Pārlūkot izejas kodu

Minor - format code

jmontoyaa 7 gadi atpakaļ
vecāks
revīzija
4ee9ef919f

+ 38 - 10
main/inc/lib/MoodleImport.php

@@ -140,7 +140,11 @@ class MoodleImport
                                 // Create a Forum category based on Moodle forum type.
                                 $catForumValues['forum_category_title'] = $moduleValues['type'];
                                 $catForumValues['forum_category_comment'] = '';
-                                $catId = store_forumcategory($catForumValues, $courseInfo, false);
+                                $catId = store_forumcategory(
+                                    $catForumValues,
+                                    $courseInfo,
+                                    false
+                                );
                                 $forumValues = [];
                                 $forumValues['forum_title'] = $moduleValues['name'];
                                 $forumValues['forum_image'] = '';
@@ -252,7 +256,10 @@ class MoodleImport
                                 $moduleXml = @file_get_contents($destinationDir.'/'.$moduleDir.'/'.$moduleName.'.xml');
                                 $filesXml = @file_get_contents($destinationDir.'/files.xml');
                                 $moduleValues = $this->readResourceModule($moduleXml);
-                                $mainFileModuleValues = $this->readMainFilesXml($filesXml, $moduleValues['contextid']);
+                                $mainFileModuleValues = $this->readMainFilesXml(
+                                    $filesXml,
+                                    $moduleValues['contextid']
+                                );
                                 $fileInfo = array_merge($moduleValues, $mainFileModuleValues, $currentItem);
                                 $currentResourceFilePath = $destinationDir.'/files/';
                                 $dirs = new RecursiveDirectoryIterator($currentResourceFilePath);
@@ -646,8 +653,13 @@ class MoodleImport
      * @param array $importedFiles
      * @return integer db response
      */
