Completed
Pull Request — 1.10.x (#1244)
by
unknown
42:26
created
main/plagiarism/compilatio/upload.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
 
16 16
 /* Variables */ 
17 17
 $typeMessage = 0;
18
-$errorCodeNotValid = get_lang('compilatioError') . get_lang('documentCodeNotValid');
19
-$errorLoadError = get_lang('compilatioLoadError') . get_lang('compilatioContactAdmin');
18
+$errorCodeNotValid = get_lang('compilatioError').get_lang('documentCodeNotValid');
19
+$errorLoadError = get_lang('compilatioLoadError').get_lang('compilatioContactAdmin');
20 20
 
21 21
 /*message to the user for be patient*/
22 22
 $msgWait = get_lang('PleaseWaitThisCouldTakeAWhile');
23 23
 
24 24
 /* if we have to upload severals documents*/
25
-if(isset($_REQUEST['type']) && $_REQUEST['type']=="multi"){
25
+if (isset($_REQUEST['type']) && $_REQUEST['type'] == "multi") {
26 26
     $docs = preg_split("/a/", $_REQUEST['doc']);
27
-    for ($k=0 ; $k < sizeof($docs)-1 ; $k++)	{
27
+    for ($k = 0; $k < sizeof($docs) - 1; $k++) {
28 28
         /* We have to modify the timeout server for send the heavy files */
29 29
         set_time_limit(600);
30 30
         $documentId = 0;
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
             $doc = Database::fetch_object($sqlResult);
63 63
             if ($doc) {
64 64
                 /*We load the document in compilatio through the webservice */
65
-                $currentCourseRepositoryWeb = api_get_path(WEB_COURSE_PATH) . $_course["path"] . "/";
66
-                $WrkUrl = $currentCourseRepositoryWeb . $doc->url;
67
-                $LocalWrkUrl = api_get_path(SYS_COURSE_PATH) . $_course["path"] . "/" . $doc->url;
65
+                $currentCourseRepositoryWeb = api_get_path(WEB_COURSE_PATH).$_course["path"]."/";
66
+                $WrkUrl = $currentCourseRepositoryWeb.$doc->url;
67
+                $LocalWrkUrl = api_get_path(SYS_COURSE_PATH).$_course["path"]."/".$doc->url;
68 68
                 $LocalWrkTitle = $doc->title;
69 69
                 $mime = typeMime($LocalWrkTitle);
70 70
                 $compilatio = new compilatio(
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
                 if ($compilatioParameter['mode_transport'] == 'wget') {
77 77
                     /*Compilatio's server recover tjre file throught wget like this:
78 78
                     username:password@http://somedomain.com/reg/remotefilename.tar.gz */
79
-                    if (strlen($compilatioParameter['wget_uri']) > 2)  {
79
+                    if (strlen($compilatioParameter['wget_uri']) > 2) {
80 80
                         $filename = ereg_replace("/$",
81 81
                                 "",
82 82
                                 $compilatioParameter['wget_uri'])
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
     if ($typeMessage == 1) {
141 141
         $message = $errorCodeNotValid;
142 142
         Display::display_error_message($message);
143
-    }elseif($typeMessage == 2){
143
+    }elseif ($typeMessage == 2) {
144 144
         $message = $errorLoadError;
145 145
         Display::display_error_message($message);
146
-    }else{
146
+    } else {
147 147
         $message = $msgWait;
148 148
         Display::display_confirmation_message($message);
149 149
     }
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
         . $coursId;
163 163
 	$sqlResult = Database::query($query);
164 164
 	$doc = Database::fetch_object($sqlResult);
165
-	$currentCourseRepositoryWeb = api_get_path(WEB_COURSE_PATH) . $_course["path"] . "/";
166
-	$WrkUrl = $currentCourseRepositoryWeb . $doc->url;
165
+	$currentCourseRepositoryWeb = api_get_path(WEB_COURSE_PATH).$_course["path"]."/";
166
+	$WrkUrl = $currentCourseRepositoryWeb.$doc->url;
167 167
 	$WrkTitle = $doc->title;
168
-	$LocalWrkUrl = api_get_path(SYS_COURSE_PATH).$_course["path"] . "/" . $doc->url;
168
+	$LocalWrkUrl = api_get_path(SYS_COURSE_PATH).$_course["path"]."/".$doc->url;
169 169
 	$mime = typeMime($WrkTitle);
170 170
 	$compilatio = new compilatio(
171 171
         $compilatioParameter['key'],
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     } else {
198 198
 		$pieces = explode("/", $doc->url);
199 199
 		$nbPieces = count($pieces);
200
-		$filename = $pieces[$nbPieces-1];
200
+		$filename = $pieces[$nbPieces - 1];
201 201
         $compilatioId = $compilatio->sendDoc($doc->title, '', $filename, $mime, file_get_contents($LocalWrkUrl));
202 202
     }
203 203
 	$compTable = Database::get_course_table("plagiarism_compilatio_docs");
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
     if ($typeMessage == 1) {
234 234
         $message = $errorCodeNotValid;
235 235
         Display::display_error_message($message);
236
-    }elseif($typeMessage == 2){
236
+    }elseif ($typeMessage == 2) {
237 237
         $message = $errorLoadError;
238 238
         Display::display_error_message($message);
239
-    }else{
239
+    } else {
240 240
         $message = $msgWait;
241 241
         Display::display_confirmation_message($message);
242 242
 	}
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 function getWorkTitle($docId, $coursId) {
269 269
     $res = "";
270 270
     $workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);    
271
-    $sql = "SELECT title FROM " . $workTable . " WHERE c_id=" . $coursId . " AND id=" . $docId;
271
+    $sql = "SELECT title FROM ".$workTable." WHERE c_id=".$coursId." AND id=".$docId;
272 272
     $res = Database::query($sql);
273 273
     if (Database::num_rows($res) > 0) {
274 274
         $data = Database::fetch_array($res);
@@ -312,15 +312,15 @@  discard block
 block discarded – undo
312 312
     $filename = getFilename($urlFile);
313 313
     $work_folder = getWorkFolder($urlFile);
314 314
     $urlFile_ext = getFileExtension($urlFile);
315
-    $coursePath = api_get_path(SYS_COURSE_PATH) . $_course["path"] . "/";
315
+    $coursePath = api_get_path(SYS_COURSE_PATH).$_course["path"]."/";
316 316
     $workTitle = getWorkTitle($docId, $coursId);
317 317
 
318 318
     if ($extensionFile != "" && $urlFile_ext == "") {
319 319
         /*rename the files in the FS whit the extension*/
320 320
         $shortFilename = $filename;                                        
321 321
         $cleanWorkTitle = api_replace_dangerous_char($workTitle); 
322
-        $newestFilename = $shortFilename . "_" . $cleanWorkTitle;
323
-        rename($coursePath . $urlFile, $coursePath . $work_folder . $newestFilename);
322
+        $newestFilename = $shortFilename."_".$cleanWorkTitle;
323
+        rename($coursePath.$urlFile, $coursePath.$work_folder.$newestFilename);
324 324
         /*rename the db's input with the extension*/
325 325
         $sql = "UPDATE "
326 326
             . $workTable
Please login to merge, or discard this patch.
main/inc/ajax/model.ajax.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
 $action = $_GET['a'];
12 12
 $page = intval($_REQUEST['page']); //page
13 13
 $limit = intval($_REQUEST['rows']); //quantity of rows
14
-$sidx = $_REQUEST['sidx'];         //index (field) to filter
15
-$sord = $_REQUEST['sord'];         //asc or desc
14
+$sidx = $_REQUEST['sidx']; //index (field) to filter
15
+$sord = $_REQUEST['sord']; //asc or desc
16 16
 
17 17
 if (strpos(strtolower($sidx), 'asc') !== false) {
18 18
     $sidx = str_replace(array('asc', ','), '', $sidx);
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     $sord = 'desc';
25 25
 }
26 26
 
27
-if (!in_array($sord, array('asc','desc'))) {
27
+if (!in_array($sord, array('asc', 'desc'))) {
28 28
     $sord = 'desc';
29 29
 }
30 30
 
@@ -64,19 +64,19 @@  discard block
 block discarded – undo
64 64
 function getWhereClause($col, $oper, $val)
65 65
 {
66 66
     $ops = array(
67
-        'eq' => '=',        //equal
68
-        'ne' => '<>',       //not equal
69
-        'lt' => '<',        //less than
70
-        'le' => '<=',       //less than or equal
71
-        'gt' => '>',        //greater than
72
-        'ge' => '>=',       //greater than or equal
73
-        'bw' => 'LIKE',     //begins with
67
+        'eq' => '=', //equal
68
+        'ne' => '<>', //not equal
69
+        'lt' => '<', //less than
70
+        'le' => '<=', //less than or equal
71
+        'gt' => '>', //greater than
72
+        'ge' => '>=', //greater than or equal
73
+        'bw' => 'LIKE', //begins with
74 74
         'bn' => 'NOT LIKE', //doesn't begin with
75
-        'in' => 'LIKE',     //is in
75
+        'in' => 'LIKE', //is in
76 76
         'ni' => 'NOT LIKE', //is not in
77
-        'ew' => 'LIKE',     //ends with
77
+        'ew' => 'LIKE', //ends with
78 78
         'en' => 'NOT LIKE', //doesn't end with
79
-        'cn' => 'LIKE',     //contains
79
+        'cn' => 'LIKE', //contains
80 80
         'nc' => 'NOT LIKE'  //doesn't contain
81 81
     );
82 82
 
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 
101 101
 // If there is no search request sent by jqgrid, $where should be empty
102 102
 $whereCondition = null;
103
-$operation = isset($_REQUEST['oper'])  ? $_REQUEST['oper']  : false;
104
-$exportFormat = isset($_REQUEST['export_format'])  ? $_REQUEST['export_format']  : 'csv';
105
-$searchField = isset($_REQUEST['searchField'])  ? $_REQUEST['searchField']  : false;
106
-$searchOperator = isset($_REQUEST['searchOper'])   ? $_REQUEST['searchOper']   : false;
103
+$operation = isset($_REQUEST['oper']) ? $_REQUEST['oper'] : false;
104
+$exportFormat = isset($_REQUEST['export_format']) ? $_REQUEST['export_format'] : 'csv';
105
+$searchField = isset($_REQUEST['searchField']) ? $_REQUEST['searchField'] : false;
106
+$searchOperator = isset($_REQUEST['searchOper']) ? $_REQUEST['searchOper'] : false;
107 107
 $searchString = isset($_REQUEST['searchString']) ? $_REQUEST['searchString'] : false;
108 108
 $search = isset($_REQUEST['_search']) ? $_REQUEST['_search'] : false;
109 109
 $forceSearch = isset($_REQUEST['_force_search']) ? $_REQUEST['_force_search'] : false;
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             foreach ($filters->rules as $key => $rule) {
168 168
                 $whereCondition .= getWhereClause($rule->field, $rule->op, $rule->data);
169 169
 
170
-                if ($counter < count($filters->rules) -1) {
170
+                if ($counter < count($filters->rules) - 1) {
171 171
                     $whereCondition .= $filters->groupOp;
172 172
                 }
173 173
                 $counter++;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
         $sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0;
203 203
         $courseCodeList = array();
204
-        $userIdList  = array();
204
+        $userIdList = array();
205 205
         $sessionIdList = [];
206 206
         $searchByGroups = false;
207 207
         if (api_is_drh()) {
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 $total_pages = 0;
555 555
 if ($count > 0) {
556 556
     if (!empty($limit)) {
557
-        $total_pages = ceil((float)$count/(float)$limit);
557
+        $total_pages = ceil((float) $count / (float) $limit);
558 558
     }
559 559
 }
560 560
 if ($page > $total_pages) {
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
                 $plagiarismColumns = array('compilatio');
813 813
             }
814 814
         }
815
-        if (isset($_GET['type'])  && $_GET['type'] == 'simple') {
815
+        if (isset($_GET['type']) && $_GET['type'] == 'simple') {
816 816
             $columns = array(
817 817
                 //'type',
818 818
                 'firstname',
@@ -847,14 +847,14 @@  discard block
 block discarded – undo
847 847
                 $plagiarismColumns = array('compilatio');
848 848
             }
849 849
         }
850
-        if (isset($_GET['type'])  && $_GET['type'] == 'simple') {
850
+        if (isset($_GET['type']) && $_GET['type'] == 'simple') {
851 851
             $columns = array(
852
-                'type', 'firstname', 'lastname',  'title', 'qualification', 'sent_date', 'qualificator_id'
852
+                'type', 'firstname', 'lastname', 'title', 'qualification', 'sent_date', 'qualificator_id'
853 853
             );
854 854
             $columns = array_merge($columns, $plagiarismColumns);
855 855
             $columns[] = 'actions';
856 856
         } else {
857
-            $columns = array('type', 'firstname', 'lastname',  'title', 'sent_date');
857
+            $columns = array('type', 'firstname', 'lastname', 'title', 'sent_date');
858 858
             $columns = array_merge($columns, $plagiarismColumns);
859 859
             $columns[] = 'actions';
860 860
         }
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
                 $plagiarismColumns = array('compilatio');
869 869
             }
870 870
         }
871
-        if (isset($_GET['type'])  && $_GET['type'] == 'simple') {
871
+        if (isset($_GET['type']) && $_GET['type'] == 'simple') {
872 872
             $columns = array(
873 873
                 'type', 'title', 'qualification', 'sent_date', 'qualificator_id'
874 874
             );
@@ -900,10 +900,10 @@  discard block
 block discarded – undo
900 900
     case 'get_exercise_results':
901 901
         $course = api_get_course_info();
902 902
         // Used inside ExerciseLib::get_exam_results_data()
903
-        $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document";
903
+        $documentPath = api_get_path(SYS_COURSE_PATH).$course['path']."/document";
904 904
         if ($is_allowedToEdit || api_is_student_boss()) {
905 905
             $columns = array(
906
-                'firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score',  'user_ip', 'status', 'lp', 'actions'
906
+                'firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score', 'user_ip', 'status', 'lp', 'actions'
907 907
             );
908 908
             $officialCodeInList = api_get_setting('show_official_code_exercise_result_list');
909 909
             if ($officialCodeInList === 'true') {
@@ -914,11 +914,11 @@  discard block
 block discarded – undo
914 914
         break;
915 915
     case 'get_hotpotatoes_exercise_results':
916 916
         $course = api_get_course_info();
917
-        $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document";
917
+        $documentPath = api_get_path(SYS_COURSE_PATH).$course['path']."/document";
918 918
         if (api_is_allowed_to_edit()) {
919
-            $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_date',  'score', 'actions');
919
+            $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_date', 'score', 'actions');
920 920
         } else {
921
-            $columns = array('exe_date',  'score', 'actions');
921
+            $columns = array('exe_date', 'score', 'actions');
922 922
         }
923 923
         $result = ExerciseLib::get_exam_results_hotpotatoes_data($start, $limit, $sidx, $sord, $hotpot_path, $whereCondition);
924 924
         break;
@@ -944,12 +944,12 @@  discard block
 block discarded – undo
944 944
         break;
945 945
     case 'get_hotpotatoes_exercise_results':
946 946
         $course = api_get_course_info();
947
-        $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document";
947
+        $documentPath = api_get_path(SYS_COURSE_PATH).$course['path']."/document";
948 948
 
949 949
         if (api_is_allowed_to_edit(null, true) || api_is_drh()) {
950
-            $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_date',  'score', 'actions');
950
+            $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_date', 'score', 'actions');
951 951
         } else {
952
-            $columns = array('exe_date',  'score', 'actions');
952
+            $columns = array('exe_date', 'score', 'actions');
953 953
         }
954 954
         $result = ExerciseLib::get_exam_results_hotpotatoes_data($start, $limit, $sidx, $sord, $hotpot_path, $whereCondition);
955 955
         break;
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
             );
979 979
         }
980 980
 
981
-        $columns =  array(
981
+        $columns = array(
982 982
             'name',
983 983
             'date',
984 984
             'course_per_session',
@@ -1014,11 +1014,11 @@  discard block
 block discarded – undo
1014 1014
                 $detailButtons = [];
1015 1015
                 $detailButtons[] = Display::url(
1016 1016
                     Display::return_icon('works.png', get_lang('WorksReport')),
1017
-                    api_get_path(WEB_CODE_PATH) . 'mySpace/works_in_session_report.php?session=' . $session['id']
1017
+                    api_get_path(WEB_CODE_PATH).'mySpace/works_in_session_report.php?session='.$session['id']
1018 1018
                 );
1019 1019
                 $detailButtons[] = Display::url(
1020 1020
                     Display::return_icon('2rightarrow.png'),
1021
-                    api_get_path(WEB_CODE_PATH) . 'mySpace/course.php?session_id=' . $session['id']
1021
+                    api_get_path(WEB_CODE_PATH).'mySpace/course.php?session_id='.$session['id']
1022 1022
                 );
1023 1023
 
1024 1024
                 $result[] = array(
@@ -1334,7 +1334,7 @@  discard block
 block discarded – undo
1334 1334
         $result = $new_result;
1335 1335
         break;
1336 1336
     case 'get_gradebooks':
1337
-        $columns = array('name', 'certificates','skills', 'actions', 'has_certificates');
1337
+        $columns = array('name', 'certificates', 'skills', 'actions', 'has_certificates');
1338 1338
         if (!in_array($sidx, $columns)) {
1339 1339
             $sidx = 'name';
1340 1340
         }
@@ -1504,7 +1504,7 @@  discard block
 block discarded – undo
1504 1504
                     if (!empty($exercises[$cnt - 4]['title'])) {
1505 1505
                         $title = ucwords(strtolower(trim($exercises[$cnt - 4]['title'])));
1506 1506
                     }
1507
-                    $columns[] = 'exer' . $i;
1507
+                    $columns[] = 'exer'.$i;
1508 1508
                     $column_names[] = $title;
1509 1509
                     $i++;
1510 1510
                     break;
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
             $sessionInfo = SessionManager::fetch($listUserSess[$user['user_id']]['id_session']);
1538 1538
             $result[$i]['session'] = $sessionInfo['name'];
1539 1539
             $result[$i]['username'] = $user['username'];
1540
-            $result[$i]['name'] = $user['lastname'] . " " . $user['firstname'];
1540
+            $result[$i]['name'] = $user['lastname']." ".$user['firstname'];
1541 1541
             $j = 1;
1542 1542
             $finalScore = 0;
1543 1543
             foreach ($quizIds as $quizID) {
@@ -1545,7 +1545,7 @@  discard block
 block discarded – undo
1545 1545
                 if (!empty($arrGrade [$user['user_id']][$quizID]) || $arrGrade [$user['user_id']][$quizID] == 0) {
1546 1546
                     $finalScore += $grade = $arrGrade [$user['user_id']][$quizID];
1547 1547
                 }
1548
-                $result[$i]['exer' . $j] = $grade;
1548
+                $result[$i]['exer'.$j] = $grade;
1549 1549
                 $j++;
1550 1550
             }
1551 1551
 
@@ -1718,9 +1718,9 @@  discard block
 block discarded – undo
1718 1718
         foreach ($result as $row) {
1719 1719
             // if results tab give not id, set id to $i otherwise id="null" for all <tr> of the jqgrid - ref #4235
1720 1720
             if (!isset($row['id']) || isset($row['id']) && $row['id'] == '') {
1721
-                $response->rows[$i]['id']= $i;
1721
+                $response->rows[$i]['id'] = $i;
1722 1722
             } else {
1723
-                $response->rows[$i]['id']= $row['id'];
1723
+                $response->rows[$i]['id'] = $row['id'];
1724 1724
             }
1725 1725
             $array = array();
1726 1726
             foreach ($columns as $col) {
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
                     $array[] = isset($row[$col]) ? Security::remove_XSS($row[$col]) : '';
1732 1732
                 }
1733 1733
             }
1734
-            $response->rows[$i]['cell']=$array;
1734
+            $response->rows[$i]['cell'] = $array;
1735 1735
             $i++;
1736 1736
         }
1737 1737
     }
Please login to merge, or discard this patch.