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. 52
      main/exercice/exercise.class.php
  3. 5
      main/exercice/exercise_result.php
  4. 290
      main/exercice/exercise_show.php
  5. 11
      main/inc/ajax/exercise.ajax.php
  6. 178
      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;
@ -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], ' / ');
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)

@ -1,8 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Shows the exercise results
*
@ -14,6 +12,8 @@ use ChamiloSession as Session;
*
*/
use ChamiloSession as Session;
require_once '../inc/global.inc.php';
$debug = false;
if (empty($origin)) {
@ -33,18 +33,40 @@ $TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISE
$TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
// General parameters passed via POST/GET
if ($debug) { error_log('Entered exercise_result.php: '.print_r($_POST,1)); }
if (empty($formSent)) { $formSent = isset($_REQUEST['formSent']) ? $_REQUEST['formSent'] : null; }
if (empty($exerciseResult)) { $exerciseResult = isset($_SESSION['exerciseResult']) ? $_SESSION['exerciseResult'] : null; }
if (empty($questionId)) { $questionId = isset($_REQUEST['questionId']) ? $_REQUEST['questionId'] : null;}
if (empty($choice)) { $choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null;}
if (empty($questionNum)) { $questionNum = isset($_REQUEST['num']) ? $_REQUEST['num'] : null;}
if (empty($nbrQuestions)) { $nbrQuestions = isset($_REQUEST['nbrQuestions']) ? $_REQUEST['nbrQuestions'] : null;}
if (empty($questionList)) { $questionList = isset($_SESSION['questionList']) ? $_SESSION['questionList'] : null;}
if (empty($objExercise)) { $objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : null;}
if (empty($exeId)) { $exeId = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;}
if (empty($action)) { $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;}
if ($debug) {
error_log('Entered exercise_result.php: ' . print_r($_POST, 1));
}
if (empty($formSent)) {
$formSent = isset($_REQUEST['formSent']) ? $_REQUEST['formSent'] : null;
}
if (empty($exerciseResult)) {
$exerciseResult = isset($_SESSION['exerciseResult']) ? $_SESSION['exerciseResult'] : null;
}
if (empty($questionId)) {
$questionId = isset($_REQUEST['questionId']) ? $_REQUEST['questionId'] : null;
}
if (empty($choice)) {
$choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null;
}
if (empty($questionNum)) {
$questionNum = isset($_REQUEST['num']) ? $_REQUEST['num'] : null;
}
if (empty($nbrQuestions)) {
$nbrQuestions = isset($_REQUEST['nbrQuestions']) ? $_REQUEST['nbrQuestions'] : null;
}
if (empty($questionList)) {
$questionList = isset($_SESSION['questionList']) ? $_SESSION['questionList'] : null;
}
if (empty($objExercise)) {
$objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : null;
}
if (empty($exeId)) {
$exeId = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
}
if (empty($action)) {
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
}
$id = intval($_REQUEST['id']); //exe id
@ -322,6 +344,7 @@ foreach ($questionList as $questionId) {
$counter = 1;
$exercise_content = null;
$category_list = array();
$useAdvancedEditor = true;
if (!empty($maxEditors) && count($questionList) > $maxEditors) {
@ -329,7 +352,6 @@ if (!empty($maxEditors) && count($questionList) > $maxEditors) {
}
foreach ($questionList as $questionId) {
$choice = $exerciseResult[$questionId];
// destruction of the Question object
unset($objQuestionTmp);
@ -342,26 +364,38 @@ foreach ($questionList as $questionId) {
// Start buffer
ob_start();
// Use switch
if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
$question_result = $objExercise->manage_answer(
$id,
$questionId,
$choice,
'exercise_show',
array(),
false,
true,
$show_results,
$objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
if ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
$choice = array();
}
switch ($answerType) {
case MULTIPLE_ANSWER_COMBINATION:
//no break
case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
//no break
case UNIQUE_ANSWER:
//no break;
case UNIQUE_ANSWER_NO_OPTION:
//no break
case MULTIPLE_ANSWER:
//no break
case MULTIPLE_ANSWER_TRUE_FALSE:
//no break
case FILL_IN_BLANKS:
//no break
case CALCULATED_ANSWER:
//no break
case GLOBAL_MULTIPLE_ANSWER:
//no break
case FREE_ANSWER:
//no break
case ORAL_EXPRESSION:
//no break
case MATCHING:
//no break
case DRAGGABLE:
//no break
case MATCHING_DRAGGABLE:
$question_result = $objExercise->manage_answer(
$id,
$questionId,
@ -377,120 +411,8 @@ foreach ($questionList as $questionId) {
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
$question_result = $objExercise->manage_answer(
$id,
$questionId,
$choice,
'exercise_show',
array(),
false,
true,
$show_results,
$objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
echo '</table>';
} elseif ($answerType == FILL_IN_BLANKS) {
$question_result = $objExercise->manage_answer(
$id,
$questionId,
$choice,
'exercise_show',
array(),
false,
true,
$show_results,
$objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == CALCULATED_ANSWER) {
$question_result = $objExercise->manage_answer(
$id,
$questionId,
$choice,
'exercise_show',
array(),
false,
true,
$show_results,
$objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == GLOBAL_MULTIPLE_ANSWER) {
$question_result = $objExercise->manage_answer(
$id,
$questionId,
$choice,
'exercise_show',
array(),
false,
true,
$show_results,
$objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == FREE_ANSWER) {
$question_result = $objExercise->manage_answer(
$id,
$questionId,
$choice,
'exercise_show',
array(),
false,
true,
$show_results,
$objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == ORAL_EXPRESSION) {
$question_result = $objExercise->manage_answer(
$id,
$questionId,
$choice,
'exercise_show',
array(),
false,
true,
$show_results,
$objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) {
$question_result = $objExercise->manage_answer(
$id,
$questionId,
$choice,
'exercise_show',
array(),
false,
true,
$show_results,
$objExercise->selectPropagateNeg(),
[],
$showTotalScoreAndUserChoices
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == HOT_SPOT) {
break;
case HOT_SPOT:
if ($show_results || $showTotalScoreAndUserChoices) {
echo '<table width="500" border="0"><tr>
<td valign="top" align="center" style="padding-left:0px;" >
@ -536,8 +458,8 @@ foreach ($questionList as $questionId) {
<br>
";
}
} else if($answerType == HOT_SPOT_DELINEATION) {
break;
case HOT_SPOT_DELINEATION:
$question_result = $objExercise->manage_answer(
$id,
$questionId,
@ -665,8 +587,7 @@ foreach ($questionList as $questionId) {
}
//showing the score
$queryfree = "SELECT marks FROM ".$TBL_TRACK_ATTEMPT."
WHERE exe_id = ".intval($id)." and question_id= ".intval($questionId)."";
$queryfree = "select marks from " . $TBL_TRACK_ATTEMPT . " WHERE exe_id = " . intval($id) . " and question_id= " . intval($questionId) . "";
$resfree = Database::query($queryfree);
$questionScore = Database::result($resfree, 0, "marks");
$totalScore += $questionScore;
@ -693,12 +614,15 @@ foreach ($questionList as $questionId) {
</table>
";
}
break;
}
if ($show_results) {
if ($answerType != HOT_SPOT) {
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
echo '</table>';
}
if ($show_results && $answerType != HOT_SPOT) {
echo '</table>';
}
$comnt = null;
@ -731,13 +655,7 @@ foreach ($questionList as $questionId) {
}
}
echo '<br />';
echo Display::url(
$url_name,
'javascript://',
array(
'class' => 'btn btn-default',
'onclick' => "showfck('".$name."', '".$marksname."');")
);
echo Display::url($url_name, 'javascript://', array('class' => 'btn', 'onclick' => "showfck('" . $name . "', '" . $marksname . "');"));
echo '<br />';
echo '<div id="feedback_' . $name . '" style="width:100%">';
@ -865,7 +783,12 @@ foreach ($questionList as $questionId) {
$score = array();
if ($show_results) {
$score['result'] = get_lang('Score')." : ".ExerciseLib::show_score($my_total_score, $my_total_weight, false, false);
$score['result'] = get_lang('Score') . " : " . ExerciseLib::show_score(
$my_total_score,
$my_total_weight,
false,
false
);
$score['pass'] = $my_total_score >= $my_total_weight ? true : false;
$score['type'] = $answerType;
$score['score'] = $my_total_score;
@ -877,7 +800,9 @@ foreach ($questionList as $questionId) {
$i++;
$contents = ob_get_clean();
$question_content = '<div class="question_row">';
if ($show_results) {
//Shows question title an description
$question_content .= $objQuestionTmp->return_header(null, $counter, $score);
@ -930,20 +855,42 @@ if ($isFeedbackAllowed) {
if ($isFeedbackAllowed) {
if (in_array($origin, array('tracking_course', 'user_course', 'correct_exercise_in_lp'))) {
echo '<form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">';
$formUrl = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidreq() . '&';
$formUrl .= http_build_query([
'exerciseId' => $exercise_id,
'filter' => 2,
'comments' => 'update',
'exeid' => $id,
'origin' => $origin,
'details' => 'true',
'course' => Security::remove_XSS($_GET['cidReq'])
]);
$formUrl .= $fromlink;
echo '<form name="myform" id="myform" action="' . $formUrl . '" method="post">';
echo '<input type = "hidden" name="lp_item_id" value="' . $learnpath_id . '">';
echo '<input type = "hidden" name="lp_item_view_id" value="' . $lp_item_view_id . '">';
echo '<input type = "hidden" name="student_id" value="' . $student_id . '">';
echo '<input type = "hidden" name="total_score" value="' . $totalScore . '"> ';
echo '<input type = "hidden" name="my_exe_exo_id" value="' . $exercise_id . '"> ';
} else {
echo ' <form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=1&comments=update&exeid='.$id.'" method="post">';
$formUrl = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidreq() . '&';
$formUrl .= http_build_query([
'exerciseId' => $exercise_id,
'filter' => 1,
'comments' => 'update',
'exeid' => $id
]);
echo ' <form name="myform" id="myform" action="' . $formUrl . '" method="post">';
}
if ($origin != 'learnpath' && $origin != 'student_progress') {
echo '<label><input type= "checkbox" name="send_notification"> ' . get_lang('SendEmail') . '</label>';
?>
<br/>
<button type="submit" class="btn btn-primary" value="<?php echo get_lang('Ok'); ?>" onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');">
<button type="submit" class="btn btn-primary" value="<?php echo get_lang('Ok'); ?>"
onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');">
<?php echo get_lang('CorrectTest'); ?>
</button>
</form>
@ -958,7 +905,9 @@ if ($origin =='student_progress') { ?>
<?php
} else if ($origin == 'myprogress') {
?>
<button type="button" class="save" onclick="top.location.href='../auth/my_progress.php?course=<?php echo api_get_course_id()?>'" value="<?php echo get_lang('Finish'); ?>" >
<button type="button" class="save"
onclick="top.location.href='../auth/my_progress.php?course=<?php echo api_get_course_id() ?>'"
value="<?php echo get_lang('Finish'); ?>">
<?php echo get_lang('Finish'); ?>
</button>
<?php
@ -970,7 +919,14 @@ if ($origin != 'learnpath') {
} else {
if (!isset($_GET['fb_type'])) {
$lp_mode = $_SESSION['lp_mode'];
$url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type;
$url = '../newscorm/lp_controller.php?' . api_get_cidreq() . '&';
$url .= http_build_url([
'action' => 'view',
'lp_id' => $learnpath_id,
'lp_item_id' => $learnpath_item_id,
'exeId' => $exeId,
'fb_type' => $feedback_type
]);
$href = ($lp_mode == 'fullscreen') ? ' window.opener.location.href="' . $url . '" ' : ' top.location.href="' . $url . '" ';
echo '<script type="text/javascript">' . $href . '</script>';
// Record the results in the learning path, using the SCORM interface (API)

@ -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)."");

@ -16,7 +16,7 @@ class ExerciseLib
/**
* Shows a question
*
* @param int $questionId question id
* @param int $questionId $questionId question id
* @param bool $only_questions if true only show the questions, no exercise title
* @param bool $origin i.e = learnpath
* @param string $current_item current item from the list of questions
@ -24,9 +24,10 @@ class ExerciseLib
* @param bool $freeze
* @param array $user_choice
* @param bool $show_comment
* @param bool $exercise_feedback
* @param null $exercise_feedback
* @param bool $show_answers
* */
* @return bool|int
*/
public static function showQuestion(
$questionId,
$only_questions = false,
@ -38,7 +39,8 @@ class ExerciseLib
$show_comment = false,
$exercise_feedback = null,
$show_answers = false
) {
)
{
$course_id = api_get_course_int_id();
// Change false to true in the following line to enable answer hinting
$debug_mark_answer = $show_answers;
@ -89,13 +91,6 @@ class ExerciseLib
$objAnswerTmp = new Answer($questionId);
$nbrAnswers = $objAnswerTmp->selectNbrAnswers();
if ($answerType == FREE_ANSWER ||
$answerType == ORAL_EXPRESSION ||
$answerType == CALCULATED_ANSWER
) {
$nbrAnswers = 1;
}
$quiz_question_options = Question::readQuestionOption(
$questionId,
$course_id
@ -277,9 +272,14 @@ class ExerciseLib
$attributes = array();
// Unique answer
if (in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION, UNIQUE_ANSWER_IMAGE])) {
switch ($answerType) {
case UNIQUE_ANSWER:
//no break
case UNIQUE_ANSWER_NO_OPTION:
//no break
case UNIQUE_ANSWER_IMAGE:
$input_id = 'choice-' . $questionId . '-' . $answerId;
if (isset($user_choice[0]['answer']) && $user_choice[0]['answer'] == $numAnswer) {
$attributes = array(
'id' => $input_id,
@ -354,12 +354,12 @@ class ExerciseLib
} else {
$s .= $answer_input;
}
} elseif (
$answerType == MULTIPLE_ANSWER ||
$answerType == MULTIPLE_ANSWER_TRUE_FALSE ||
$answerType == GLOBAL_MULTIPLE_ANSWER
) {
break;
case MULTIPLE_ANSWER:
//no break
case MULTIPLE_ANSWER_TRUE_FALSE:
//no break
case GLOBAL_MULTIPLE_ANSWER:
$input_id = 'choice-' . $questionId . '-' . $answerId;
$answer = Security::remove_XSS($answer, STUDENT);
@ -455,7 +455,8 @@ class ExerciseLib
}
$s .= '</tr>';
}
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
break;
case MULTIPLE_ANSWER_COMBINATION:
// multiple answers
$input_id = 'choice-' . $questionId . '-' . $answerId;
@ -500,8 +501,8 @@ class ExerciseLib
} else {
$s .= $answer_input;
}
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
break;
case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
$s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />';
$my_choice = array();
@ -550,7 +551,8 @@ class ExerciseLib
$s .= '</td>';
}
$s .= '</tr>';
} elseif ($answerType == FILL_IN_BLANKS) {
break;
case FILL_IN_BLANKS:
// display the question, with field empty, for student to fill it,
// or filled to display the answer in the Question preview of the exercice/admin.php page
$displayForStudent = true;
@ -618,9 +620,8 @@ class ExerciseLib
$answer .= $listAnswerInformations["commonwords"][$i];
}
$s .= $answer;
} elseif ($answerType == CALCULATED_ANSWER) {
break;
case CALCULATED_ANSWER:
/*
* In the CALCULATED_ANSWER test
* you mustn't have [ and ] in the textarea
@ -629,20 +630,17 @@ class ExerciseLib
* the text to find mustn't contains HTML tags
* the text to find mustn't contains char "
*/
global $exerciseId;
if ($origin !== null) {
global $exe_id;
$trackAttempts = Database::get_main_table(
TABLE_STATISTIC_TRACK_E_ATTEMPT
);
$sql = 'SELECT answer FROM ' . $trackAttempts . '
WHERE exe_id=' . $exerciseId . ' AND question_id=' . $questionId;
WHERE exe_id=' . $exe_id . ' AND question_id=' . $questionId;
$rsLastAttempt = Database::query($sql);
$rowLastAttempt = Database::fetch_array($rsLastAttempt);
$answer = $rowLastAttempt['answer'];
$calculatedAnswerId = Session::read('calculatedAnswerId');
$calculatedAnswerInfo = Session::read('calculatedAnswerInfo');
if (empty($answer)) {
if (empty($calculatedAnswerId)) {
$_SESSION['calculatedAnswerId'][$questionId] = mt_rand(
1,
$nbrAnswers
@ -650,14 +648,6 @@ class ExerciseLib
$answer = $objAnswerTmp->selectAnswer(
$_SESSION['calculatedAnswerId'][$questionId]
);
Session::write('calculatedAnswerInfo', [$questionId => $answer]);
} else {
$calculatedAnswerInfo = Session::read('calculatedAnswerInfo');
if (isset($calculatedAnswerInfo[$questionId])) {
$answer = $calculatedAnswerInfo[$questionId];
}
}
}
@ -669,7 +659,6 @@ class ExerciseLib
$correctAnswerList
);
// get student answer to display it if student go back to previous calculated answer question in a test
if (isset($user_choice[0]['answer'])) {
api_preg_match_all(
@ -778,7 +767,8 @@ class ExerciseLib
} else {
$s .= $answer;
}
} elseif ($answerType == MATCHING) {
break;
case MATCHING:
// matching type, showing suggestions and answers
// TODO: replace $answerId by $numAnswer
@ -839,7 +829,8 @@ class ExerciseLib
} // end if()
$matching_correct_answer++;
}
} elseif ($answerType == DRAGGABLE) {
break;
case DRAGGABLE:
if ($answerCorrect != 0) {
$parsed_answer = $answer;
/*$lines_count = '';
@ -931,7 +922,8 @@ JAVASCRIPT;
$s .= '</li>';
}
} elseif ($answerType == MATCHING_DRAGGABLE) {
break;
case MATCHING_DRAGGABLE:
if ($answerId == 1) {
echo $objAnswerTmp->getJs();
}
@ -1046,6 +1038,7 @@ HTML;
}
$matching_correct_answer++;
}
break;
}
} // end for()
@ -1108,11 +1101,11 @@ HTML;
// destruction of the Question object
unset($objQuestionTmp);
if ($origin != 'export') {
echo $s;
} else {
if ($origin == 'export') {
return $s;
}
echo $s;
} elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
global $exerciseId, $exe_id;
// Question is a HOT_SPOT
@ -1216,7 +1209,6 @@ HTML;
HOTSPOT;
}
$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
$relPath = api_get_path(REL_PATH);
$s .= "
<div class=\"col-sm-8 col-md-9\">
@ -1284,7 +1276,8 @@ HOTSPOT;
$exercise_id,
$lp_id = 0,
$lp_item_id = 0
) {
)
{
$course_id = api_get_course_int_id();
$exercise_id = intval($exercise_id);
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
@ -1324,7 +1317,8 @@ HOTSPOT;
$exercise_id,
$lp_id = 0,
$lp_item_id = 0
) {
)
{
$current_expired_time_key = self::get_time_control_key(
$exercise_id,
$lp_id,
@ -1357,7 +1351,8 @@ HOTSPOT;
$exercise_id,
$lp_id = 0,
$lp_item_id = 0
) {
)
{
$return_value = 0;
$time_control_key = self::get_time_control_key(
$exercise_id,
@ -1423,7 +1418,8 @@ HOTSPOT;
$in_hotpot_path,
$in_get_count = false,
$where_condition = null
) {
)
{
$courseId = api_get_course_int_id();
/* by default in_column = 1 If parameters given,
it is the name of the column witch is the bdd field name*/
@ -1502,7 +1498,8 @@ HOTSPOT;
$userId,
$courseId,
$sessionId
) {
)
{
$table = Database:: get_main_table(
TABLE_STATISTIC_TRACK_E_HOTPOTATOES
);
@ -1546,7 +1543,8 @@ HOTSPOT;
$exercise_id,
$extra_where_conditions = null,
$get_count = false
) {
)
{
//@todo replace all this globals
global $documentPath, $filter;
@ -1851,8 +1849,7 @@ HOTSPOT;
if ($lp_obj) {
$url = api_get_path(
WEB_CODE_PATH
) . 'newscorm/lp_controller.php?' . api_get_cidreq(
) . '&action=view&lp_id=' . $results[$i]['orig_lp_id'];
) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&action=view&lp_id=' . $results[$i]['orig_lp_id'];
$lp_name = Display::url(
$lp_obj['lp_name'],
$url,
@ -1926,8 +1923,7 @@ HOTSPOT;
}
}
if ($revised) {
$actions .= "<a href='exercise_show.php?" . api_get_cidreq(
) . "&action=edit&id=$id'>" .
$actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=edit&id=$id'>" .
Display:: return_icon(
'edit.png',
get_lang('Edit'),
@ -1936,8 +1932,7 @@ HOTSPOT;
);
$actions .= '&nbsp;';
} else {
$actions .= "<a href='exercise_show.php?" . api_get_cidreq(
) . "&action=qualify&id=$id'>" .
$actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=qualify&id=$id'>" .
Display:: return_icon(
'quiz.gif',
get_lang('Qualify')
@ -1947,8 +1942,7 @@ HOTSPOT;
$actions .= "</a>";
if ($filter == 2) {
$actions .= ' <a href="exercise_history.php?' . api_get_cidreq(
) . '&exe_id=' . $id . '">' .
$actions .= ' <a href="exercise_history.php?' . api_get_cidreq() . '&exe_id=' . $id . '">' .
Display:: return_icon(
'history.gif',
get_lang('ViewHistoryChange')
@ -1956,8 +1950,7 @@ HOTSPOT;
}
//Admin can always delete the attempt
if (($locked == false || api_is_platform_admin(
)) && !api_is_student_boss()
if (($locked == false || api_is_platform_admin()) && !api_is_student_boss()
) {
$ip = TrackingUserLog::get_ip_from_user_event(
$results[$i]['exe_user_id'],
@ -1988,8 +1981,7 @@ HOTSPOT;
} else {
$attempt_url = api_get_path(
WEB_CODE_PATH
) . 'exercice/result.php?' . api_get_cidreq(
) . '&id=' . $results[$i]['exe_id'] . '&id_session=' . $sessionId;
) . 'exercice/result.php?' . api_get_cidreq() . '&id=' . $results[$i]['exe_id'] . '&id_session=' . $sessionId;
$attempt_link = Display::url(
get_lang('Show'),
$attempt_url,
@ -2092,7 +2084,8 @@ HOTSPOT;
$show_percentage = true,
$use_platform_settings = true,
$show_only_percentage = false
) {
)
{
if (is_null($score) && is_null($weight)) {
return '-';
}
@ -2271,7 +2264,8 @@ HOTSPOT;
$search = '',
$search_all_sessions = false,
$active = 2
) {
)
{
$course_id = api_get_course_int_id();
if (!empty($course_info) && !empty($course_info['real_id'])) {
@ -2391,7 +2385,8 @@ HOTSPOT;
$session_id = 0,
$course_id = 0,
$only_active_exercises = true
) {
)
{
$TBL_EXERCISES = Database:: get_course_table(TABLE_QUIZ_TEST);
if ($only_active_exercises) {
@ -2453,7 +2448,8 @@ HOTSPOT;
$session_id = 0,
$user_list = array(),
$return_string = true
) {
)
{
//No score given we return
if (is_null($my_score)) {
return '-';
@ -2541,7 +2537,8 @@ HOTSPOT;
$courseId,
$session_id = 0,
$return_string = true
) {
)
{
if (empty($session_id)) {
$session_id = 0;
}
@ -2650,7 +2647,8 @@ HOTSPOT;
$exercise_id,
$courseId,
$session_id
) {
)
{
$user_results = Event::get_all_exercise_results(
$exercise_id,
$courseId,
@ -2750,7 +2748,8 @@ HOTSPOT;
$user_id,
$courseId,
$session_id
) {
)
{
$user_results = Event::get_all_exercise_results_by_user(
$user_id,
$courseId,
@ -2787,7 +2786,8 @@ HOTSPOT;
$courseId,
$session_id,
$user_count
) {
)
{
$user_results = Event::get_best_exercise_results_by_user(
$exercise_id,
$courseId,
@ -2851,7 +2851,8 @@ HOTSPOT;
$exercise_id,
$course_code,
$session_id
) {
)
{
$track_exercises = Database::get_main_table(
TABLE_STATISTIC_TRACK_E_EXERCISES
);
@ -2899,7 +2900,8 @@ HOTSPOT;
public static function getNumberStudentsFillBlanksAnwserCount(
$question_id,
$exercise_id
) {
)
{
$listStudentsId = [];
$listAllStudentInfo = CourseManager::get_student_list_from_course_code(
api_get_course_id(),
@ -2950,7 +2952,8 @@ HOTSPOT;
$course_code,
$session_id,
$questionType = ''
) {
)
{
$track_exercises = Database::get_main_table(
TABLE_STATISTIC_TRACK_E_EXERCISES
);
@ -3044,7 +3047,8 @@ HOTSPOT;
$exercise_id,
$course_code,
$session_id
) {
)
{
$track_exercises = Database::get_main_table(
TABLE_STATISTIC_TRACK_E_EXERCISES
);
@ -3122,7 +3126,8 @@ HOTSPOT;
$question_type = null,
$correct_answer = null,
$current_answer = null
) {
)
{
$track_exercises = Database::get_main_table(
TABLE_STATISTIC_TRACK_E_EXERCISES
);
@ -3361,7 +3366,8 @@ HOTSPOT;
$exercise_id,
$course_code,
$session_id
) {
)
{
$track_exercises = Database::get_main_table(
TABLE_STATISTIC_TRACK_E_EXERCISES
);
@ -3455,7 +3461,8 @@ HOTSPOT;
$objExercise,
$exe_id,
$save_user_result = false
) {
)
{
global $origin;
// Getting attempt info
@ -3641,8 +3648,7 @@ HOTSPOT;
$category_list['none']['total'] += $my_total_weight;
}
if ($objExercise->selectPropagateNeg(
) == 0 && $my_total_score < 0
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0
) {
$my_total_score = 0;
}
@ -3807,7 +3813,8 @@ HOTSPOT;
$score,
$weight,
$check_pass_percentage = false
) {
)
{
$ribbon = '<div class="title-score">';
if ($check_pass_percentage) {
$is_success = self::is_success_exercise_result(
@ -3819,7 +3826,8 @@ HOTSPOT;
$ribbon_total_success_or_error = "";
if (self::is_pass_pourcentage_enabled(
$objExercise->selectPassPercentage()
)) {
)
) {
if ($is_success) {
$ribbon_total_success_or_error = ' ribbon-total-success';
} else {

Loading…
Cancel
Save