Merge branch '8237' into 1.10.x

1.10.x
Angel Fernando Quiroz Campos 9 years ago
commit 07002c35ed
  1. 3
      main/exercice/answer.class.php
  2. 58
      main/exercice/exercise.class.php
  3. 5
      main/exercice/exercise_result.php
  4. 1076
      main/exercice/exercise_show.php
  5. 13
      main/inc/ajax/exercise.ajax.php
  6. 1410
      main/inc/lib/exercise.lib.php

@ -72,7 +72,8 @@ class Answer
$objExercise = new Exercise($this->course_id);
$exerciseId = isset($_REQUEST['exerciseId']) ? $_REQUEST['exerciseId'] : null;
$objExercise->read($exerciseId);
if ($objExercise->random_answers == '1') {
if ($objExercise->random_answers == '1' && $this->getQuestionType() != CALCULATED_ANSWER) {
$this->readOrderedBy('rand()', '');// randomize answers
} else {
$this->read(); // natural order

@ -1,8 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Class Exercise
*
@ -164,7 +162,9 @@ class Exercise
$this->display_category_name = $object->display_category_name;
$this->pass_percentage = $object->pass_percentage;
$this->sessionId = $object->session_id;
$this->is_gradebook_locked = api_resource_is_locked_by_gradebook($id, LINK_EXERCISE);
$this->review_answers = (isset($object->review_answers) && $object->review_answers == 1) ? true : false;
$this->globalCategoryId = isset($object->global_category_id) ? $object->global_category_id : null;
$this->questionSelectionType = isset($object->question_selection_type) ? $object->question_selection_type : null;
@ -190,10 +190,10 @@ class Exercise
}
if ($object->end_time != '0000-00-00 00:00:00') {
$this->end_time = $object->end_time;
$this->end_time = $object->end_time;
}
if ($object->start_time != '0000-00-00 00:00:00') {
$this->start_time = $object->start_time;
$this->start_time = $object->start_time;
}
//control time
@ -3123,7 +3123,7 @@ class Exercise
* @param bool $show_result show results or not
* @param int $propagate_neg
* @param array $hotspot_delineation_result
*
* @param boolean $showTotalScoreAndUserChoices
* @todo reduce parameters of this function
* @return string html code
*/
@ -3746,16 +3746,7 @@ class Exercise
}
break;
case CALCULATED_ANSWER:
$calculatedAnswerId = Session::read('calculatedAnswerId');
$answer = '';
if ($calculatedAnswerId) {
$calculatedAnswerInfo = Session::read('calculatedAnswerInfo');
if (isset($calculatedAnswerInfo[$questionId])) {
$answer = $calculatedAnswerInfo[$questionId];
} else {
$answer = $objAnswerTmp->selectAnswer($calculatedAnswerId[$questionId]);
}
}
$answer = $objAnswerTmp->selectAnswer($_SESSION['calculatedAnswerId'][$questionId]);
$preArray = explode('@@', $answer);
$last = count($preArray) - 1;
$answer = '';
@ -3794,7 +3785,7 @@ class Exercise
$queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT."
WHERE
exe_id = '".$exeId."' AND
question_id= ".intval($questionId)."";
question_id= ".intval($questionId);
$resfill = Database::query($queryfill);
$str = Database::result($resfill, 0, 'answer');
api_preg_match_all('#\[([^[]*)\]#', $str, $arr);
@ -3802,7 +3793,14 @@ class Exercise
$choice = $arr[1];
if (isset($choice[$j])) {
$tmp = api_strrpos($choice[$j], ' / ');
$choice[$j] = api_substr($choice[$j], 0, $tmp);
if ($tmp) {
$choice[$j] = api_substr($choice[$j], 0, $tmp);
} else {
$tmp = ltrim($tmp, '[');
$tmp = rtrim($tmp, ']');
}
$choice[$j] = trim($choice[$j]);
// Needed to let characters ' and " to work as part of an answer
$choice[$j] = stripslashes($choice[$j]);
@ -3821,18 +3819,6 @@ class Exercise
}
$answer = '';
$realCorrectTags = $correctTags;
if ($from_database && empty($calculatedAnswerId)) {
$queryfill = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
WHERE
exe_id = '".$exeId."' AND
question_id= ".intval($questionId) ;
$resfill = Database::query($queryfill);
$rowFill = Database::fetch_assoc($resfill);
$answer = $rowFill['answer'];
$questionScore = $rowFill['marks'];
}
for ($i = 0; $i < count($realCorrectTags); $i++) {
if ($i == 0) {
$answer .= $realText[0];
@ -3855,17 +3841,10 @@ class Exercise
$answer .= ''; // remove &nbsp; that causes issue
}
$addCorrecWord = true;
// adds the correct word, followed by ] to close the blank
if (
Session::has('objExercise') &&
Session::read('objExercise')->selectResultsDisabled() == EXERCISE_FEEDBACK_TYPE_EXAM
$this->results_disabled != EXERCISE_FEEDBACK_TYPE_EXAM
) {
$addCorrecWord = false;
}
if ($addCorrecWord) {
// adds the correct word, followed by ] to close the blank
$answer .= ' / <font color="green"><b>' . $realCorrectTags[$i] . '</b></font>';
}
@ -4621,7 +4600,8 @@ class Exercise
$studentChoice,
$answerComment,
$results_disabled,
$answerId
$answerId,
$showTotalScoreAndUserChoices
);
break;
case HOT_SPOT_DELINEATION:

