@@ -15,6 +15,11 @@ class Compilatio
15
15
{
16
16
/** Identification key for the Compilatio account*/
17
17
public $ key ;
18
+
19
+ /**
20
+ * @var Client
21
+ */
22
+ public $ client ;
18
23
/**
19
24
* @var string
20
25
*/
@@ -24,11 +29,6 @@ class Compilatio
24
29
private $ proxyHost ;
25
30
private $ proxyPort ;
26
31
27
- /**
28
- * @var Client
29
- */
30
- public $ client ;
31
-
32
32
/**
33
33
* Compilatio constructor.
34
34
*
@@ -62,36 +62,6 @@ public function __construct()
62
62
$ this ->client = new Client ($ clientConfig );
63
63
}
64
64
65
- /**
66
- * @throws Exception
67
- */
68
- protected function getSettings (): array
69
- {
70
- if (empty (api_get_configuration_value ('allow_compilatio_tool ' )) ||
71
- empty (api_get_configuration_value ('compilatio_tool ' ))
72
- ) {
73
- throw new Exception ('Compilatio not available ' );
74
- }
75
-
76
- $ compilatioTool = api_get_configuration_value ('compilatio_tool ' );
77
-
78
- if (!isset ($ compilatioTool ['settings ' ])) {
79
- throw new Exception ('Compilatio config available ' );
80
- }
81
-
82
- $ settings = $ compilatioTool ['settings ' ];
83
-
84
- if (empty ($ settings ['key ' ])) {
85
- throw new Exception ('API key not available ' );
86
- }
87
-
88
- if (empty ($ settings ['api_url ' ])) {
89
- throw new Exception ('Api URL not available ' );
90
- }
91
-
92
- return $ settings ;
93
- }
94
-
95
65
/**
96
66
* @return string
97
67
*/
@@ -153,20 +123,20 @@ public function sendDoc(
153
123
'filename ' => basename ($ filename ),
154
124
'indexed ' => 'true ' ,
155
125
'user_notes ' => [
156
- 'description ' => $ description
126
+ 'description ' => $ description,
157
127
],
158
128
'authors ' => [
159
129
[
160
130
'firstname ' => $ user ->getFirstname (),
161
131
'lastname ' => $ user ->getlastname (),
162
132
'email_address ' => $ user ->getEmail (),
163
- ]
133
+ ],
164
134
],
165
135
'depositor ' => [
166
136
'firstname ' => $ user ->getFirstname (),
167
137
'lastname ' => $ user ->getlastname (),
168
138
'email_address ' => $ user ->getEmail (),
169
- ]
139
+ ],
170
140
];
171
141
172
142
try {
@@ -176,14 +146,14 @@ public function sendDoc(
176
146
[
177
147
'multipart ' => [
178
148
[
179
- 'name ' => 'postData ' ,
180
- 'contents ' => json_encode ($ postData )
149
+ 'name ' => 'postData ' ,
150
+ 'contents ' => json_encode ($ postData ),
181
151
],
182
152
[
183
- 'name ' => 'file ' ,
153
+ 'name ' => 'file ' ,
184
154
'contents ' => Utils::tryFopen ($ filepath , 'r ' ),
185
- ]
186
- ]
155
+ ],
156
+ ],
187
157
]
188
158
)
189
159
->getBody ()
@@ -238,7 +208,6 @@ public function getDoc(string $documentId): array
238
208
*/
239
209
public function deldoc (string $ documentId )
240
210
{
241
-
242
211
}
243
212
244
213
/**
@@ -255,7 +224,7 @@ public function startAnalyse(string $compilatioId): string
255
224
[
256
225
'json ' => [
257
226
'doc_id ' => $ compilatioId ,
258
- 'recipe_name ' => 'anasim '
227
+ 'recipe_name ' => 'anasim ' ,
259
228
],
260
229
]
261
230
)
@@ -332,7 +301,7 @@ public function getCompilatioId(int $documentId, int $courseId): ?string
332
301
$ result = Database::query ($ sql );
333
302
$ result = Database::fetch_object ($ result );
334
303
335
- return $ result ? (string )$ result ->compilatio_id : null ;
304
+ return $ result ? (string ) $ result ->compilatio_id : null ;
336
305
}
337
306
338
307
public function giveWorkIdState (int $ workId ): string
@@ -372,7 +341,7 @@ public function giveWorkIdState(int $workId): string
372
341
$ actionCompilatio .= "<div style='font-size:80%;font-style:italic;margin-bottom:5px;'> "
373
342
.get_lang ('CompilatioAnalysisPercentage ' )
374
343
."</div> " ;
375
- $ actionCompilatio .= $ spinnerIcon .PHP_EOL .get_lang ('CompilatioAnalysisEnding ' );
344
+ $ actionCompilatio .= $ spinnerIcon .PHP_EOL .get_lang ('CompilatioAnalysisEnding ' );
376
345
break ;
377
346
case 'waiting ' :
378
347
$ actionCompilatio .= $ spinnerIcon .PHP_EOL .get_lang ('CompilatioWaitingAnalysis ' );
@@ -388,4 +357,34 @@ public function giveWorkIdState(int $workId): string
388
357
389
358
return $ workId .'| ' .$ actionCompilatio .'| ' .$ status .'| ' ;
390
359
}
360
+
361
+ /**
362
+ * @throws Exception
363
+ */
364
+ protected function getSettings (): array
365
+ {
366
+ if (empty (api_get_configuration_value ('allow_compilatio_tool ' )) ||
367
+ empty (api_get_configuration_value ('compilatio_tool ' ))
368
+ ) {
369
+ throw new Exception ('Compilatio not available ' );
370
+ }
371
+
372
+ $ compilatioTool = api_get_configuration_value ('compilatio_tool ' );
373
+
374
+ if (!isset ($ compilatioTool ['settings ' ])) {
375
+ throw new Exception ('Compilatio config available ' );
376
+ }
377
+
378
+ $ settings = $ compilatioTool ['settings ' ];
379
+
380
+ if (empty ($ settings ['key ' ])) {
381
+ throw new Exception ('API key not available ' );
382
+ }
383
+
384
+ if (empty ($ settings ['api_url ' ])) {
385
+ throw new Exception ('Api URL not available ' );
386
+ }
387
+
388
+ return $ settings ;
389
+ }
391
390
}
0 commit comments