-    public function processAnswers($questionList, $questionType, $questionInstance, $currentQuestion, $importedFiles)
-    {
+    public function processAnswers(
+        $questionList,
+        $questionType,
+        $questionInstance,
+        $currentQuestion,
+        $importedFiles
+    ) {
         switch ($questionType) {
             case 'multichoice':
                 $objAnswer = new Answer($questionInstance->id);
@@ -804,8 +816,13 @@ class MoodleImport
      * @param array $importedFiles
      * @return integer db response
      */
-    public function processUniqueAnswer($objAnswer, $answerValues, $position, &$questionWeighting, $importedFiles)
-    {
+    public function processUniqueAnswer(
+        $objAnswer,
+        $answerValues,
+        $position,
+        &$questionWeighting,
+        $importedFiles
+    ) {
         $correct = intval($answerValues['fraction']) ? intval($answerValues['fraction']) : 0;
         $answer = $answerValues['answertext'];
         $comment = $answerValues['feedback'];
@@ -841,8 +858,13 @@ class MoodleImport
      *
      * @return integer db response
      */
-    public function processTrueFalse($objAnswer, $answerValues, $position, &$questionWeighting, $importedFiles)
-    {
+    public function processTrueFalse(
+        $objAnswer,
+        $answerValues,
+        $position,
+        &$questionWeighting,
+        $importedFiles
+    ) {
         $correct = intval($answerValues['fraction']) ? intval($answerValues['fraction']) : 0;
         $answer = $answerValues['answertext'];
         $comment = $answerValues['feedback'];
@@ -879,8 +901,14 @@ class MoodleImport
      * @return integer db response
      *
      */
-    public function processFillBlanks($objAnswer, $questionType, $answerValues, &$placeholder, $position, $importedFiles)
-    {
+    public function processFillBlanks(
+        $objAnswer,
+        $questionType,
+        $answerValues,
+        &$placeholder,
+        $position,
+        $importedFiles
+    ) {
         $coursePath = api_get_course_path();
 
         switch ($questionType) {

+ 27 - 20
main/inc/lib/geometry.lib.php

@@ -70,14 +70,15 @@ function poly_compile($poly, $max, $test = false)
     $bords = array_fill(0, $bord_lenght, array()); // building this array
 
     /* adding the first point of the polygone */
-    if (is_array($bords[$poly[0]['y']])) //avoid warning
+    if (is_array($bords[$poly[0]['y']])) {
+        // avoid warning
         array_push($bords[$poly[0]['y']], $poly[0]['x']);
+    }
 
     $i = 1; // we re-use $i and $old_pente bellow the loop
     $old_pente = 0;
-    for (;    // for each points of the polygon but the first
-        $i < sizeof($poly) && (!empty($poly[$i]['x']) && !empty($poly[$i]['y'])); $i++) {
-
+     // for each points of the polygon but the first
+    for (; $i < sizeof($poly) && (!empty($poly[$i]['x']) && !empty($poly[$i]['y'])); $i++) {
         /* special cases */
         if ($poly[$i - 1]['y'] == $poly[$i]['y']) {
             if ($poly[$i - 1]['x'] == $poly[$i]['x'])
@@ -104,16 +105,20 @@ function poly_compile($poly, $max, $test = false)
         // if the sign of the elevation change from the one of the
         // previous edge, the point must be added a second time inside
         // $bords
-        if ($i > 1)
+        if ($i > 1) {
             if (($old_pente < 0 && $pente > 0)
-                    || ($old_pente > 0 && $pente < 0)) {
+                || ($old_pente > 0 && $pente < 0)) {
                 if (is_array($bords[$poly[$i]['y']])) //avoid warning
+                {
                     array_push($bords[$poly[$i]['y']], $poly[$i]['x']);
+                }
 
-                if (DEBUG)
+                if (DEBUG) {
                     echo '*('.$poly[$i]['x'].
                         ';'.$poly[$i]['y'].')   ';
+                }
             }
+        }
 
         /* detect the direction of the elevation in Y */
         $dy_inc = ($poly[$i]['y'] - $poly[$i - 1]['y']) > 0 ? 1 : -1;
@@ -141,10 +146,11 @@ function poly_compile($poly, $max, $test = false)
 
         // elevation between $poly[0]['x'] and $poly[1]['x'])
         $rest = $poly[0]['y'] - $poly[1]['y'];
-        if ($rest != 0)
+        if ($rest != 0) {
             $pente1 = ($poly[0]['x'] - $poly[1]['x']) / ($rest);
-        else
+        } else {
             $pente1 = 0;
+        }
 
         // elevation between $poly[$i-1]['x'] and $poly[0]['x'])
         $pente = ($poly[$i - 1]['x'] - $poly[0]['x']) /
@@ -173,13 +179,9 @@ function poly_compile($poly, $max, $test = false)
 //        if (DEBUG) echo "init: ".$poly[$i-1]['y']."  dy_inc: ".$dy_inc.
 //            "   end: ".$poly[0]['y'];
 
-        for ($dy = $poly[$i - 1]['y'] + $dy_inc;
-            $dy != $poly[0]['y'];
-            $dy += $dy_inc)
-        {
+        for ($dy = $poly[$i - 1]['y'] + $dy_inc; $dy != $poly[0]['y']; $dy += $dy_inc) {
             $x += $pente * $dy_inc;
             array_push($bords[$dy], round($x));
-//            if (DEBUG) echo '/('.$x.';'.$dy.')   ';
         }
     }
 
@@ -233,11 +235,13 @@ function poly_dump(&$poly, $max, $format = 'raw')
         $s = "<div style='font-size: 8px; line-height:3px'><pre>\n";
     }
     for ($i = 0; $i < $max['y']; $i++) {
-        for ($j = 0; $j < $max['x']; $j++)
-            if ($poly[$j][$i] == TRUE)
+        for ($j = 0; $j < $max['x']; $j++) {
+            if ($poly[$j][$i] == true) {
                 $s .= ($format == 'html' ? "<b>1</b>" : '1');
-            else
+            } else {
                 $s .= "0";
+            }
+        }
         $s .= ($format == 'html' ? "<br />\n" : "\n");
     }
     $s .= ($format == 'html' ? "</pre></div>\n" : "\n");
@@ -259,16 +263,19 @@ function poly_result(&$poly1, &$poly2, $max)
     $surfaceOf1 = 0;
     $surfaceOf2 = 0;
 
-    for ($i = 0; $i < $max['x']; $i++)
+    for ($i = 0; $i < $max['x']; $i++) {
         for ($j = 0; $j < $max['y']; $j++) {
             if (isset($poly1[$i][$j]) && ($poly1[$i][$j] == true)) {
                 $surfaceOf1++;
-                if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == false))
+                if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == false)) {
                     $onlyIn1++;
+                }
             }
-            if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == true))
+            if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == true)) {
                 $surfaceOf2++;
+            }
         }
+    }
 
     return array(
         "s1" => $surfaceOf1,

+ 5 - 1
main/inc/lib/glossary.lib.php

@@ -755,6 +755,10 @@ class GlossaryManager
                 'add_signatures' => $signatures
             ]
         );
-        $pdf->exportFromHtmlToDocumentsArea($template->fetch($layout), $fileName, $courseId);
+        $pdf->exportFromHtmlToDocumentsArea(
+            $template->fetch($layout),
+            $fileName,
+            $courseId
+        );
     }
 }

+ 1 - 1
main/inc/lib/import.lib.php

@@ -49,7 +49,7 @@ class Import
      *   $result [0]['Email'] = 'john.doe@mail. com';
      *   $result [1]['FirstName'] = 'Adam';
      *   ...
-     * @param string $filename	The path to the CSV-file which should be imported.
+     * @param string $filename The path to the CSV-file which should be imported.
      * @return array Returns an array (in the system encoding) that contains all data from the CSV-file.
      *
      *

+ 36 - 8
main/inc/lib/myspace.lib.php

@@ -59,14 +59,32 @@ class MySpace
     {
         $menu_items = array();
         $menu_items[] = Display::url(
-            Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
+            Display::return_icon(
+                'stats.png',
+                get_lang('MyStats'),
+                '',
+                ICON_SIZE_MEDIUM
+            ),
             api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
         );
         $menu_items[] = Display::url(
-            Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32),
+            Display::return_icon(
+                'teacher.png',
+                get_lang('TeacherInterface'),
+                array(),
+                32
+            ),
             api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher'
         );
-        $menu_items[] = Display::url(Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), 32), '#');
+        $menu_items[] = Display::url(
+            Display::return_icon(
+                'star_na.png',
+                get_lang('AdminInterface'),
+                array(),
+                32
+            ),
+            '#'
+        );
         $menu_items[] = Display::url(
             Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), 32),
             api_get_path(WEB_CODE_PATH).'tracking/exams.php'