@ -165,6 +165,7 @@ ExerciseLib::exercise_time_control_delete(
$learnpath_id,
$learnpath_item_id
);
ExerciseLib::delete_chat_exercise_session($exe_id);
if ($origin != 'learnpath') {
@ -179,8 +180,6 @@ if ($origin != 'learnpath') {
if (api_is_allowed_to_session_edit()) {
Session::erase('objExercise');
Session::erase('exe_id');
Session::erase('calculatedAnswerId');
Session::erase('calculatedAnswerInfo');
}
Display::display_footer();
} else {
@ -191,8 +190,6 @@ if ($origin != 'learnpath') {
if (api_is_allowed_to_session_edit()) {
Session::erase('objExercise');
Session::erase('exe_id');
Session::erase('calculatedAnswerId');
Session::erase('calculatedAnswerInfo');
}
// Record the results in the learning path, using the SCORM interface (API)

File diff suppressed because it is too large Load Diff

@ -283,9 +283,7 @@ switch ($action) {
$attempt_list = array();
// First time here we create an attempt (getting the exe_id).
if (empty($exercise_stat_info)) {
} else {
if (!empty($exercise_stat_info)) {
// We know the user we get the exe_id.
$exe_id = $exercise_stat_info['exe_id'];
$total_score = $exercise_stat_info['exe_result'];
@ -325,10 +323,10 @@ switch ($action) {
error_log("exe_id is empty");
}
exit;
} else {
$_SESSION['exe_id'] = $exe_id;
}
$_SESSION['exe_id'] = $exe_id;
// Getting the total weight if the request is simple
$total_weight = 0;
@ -351,7 +349,8 @@ switch ($action) {
continue;
}
$my_choice = isset($choice[$my_question_id]) ? $choice[$my_question_id] : null;
$my_choice = isset($choice[$my_question_id]) ?
$choice[$my_question_id] : null;
if ($debug) {
error_log("my_choice = ".print_r($my_choice, 1)."");
@ -361,7 +360,7 @@ switch ($action) {
$objQuestionTmp = Question::read($my_question_id, $course_id);
// Getting free choice data.
if ($objQuestionTmp->type == FREE_ANSWER && $type == 'all') {
if ($objQuestionTmp->type == FREE_ANSWER && $type == 'all') {
$my_choice = isset($_REQUEST['free_choice'][$my_question_id]) && !empty($_REQUEST['free_choice'][$my_question_id]) ? $_REQUEST['free_choice'][$my_question_id]: null;
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save