Bladeren bron

Set course id to fix PHP notice

jmontoyaa 9 jaren geleden
bovenliggende
commit
9822473ef5

+ 3 - 2
main/exercice/exercise.class.php

@@ -132,6 +132,7 @@ class Exercise
 
 
         $id  = intval($id);
         $id  = intval($id);
         if (empty($this->course_id)) {
         if (empty($this->course_id)) {
+
             return false;
             return false;
         }
         }
         $sql = "SELECT * FROM $TBL_EXERCISES WHERE c_id = ".$this->course_id." AND id = ".$id;
         $sql = "SELECT * FROM $TBL_EXERCISES WHERE c_id = ".$this->course_id." AND id = ".$id;
@@ -5797,10 +5798,10 @@ class Exercise
      */
      */
     private function setMediaList($questionList)
     private function setMediaList($questionList)
     {
     {
-        $mediaList= array();
+        $mediaList = array();
         if (!empty($questionList)) {
         if (!empty($questionList)) {
             foreach ($questionList as $questionId) {
             foreach ($questionList as $questionId) {
-                $objQuestionTmp = Question::read($questionId);
+                $objQuestionTmp = Question::read($questionId, $this->course_id);
 
 
                 // If a media question exists
                 // If a media question exists
                 if (isset($objQuestionTmp->parent_id) && $objQuestionTmp->parent_id != 0) {
                 if (isset($objQuestionTmp->parent_id) && $objQuestionTmp->parent_id != 0) {

+ 2 - 1
main/gradebook/lib/be/category.class.php

@@ -897,6 +897,8 @@ class Category implements GradebookItem
             if (!empty($cats)) {
             if (!empty($cats)) {
                 /** @var Category $cat */
                 /** @var Category $cat */
                 foreach ($cats as $cat) {
                 foreach ($cats as $cat) {
+                    $cat->set_session_id($session_id);
+                    $cat->set_course_code($course_code);
                     $cat->setStudentList($this->getStudentList());
                     $cat->setStudentList($this->getStudentList());
                     $score = $cat->calc_score(
                     $score = $cat->calc_score(
                         $stud_id,
                         $stud_id,
@@ -2299,5 +2301,4 @@ class Category implements GradebookItem
     {
     {
         $this->studentList = $list;
         $this->studentList = $list;
     }
     }
-
 }
 }

+ 7 - 6
main/gradebook/lib/be/exerciselink.class.php

@@ -173,7 +173,8 @@ class ExerciseLink extends AbstractLink
                     exe_exo_id   = ".(int)$this->get_ref_id();
                     exe_exo_id   = ".(int)$this->get_ref_id();
         $result = Database::query($sql);
         $result = Database::query($sql);
         $number=Database::fetch_row($result);
         $number=Database::fetch_row($result);
-        return ($number[0] != 0);
+
+        return $number[0] != 0;
     }
     }
 
 
     /**
     /**
@@ -192,7 +193,7 @@ class ExerciseLink extends AbstractLink
 
 
         /* the following query should be similar (in conditions) to the one used
         /* the following query should be similar (in conditions) to the one used
         in exercice/exercice.php, look for note-query-exe-results marker*/
         in exercice/exercice.php, look for note-query-exe-results marker*/
-        $session_id = api_get_session_id();
+        $session_id = $this->get_session_id();
         $courseId = $this->getCourseId();
         $courseId = $this->getCourseId();
 	    $exercise = new Exercise($courseId);
 	    $exercise = new Exercise($courseId);
         $exercise->read($this->get_ref_id());
         $exercise->read($this->get_ref_id());
@@ -207,8 +208,8 @@ class ExerciseLink extends AbstractLink
 			            orig_lp_item_id = 0 AND
 			            orig_lp_item_id = 0 AND
 			            status <> 'incomplete' AND
 			            status <> 'incomplete' AND
 			            session_id = $session_id AND
 			            session_id = $session_id AND
-                                    c_id = $courseId 
-                                ";
+                        c_id = $courseId 
+                    ";
 		    } else {
 		    } else {
 		        $lpId = null;
 		        $lpId = null;
 		        if (!empty($exercise->lpList)) {
 		        if (!empty($exercise->lpList)) {
@@ -223,8 +224,8 @@ class ExerciseLink extends AbstractLink
 		                    orig_lp_id = $lpId AND
 		                    orig_lp_id = $lpId AND
 		                    status <> 'incomplete' AND
 		                    status <> 'incomplete' AND
 		                    session_id = $session_id AND
 		                    session_id = $session_id AND
-                                    c_id = $courseId 
-                                ";
+                            c_id = $courseId 
+                        ";
 		    }
 		    }
 
 
             if (!empty($stud_id) && $type != 'ranking') {
             if (!empty($stud_id) && $type != 'ranking') {