示例#1
0
 /**
  * Record an hotspot spot for this attempt at answering an hotspot question
  * @param	int		Exercise ID
  * @param	int		Question ID
  * @param	int		Answer ID
  * @param	int		Whether this answer is correct (1) or not (0)
  * @param	string	Coordinates of this point (e.g. 123;324)
  * @param	bool update results?
  * @return	boolean	Result of the insert query
  * @uses Course code and user_id from global scope $_cid and $_user
  */
 public static function saveExerciseAttemptHotspot($exe_id, $question_id, $answer_id, $correct, $coords, $updateResults = false, $exerciseId = 0)
 {
     global $safe_lp_id, $safe_lp_item_id;
     if ($updateResults == false) {
         // Validation in case of fraud with activated control time
         if (!ExerciseLib::exercise_time_control_is_valid($exerciseId, $safe_lp_id, $safe_lp_item_id)) {
             $correct = 0;
         }
     }
     $tbl_track_e_hotspot = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
     if ($updateResults) {
         $params = array('hotspot_correct' => $correct, 'hotspot_coordinate' => $coords);
         Database::update($tbl_track_e_hotspot, $params, array('hotspot_user_id = ? AND hotspot_exe_id = ? AND hotspot_question_id = ? AND hotspot_answer_id = ? ' => array(api_get_user_id(), $exe_id, $question_id, $answer_id, $answer_id)));
     } else {
         return Database::insert($tbl_track_e_hotspot, ['hotspot_course_code' => api_get_course_id(), 'hotspot_user_id' => api_get_user_id(), 'c_id' => api_get_course_int_id(), 'hotspot_exe_id' => $exe_id, 'hotspot_question_id' => $question_id, 'hotspot_answer_id' => $answer_id, 'hotspot_correct' => $correct, 'hotspot_coordinate' => $coords]);
     }
 }
示例#2
0
             if ($origin != 'learnpath') {
                 //so we are not in learnpath tool
                 echo '</div>';
                 //End glossary div
                 Display::display_footer();
             } else {
                 echo '</body></html>';
             }
             exit;
         }
     }
 } else {
     //Time control is only enabled for ONE PER PAGE
     if (!empty($exe_id) && is_numeric($exe_id)) {
         //Verify if the current test is fraudulent
         $check = ExerciseLib::exercise_time_control_is_valid($exerciseId, $learnpath_id, $learnpath_item_id);
         if ($check) {
             $sql_exe_result = "";
             if ($debug) {
                 error_log('12. exercise_time_control_is_valid is valid');
             }
         } else {
             $sql_exe_result = ", exe_result = 0";
             if ($debug) {
                 error_log('12. exercise_time_control_is_valid is NOT valid then exe_result = 0 ');
             }
         }
     }
     if ($objExercise->review_answers) {
         //header('Location: '.$urlMainExercise.'exercise_reminder.php?'.$params);
         header("Location: " . $urlMainExercise . "exercise_result.php?" . api_get_cidreq() . "&exe_id={$exe_id}&origin={$origin}&learnpath_id={$learnpath_id}&learnpath_item_id={$learnpath_item_id}&learnpath_item_view_id={$learnpath_item_view_id}");
示例#3
0
 /**
  * Record an hotspot spot for this attempt at answering an hotspot question
  * @param	int		Exercise ID
  * @param	int		Question ID
  * @param	int		Answer ID
  * @param	int		Whether this answer is correct (1) or not (0)
  * @param	string	Coordinates of this point (e.g. 123;324)
  * @param	bool update results?
  * @return	boolean	Result of the insert query
  * @uses Course code and user_id from global scope $_cid and $_user
  */
 public static function saveExerciseAttemptHotspot($exe_id, $question_id, $answer_id, $correct, $coords, $updateResults = false, $exerciseId = 0)
 {
     global $safe_lp_id, $safe_lp_item_id;
     if ($updateResults == false) {
         // Validation in case of fraud with activated control time
         if (!ExerciseLib::exercise_time_control_is_valid($exerciseId, $safe_lp_id, $safe_lp_item_id)) {
             $correct = 0;
         }
     }
     $tbl_track_e_hotspot = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
     if ($updateResults) {
         $params = array('hotspot_correct' => $correct, 'hotspot_coordinate' => $coords);
         Database::update($tbl_track_e_hotspot, $params, array('hotspot_user_id = ? AND hotspot_exe_id = ? AND hotspot_question_id = ? AND hotspot_answer_id = ? ' => array(api_get_user_id(), $exe_id, $question_id, $answer_id, $answer_id)));
     } else {
         $sql = "INSERT INTO {$tbl_track_e_hotspot} (hotspot_course_code, hotspot_user_id, c_id, hotspot_exe_id, hotspot_question_id, hotspot_answer_id, hotspot_correct, hotspot_coordinate)\n                VALUES (\n                '" . api_get_course_id() . "',\n                " . api_get_user_id() . "'," . " " . api_get_course_int_id() . ", " . " '" . Database::escape_string($exe_id) . "', " . " '" . Database::escape_string($question_id) . "'," . " '" . Database::escape_string($answer_id) . "'," . " '" . Database::escape_string($correct) . "'," . " '" . Database::escape_string($coords) . "')";
         return $result = Database::query($sql);
     }
 }
示例#4
0
 /**
  * Record an hotspot spot for this attempt at answering an hotspot question
  * @param	int		Exercise ID
  * @param	int		Question ID
  * @param	int		Answer ID
  * @param	int		Whether this answer is correct (1) or not (0)
  * @param	string	Coordinates of this point (e.g. 123;324)
  * @param	bool update results?
  * @return	boolean	Result of the insert query
  * @uses Course code and user_id from global scope $_cid and $_user
  */
 public static function saveExerciseAttemptHotspot($exe_id, $question_id, $answer_id, $correct, $coords, $updateResults = false, $exerciseId = 0)
 {
     global $safe_lp_id, $safe_lp_item_id;
     $em = Database::getManager();
     if ($updateResults == false) {
         // Validation in case of fraud with activated control time
         if (!ExerciseLib::exercise_time_control_is_valid($exerciseId, $safe_lp_id, $safe_lp_item_id)) {
             $correct = 0;
         }
     }
     if ($updateResults) {
         $em->createQuery('
                 UPDATE ChamiloCoreBundle:TrackEHotspot teh
                 SET teh.hotspotCorrect = :correct,
                     teh.hotspotCoordinate = :coords
                 WHERE teh.hotspotUserId = :user AND teh.hotspotExeId = :exe AND
                     teh.hotspotQuestionId = :question AND teh.hotspotAnswerId = :answer
             ')->execute(['correct' => $correct, 'coords' => $coords, 'user' => api_get_user_id(), 'exe' => $exe_id, 'question' => $question_id, 'answer' => $answer_id]);
     } else {
         $course = $em->find('ChamiloCoreBundle:', api_get_course_int_id());
         $trackEHotspot = new \Chamilo\CoreBundle\Entity\TrackEHotspot();
         $trackEHotspot->setCourse($course)->setHotspotUserId(api_get_user_id())->setHotspotExeId($exe_id)->setHotspotQuestionId($question_id)->setHotspotAnswerId($answer_id)->setHotspotCorrect($correct)->setHotspotCoordinate($coords);
         $em->persist($trackEHotspot);
         $em->flush();
         return $trackEHotspot->getHotspotId();
     }
 }