@@ -565,12 +583,18 @@ class MySpace
 
     public static function sort_users($a, $b)
     {
-        return api_strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
+        return api_strcmp(
+            trim(api_strtolower($a[$_SESSION['tracking_column']])),
+            trim(api_strtolower($b[$_SESSION['tracking_column']]))
+        );
     }
 
     public static function rsort_users($a, $b)
     {
-        return api_strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
+        return api_strcmp(
+            trim(api_strtolower($b[$_SESSION['tracking_column']])),
+            trim(api_strtolower($a[$_SESSION['tracking_column']]))
+        );
     }
 
     /**
@@ -1033,9 +1057,13 @@ class MySpace
                 null,
                 false
             );
-            if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned
+            if ($last_login_date_tmp != false &&
+                $last_login_date == false
+            ) { // TODO: To be cleaned
                 $last_login_date = $last_login_date_tmp;
-            } elseif ($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned.
+            } elseif ($last_login_date_tmp != false &&
+                $last_login_date != false
+            ) { // TODO: Repeated previous condition. To be cleaned.
                 // Find the max and assign it to first_login_date
                 if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
                     $last_login_date = $last_login_date_tmp;
@@ -1220,7 +1248,7 @@ class MySpace
                 );
                 if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
                     $last_login_date = $last_login_date_tmp;
-                } else if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
+                } elseif ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
                     // Find the max and assign it to first_login_date
                     if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
                         $last_login_date = $last_login_date_tmp;