'; //margin top -10
+ }
+
+ $html = Display::span($html, array('class'=>'exercise_button'));
return $html;
+
}
/**
@@ -1779,7 +1792,7 @@ class Exercise {
if ($debug) error_log('manage_answer $from_database '.$from_database);
if ($debug) error_log('manage_answer $show_result '.$show_result);
if ($debug) error_log('manage_answer $propagate_neg '.$propagate_neg);
- if ($debug) error_log('manage_answer $$hotspot_delineation_result '.print_r($hotspot_delineation_result, 1));
+ if ($debug) error_log('manage_answer $hotspot_delineation_result '.print_r($hotspot_delineation_result, 1));
$extra_data = array();
$html = '';
@@ -1894,8 +1907,7 @@ class Exercise {
$studentChoice =$choice[$numAnswer];
} else {
$studentChoice =$choice[$numAnswer];
- }
-
+ }
if (!empty($studentChoice)) {
if ($studentChoice == $answerCorrect ) {
@@ -2242,12 +2254,14 @@ class Exercise {
}
// for hotspot with no order
case HOT_SPOT :
+
if ($from_database) {
+
if ($show_result) {
$TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$query = "SELECT hotspot_correct FROM ".$TBL_TRACK_HOTSPOT." where hotspot_exe_id = '".$exeId."' and hotspot_question_id= '".$questionId."' AND hotspot_answer_id='".Database::escape_string($answerId)."'";
- $resq=Database::query($query);
- $studentChoice = Database::result($resq,0,"hotspot_correct");
+ $resq = Database::query($query);
+ $studentChoice = Database::result($resq,0,"hotspot_correct");
}
} else {
$studentChoice = $choice[$answerId];
@@ -2318,7 +2332,7 @@ class Exercise {
//display answers (if not matching type, or if the answer is correct)
if ($answerType != MATCHING || $answerCorrect) {
if (in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION, MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION))) {
- if ($origin!='learnpath') {
+ if ($origin != 'learnpath') {
ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,0,0,0);
}
} elseif($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
@@ -2743,7 +2757,7 @@ class Exercise {
'overlap_color' => $overlap_color, 'missing_color'=>$missing_color, 'excess_color'=> $excess_color,
'threadhold1' => $threadhold1, 'threadhold2'=>$threadhold2, 'threadhold3'=> $threadhold3,
);
-
+
if ($from == 'exercise_result') {
// if answer is hotspot. To the difference of exercise_show.php, we use the results from the session (from_db=0)
// TODO Change this, because it is wrong to show the user some results that haven't been stored in the database yet
@@ -2869,16 +2883,19 @@ class Exercise {
if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER) {
// We made an extra table for the answers
+
if ($show_result) {
+
if ($origin != 'learnpath') {
echo '';
echo '
';
echo ''.get_lang('HotSpot').'
';
- echo '
-
+
+ echo '';
+ echo '
';
}
@@ -2908,7 +2925,7 @@ class Exercise {
// For all in one page exercises, the results will be
// stored by exercise_results.php (using the session)
- if ($saved_results) {
+ if ($saved_results) {
if (empty($choice)) {
$choice = 0;
}
@@ -2956,14 +2973,14 @@ class Exercise {
$answer = $choice;
exercise_attempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
// } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
- } elseif ($answerType == HOT_SPOT) {
+ } elseif ($answerType == HOT_SPOT) {
exercise_attempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
if (isset($exerciseResultCoordinates[$questionId]) && !empty($exerciseResultCoordinates[$questionId])) {
- foreach($exerciseResultCoordinates[$questionId] as $idx => $val) {
+ foreach($exerciseResultCoordinates[$questionId] as $idx => $val) {
exercise_attempt_hotspot($exeId,$quesId,$idx,$choice[$idx],$val,$this->id);
}
}
- } else {
+ } else {
exercise_attempt($questionScore, $answer, $quesId, $exeId, 0,$this->id);
}
}
@@ -3291,5 +3308,113 @@ class Exercise {
return $is_visible;
}
+
+ function save_attempt() {
+
+ }
+
+ function added_in_lp() {
+ $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
+ $sql = "SELECT max_score FROM $TBL_LP_ITEM WHERE item_type = '".TOOL_QUIZ."' AND path = '".$this->id."'";
+ $result = Database::query($sql);
+ if (Database::num_rows($result) > 0) {
+ return true;
+ }
+ return false;
+ }
+
+ function get_validated_question_list() {
+ return ($this->isRandom() ? $this->selectRandomList() : $this->selectQuestionList());
+ }
+
+ public function get_stat_track_exercise_info_by_exe_id($exe_id) {
+ $track_exercises = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+ $exe_id = intval($exe_id);
+ $sql_track = "SELECT * FROM $track_exercises WHERE exe_id = $exe_id ";
+ $result = Database::query($sql_track);
+ $new_array = array();
+ if (Database::num_rows($result) > 0 ) {
+ $new_array = Database::fetch_array($result, 'ASSOC');
+ }
+ return $new_array;
+ }
+
+ public function edit_question_to_remind($exe_id, $question_id, $action = 'add') {
+ $exercise_info = self::get_stat_track_exercise_info_by_exe_id($exe_id);
+ $question_id = intval($question_id);
+ $exe_id = intval($exe_id);
+ $track_exercises = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+ if ($exercise_info) {
+
+ if (empty($exercise_info['questions_to_check'])) {
+ if ($action == 'add') {
+ $sql = "UPDATE $track_exercises SET questions_to_check = '$question_id' WHERE exe_id = $exe_id ";
+ $result = Database::query($sql);
+ }
+ } else {
+ $remind_list = explode(',',$exercise_info['questions_to_check']);
+
+ $remind_list_string = '';
+ if ($action == 'add') {
+ if (!in_array($question_id, $remind_list)) {
+ $remind_list[] = $question_id;
+ if (!empty($remind_list)) {
+ sort($remind_list);
+ array_filter($remind_list);
+ }
+ $remind_list_string = implode(',', $remind_list);
+ }
+ } elseif ($action == 'delete') {
+ if (!empty($remind_list)) {
+ if (in_array($question_id, $remind_list)) {
+ $remind_list = array_flip($remind_list);
+ unset($remind_list[$question_id]);
+ $remind_list = array_flip($remind_list);
+
+ if (!empty($remind_list)) {
+ sort($remind_list);
+ array_filter($remind_list);
+ $remind_list_string = implode(',', $remind_list);
+ }
+ }
+ }
+ }
+ $remind_list_string = Database::escape_string($remind_list_string);
+ $sql = "UPDATE $track_exercises SET questions_to_check = '$remind_list_string' WHERE exe_id = $exe_id ";
+ $result = Database::query($sql);
+ }
+ }
+ }
+
+ public function fill_in_blank_answer_to_string($answer) {
+
+ api_preg_match_all('/\[[^]]+\]/', $answer, $teacher_answer_list);
+
+
+ $result = '';
+
+ if (!empty($teacher_answer_list)) {
+ $teacher_answer_list = $teacher_answer_list[0];
+
+
+ $i = 0;
+ foreach($teacher_answer_list as $teacher_item) {
+ $value = null;
+ //Cleaning student answer list
+ $value = strip_tags($teacher_item);
+ $value = api_substr($value,1, api_strlen($value)-2);
+ $value = explode('/', $value);
+ if (!empty($value[0])) {
+ $value = trim($value[0]);
+ $value = str_replace(' ', '', $value);
+ $result .= $value;
+ }
+ }
+ }
+
+ return $result;
+ }
+
+
}
endif;
\ No newline at end of file
diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php
index a8e627539b..beff5e89d0 100755
--- a/main/exercice/exercise.lib.php
+++ b/main/exercice/exercise.lib.php
@@ -24,11 +24,12 @@ require_once dirname(__FILE__).'/../inc/lib/fckeditor/fckeditor.php';
* @param int current item from the list of questions
* @param int number of total questions
* */
-function showQuestion($questionId, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false) {
+function showQuestion($questionId, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false, $user_choice = array()) {
- $s = '';
// Text direction for the current language
$is_ltr_text_direction = api_get_text_direction() != 'rtl';
+
+ $remind_question = 1;
// Change false to true in the following line to enable answer hinting.
$debug_mark_answer = api_is_allowed_to_edit() && false;
@@ -41,56 +42,35 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
$answerType = $objQuestionTmp->selectType();
$pictureName = $objQuestionTmp->selectPicture();
-
+
+ $html = '';
if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) {
// Question is not a hotspot
if (!$only_questions) {
-
- $questionName = $objQuestionTmp->selectTitle();
$questionDescription = $objQuestionTmp->selectDescription();
- $questionName = text_filter($questionName);
-
- if ($show_title) {
- $s='
'.get_lang('Question').' ';
- $s.=$current_item;
- //@todo I need the get the feedback type
- //if($answerType != 1)
- //$s.=' / '.$total_item;
- echo $s;
- echo ' : ';
- echo $questionName.'
';
- } else {
+ } elseif ($answerType == MATCHING) {
// matching type, showing suggestions and answers
// TODO: replace $answerId by $numAnswer
+
if ($answerCorrect != 0) {
// only show elements to be answered (not the contents of
// the select boxes, who are corrrect = 0)
- $s .= '
';
- //middle part (matches selects)
+ //middle part (matches selects)
+
$s .= '
-
';
+ $s .= '';
//print_r($select_items);
//right part (answers)
$s.='
';
@@ -382,7 +419,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
// if it remains answers to shown at the right side
while (isset($select_items[$lines_count])) {
$s .= '