diff --git a/main/css/base.css b/main/css/base.css
index 6380af86ee..90b0765c12 100644
--- a/main/css/base.css
+++ b/main/css/base.css
@@ -3416,7 +3416,7 @@ div.admin_section h4 {
display: block;
font-size: 100%;
line-height: 150%;
- margin: -27px 0 0 23px;
+ margin: -16px 0 0 23px;
padding: 0 0 5px;
width: 88%;
}
@@ -3796,4 +3796,59 @@ form div.error input, form div.error textarea {
.invisible h2 {
color: #999;
-}
\ No newline at end of file
+}
+
+
+
+/************************************************************************************
+REFLECTION
+*************************************************************************************/
+
+
+.image-wrap {
+ margin-right: 10px;
+ position: relative;
+ display: inline-block;
+ width: 64px;
+ height: 64px;'
+}
+.box-image {
+ margin: 0 0 50px;
+ border-top: solid 1px #ccc;
+}
+
+
+
+.reflection .image-wrap {
+ -webkit-box-shadow: inset 0 0 1px rgba(0,0,0,.5), inset 0 2px 0 rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.5);
+ -moz-box-shadow: inset 0 0 1px rgba(0,0,0,.5), inset 0 2px 0 rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.5);
+ box-shadow: inset 0 0 1px rgba(0,0,0,.5), inset 0 2px 0 rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.5);
+ -webkit-transition: .5s;
+ -moz-transition: .5s;
+ transition: .5s;
+ -webkit-border-radius: 20px;
+ -moz-border-radius: 20px;
+ border-radius: 20px;
+}
+.reflection .image-wrap:after {
+ position: absolute;
+ content: ' ';
+ width: 100%;
+ height: 30px;
+ bottom: -31px;
+ left: 0;
+ -webkit-border-top-left-radius: 20px;
+ -webkit-border-top-right-radius: 20px;
+ -moz-border-radius-topleft: 20px;
+ -moz-border-radius-topright: 20px;
+ border-top-left-radius: 20px;
+ border-top-right-radius: 20px;
+ background: -moz-linear-gradient(top, rgba(0,0,0,.3) 0%, rgba(255,255,255,0) 100%);
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,.3)), color-stop(100%,rgba(255,255,255,0)));
+ background: linear-gradient(top, rgba(0,0,0,.3) 0%,rgba(255,255,255,0) 100%);
+}
+.reflection .image-wrap:hover {
+ position: relative;
+ top: -8px;
+}
+
diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php
index 44941f1646..2e4de33930 100644
--- a/main/exercice/exercise.class.php
+++ b/main/exercice/exercise.class.php
@@ -47,6 +47,7 @@ class Exercise {
public $expired_time;
public $course;
public $propagate_neg;
+ public $review_answers; //
/**
@@ -70,12 +71,13 @@ class Exercise {
$this->results_disabled = 1;
$this->expired_time = '0000-00-00 00:00:00';
$this->propagate_neg = 0;
+ $this->review_answers = false;
if (!empty($course_id)) {
- $this->course_id = intval($course_id);
- $course_info = api_get_course_info_by_id($this->course_id);
+ $this->course_id = intval($course_id);
+ $course_info = api_get_course_info_by_id($this->course_id);
} else {
- $course_info = api_get_course_info();
+ $course_info = api_get_course_info();
}
$this->course = $course_info;
@@ -92,7 +94,6 @@ class Exercise {
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION,$this->course['db_name']);
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST,$this->course['db_name']);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION,$this->course['db_name']);
- #$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
$id = intval($id);
$sql = "SELECT * FROM $TBL_EXERCICES WHERE id = ".$id;
$result = Database::query($sql);
@@ -112,7 +113,9 @@ class Exercise {
$this->attempts = $object->max_attempt;
$this->feedbacktype = $object->feedback_type;
$this->propagate_neg = $object->propagate_neg;
-
+
+ $this->review_answers = (isset($object->review_answers) && $object->review_answers == 1) ? true : false;
+
if ($object->end_time != '0000-00-00 00:00:00') {
$this->end_time = api_get_local_time($object->end_time);
}
@@ -423,6 +426,9 @@ class Exercise {
function updatePropagateNegative($value) {
$this->propagate_neg = $value;
}
+ function updateReviewAnswers($value) {
+ $this->review_answers = (isset($value) && $value) ? true : false;
+ }
/**
* changes the exercise sound file
@@ -543,6 +549,8 @@ class Exercise {
$random_answers = $this->random_answers;
$active = $this->active;
$propagate_neg = $this->propagate_neg;
+ $review_answers = (isset($this->review_answers) && $this->review_answers) ? 1 : 0;
+
$session_id = api_get_session_id();
//If direct we do not show results
@@ -574,10 +582,11 @@ class Exercise {
max_attempt ='".Database::escape_string($attempts)."',
expired_time ='".Database::escape_string($expired_time)."',
propagate_neg ='".Database::escape_string($propagate_neg)."',
+ review_answers ='".Database::escape_string($review_answers)."',
results_disabled='".Database::escape_string($results_disabled)."'";
}
+
$sql .= " WHERE id='".Database::escape_string($id)."'";
-
Database::query($sql);
// update into the item_property table
@@ -588,7 +597,8 @@ class Exercise {
}
} else {
// creates a new exercise
- $sql="INSERT INTO $TBL_EXERCICES (c_id, start_time, end_time, title, description, sound, type, random, random_answers,active, results_disabled, max_attempt, feedback_type, expired_time, session_id)
+ $sql="INSERT INTO $TBL_EXERCICES (c_id, start_time, end_time, title, description, sound, type, random, random_answers,
+ active, results_disabled, max_attempt, feedback_type, expired_time, session_id, review_answers)
VALUES(
".api_get_course_int_id().",
'$start_time','$end_time',
@@ -603,10 +613,11 @@ class Exercise {
'".Database::escape_string($attempts)."',
'".Database::escape_string($feedbacktype)."',
'".Database::escape_string($expired_time)."',
- '".Database::escape_string($session_id)."'
+ '".Database::escape_string($session_id)."',
+ '".Database::escape_string($review_answers)."'
)";
Database::query($sql);
- $this->id=Database::insert_id();
+ $this->id = Database::insert_id();
// insert into the item_property table
api_item_property_update($_course, TOOL_QUIZ, $this->id,'QuizAdded',api_get_user_id());
@@ -883,7 +894,6 @@ class Exercise {
$form->add_html_editor('exerciseDescription', get_lang('langExerciseDescription'), false, false, $editor_config);
$form->addElement ('html','');
-
$form->addElement('html','
@@ -980,8 +990,6 @@ class Exercise {
}
}
-
-
$random = array();
$option=array();
$max = ($this->id > 0) ? $this->selectNbrQuestions() : 10 ;
@@ -1029,6 +1037,9 @@ class Exercise {
//$check_option=$this->selectType();
$diplay = 'block';
$form->addElement('checkbox', 'propagate_neg',get_lang('PropagateNegativeResults'),null);
+
+ $form->addElement('checkbox', 'review_answers',get_lang('ReviewAnswers'),null);
+
$form->addElement('html','
');
@@ -1112,6 +1123,9 @@ class Exercise {
$defaults['exerciseFeedbackType'] = $this->selectFeedbackType();
$defaults['results_disabled'] = $this->selectResultsDisabled();
$defaults['propagate_neg'] = $this->selectPropagateNeg();
+
+ $defaults['review_answers'] = $this->review_answers;
+
if (($this->start_time!='0000-00-00 00:00:00'))
$defaults['activate_start_date_check'] = 1;
@@ -1169,6 +1183,8 @@ class Exercise {
$this->updateResultsDisabled($form->getSubmitValue('results_disabled'));
$this->updateExpiredTime($form->getSubmitValue('enabletimercontroltotalminutes'));
$this->updatePropagateNegative($form->getSubmitValue('propagate_neg'));
+
+ $this->updateReviewAnswers($form->getSubmitValue('review_answers'));
if ($form->getSubmitValue('activate_start_date_check') == 1) {
$start_time = $form->getSubmitValue('start_time');
@@ -1429,19 +1445,25 @@ class Exercise {
$new_exercise_id = $exercise_obj->selectId();
$question_list = $exercise_obj->selectQuestionList();
-
- //Question creation
- foreach ($question_list as $old_question_id) {
- $old_question_obj = Question::read($old_question_id);
- $new_id = $old_question_obj->duplicate();
-
- $new_question_obj = Question::read($new_id);
-
- $new_question_obj->addToList($new_exercise_id);
- // This should be moved to the duplicate function
- $new_answer_obj = new Answer($old_question_id);
- $new_answer_obj->read();
- $new_answer_obj->duplicate($new_id);
+
+ if (!empty($question_list)) {
+ //Question creation
+
+ foreach ($question_list as $old_question_id) {
+ $old_question_obj = Question::read($old_question_id);
+ $new_id = $old_question_obj->duplicate();
+ if ($new_id) {
+ $new_question_obj = Question::read($new_id);
+
+ if (isset($new_question_obj) && $new_question_obj) {
+ $new_question_obj->addToList($new_exercise_id);
+ // This should be moved to the duplicate function
+ $new_answer_obj = new Answer($old_question_id);
+ $new_answer_obj->read();
+ $new_answer_obj->duplicate($new_id);
+ }
+ }
+ }
}
}
@@ -1563,11 +1585,16 @@ class Exercise {
//User
if (api_is_allowed_to_session_edit()) {
if ($this->type == ALL_ON_ONE_PAGE || $nbrQuestions == $questionNum) {
- $label = get_lang('ReviewQuestions');
- $class = 'accept';
+ if ($this->review_answers) {
+ $label = get_lang('ReviewQuestions');
+ $class = 'a_button blue medium';
+ } else {
+ $label = get_lang('ValidateAnswers');
+ $class = 'a_button green';
+ }
} else {
$label = get_lang('NextQuestion');
- $class = 'next';
+ $class = 'a_button blue medium';
}
if ($this->type == ONE_PER_PAGE) {
@@ -1577,18 +1604,24 @@ class Exercise {
}
//Next question
- $all_button .= '
'.$label.'';
-
-
+ $all_button .= '
'.$label.'';
//$all_button .= '
';
$all_button .= '
';
$html .= $all_button;
- } else {
- $all_button = '
'.get_lang('ReviewQuestions').'';
+ } else {
+ if ($this->review_answers) {
+ $all_label = get_lang('ReviewQuestions');
+ $class = 'a_button blue medium';
+ } else {
+ $all_label = get_lang('ValidateAnswers');
+ $class = 'a_button green';
+ }
+ $all_button = '
'.$all_label.'';
$all_button .= '
';
+
$html .= $all_button;
}
diff --git a/main/exercice/exercise_submit.php b/main/exercice/exercise_submit.php
index a1857f2821..423c1307cb 100644
--- a/main/exercice/exercise_submit.php
+++ b/main/exercice/exercise_submit.php
@@ -105,11 +105,6 @@ $safe_lp_id = ($learnpath_id == '') ? 0 : $learnpath_id;
$safe_lp_item_id = ($learnpath_item_id == '') ? 0 : $learnpath_item_id;
$safe_lp_item_view_id = ($learnpath_item_view_id == '') ? 0 : $learnpath_item_view_id;
-//if reminder ends we jump to the exexrcise_reminder
-if ($remind_question_id == -1) {
- header('Location: exercise_reminder.php?origin='.$origin.'&exerciseId='.$exerciseId);
- exit;
-}
//Table calls
$stat_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
@@ -153,6 +148,16 @@ if (!is_object($objExercise)) {
exit;
}
+
+//if reminder ends we jump to the exercise_reminder
+if ($objExercise->review_answers) {
+ if ($remind_question_id == -1) {
+ header('Location: exercise_reminder.php?origin='.$origin.'&exerciseId='.$exerciseId);
+ exit;
+ }
+}
+
+
$current_timestamp = time();
$my_remind_list = array();
@@ -509,10 +514,13 @@ if ($question_count != 0) {
//if ($debug) { error_log('Updating track_e_exercises '.$update_query); }
Database::query($update_query);*/
- }
- header('Location: exercise_reminder.php?'.$params);
- exit;
- //header("Location: exercise_submit.php?exerciseId=$exerciseId");
+ }
+ if ($objExercise->review_answers) {
+ header('Location: exercise_reminder.php?'.$params);
+ exit;
+ } else {
+ header("Location: exercise_result.php?exe_id=$exe_id&origin=$origin&learnpath_id=$safe_lp_id&learnpath_item_id=$safe_lp_item_id&learnpath_item_view_id=$safe_lp_item_view_id");
+ }
}
} else {
if ($debug) { error_log('Redirecting to exercise_submit.php'); }
@@ -718,12 +726,19 @@ if ($reminder == 2) {
}
}
} else {
- header("Location: exercise_reminder.php?$params");
- exit;
+ if ($objExercise->review_answers) {
+ header("Location: exercise_reminder.php?$params");
+ exit;
+ }
}
//var_dump($remind_question_id, $my_remind_list, $data_tracking, $current_question);
}
+if ($objExercise->review_answers) {
+ $script_php = 'exercise_reminder.php';
+} else {
+ $script_php = 'exercise_result.php';
+}
if (!empty($error)) {
Display :: display_error_message($error, false);
@@ -887,7 +902,7 @@ if (!empty($error)) {
if (return_value == "ok") {
//$("#save_all_reponse").html("'.addslashes(Display::return_icon('accept.png')).'");
if (validate == "validate") {
- window.location = "exercise_reminder.php?'.$params.'&" + lp_data;
+ window.location = "'.$script_php.'?'.$params.'&" + lp_data;
} else {
$("#save_all_reponse").html("'.addslashes(Display::return_icon('accept.png')).'");
}
@@ -988,11 +1003,13 @@ if (!empty($error)) {
$button = '
'.get_lang('SaveForNow').'';
$button .= '
';
$exercise_actions .= Display::span($button, array('class'=>'exercise_save_now_button'));
- }
-
- $remind_question_div = Display::input('checkbox', 'remind_list['.$questionId.']', '', $attributes);
- $remind_question_div .= Display::tag('label', get_lang('ReviewQuestionLater'), array('for' =>'remind_list['.$questionId.']'));
- $exercise_actions .= Display::span($remind_question_div, array('class'=>'exercise_save_now_button'));
+ }
+
+ if ($objExercise->review_answers) {
+ $remind_question_div = Display::input('checkbox', 'remind_list['.$questionId.']', '', $attributes);
+ $remind_question_div .= Display::tag('label', get_lang('ReviewQuestionLater'), array('for' =>'remind_list['.$questionId.']'));
+ $exercise_actions .= Display::span($remind_question_div, array('class'=>'exercise_save_now_button'));
+ }
echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php
index b2f3194315..c547500a2d 100644
--- a/main/exercice/question.class.php
+++ b/main/exercice/question.class.php
@@ -107,19 +107,22 @@ abstract class Question
} else {
global $course;
$course_info = api_get_course_info();
- }
+ }
+ $course_id = $course_info['real_id'];
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST, $course_info['db_name']);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION, $course_info['db_name']);
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION, $course_info['db_name']);
- $sql="SELECT question,description,ponderation,position,type,picture,level,extra FROM $TBL_QUESTIONS WHERE id= $id ";
+ $sql = "SELECT question,description,ponderation,position,type,picture,level,extra FROM $TBL_QUESTIONS WHERE c_id = $course_id AND id = $id ";
- $result=Database::query($sql);
+ $result = Database::query($sql);
// if the question has been found
if ($object = Database::fetch_object($result)) {
+
$objQuestion = Question::getInstance($object->type);
+
$objQuestion->id = $id;
$objQuestion->question = $object->question;
$objQuestion->description = $object->description;
@@ -130,13 +133,15 @@ abstract class Question
$objQuestion->level = (int) $object->level;
$objQuestion->extra = $object->extra;
$objQuestion->course = $course_info;
-
- $sql="SELECT exercice_id FROM $TBL_EXERCICE_QUESTION WHERE question_id='".$id."'";
- $result=Database::query($sql);
+
+ $sql = "SELECT exercice_id FROM $TBL_EXERCICE_QUESTION WHERE c_id = $course_id AND question_id = $id";
+ $result_exercise_list = Database::query($sql);
// fills the array with the exercises which this question is in
- while($object=Database::fetch_object($result)) {
- $objQuestion->exerciseList[]=$object->exercice_id;
+ if ($result_exercise_list) {
+ while ($obj = Database::fetch_object($result_exercise_list)) {
+ $objQuestion->exerciseList[] = $obj->exercice_id;
+ }
}
return $objQuestion;
}
@@ -473,6 +478,7 @@ abstract class Question
* @return - boolean - true if copied, otherwise false
*/
function exportPicture($questionId, $course_info) {
+ $course_id = $course_info['real_id'];
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION, $course_info['db_name']);
$destination_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/images';
$source_path = api_get_path(SYS_COURSE_PATH).$this->course['path'].'/document/images';
@@ -482,7 +488,7 @@ abstract class Question
$picture=explode('.',$this->picture);
$Extension=$picture[sizeof($picture)-1];
$picture='quiz-'.$questionId.'.'.$Extension;
- $sql="UPDATE $TBL_QUESTIONS SET picture='".Database::escape_string($picture)."' WHERE id='".intval($questionId)."'";
+ $sql="UPDATE $TBL_QUESTIONS SET picture='".Database::escape_string($picture)."' WHERE c_id = $course_id AND id='".intval($questionId)."'";
Database::query($sql);
return @copy($source_path.'/'.$this->picture, $destination_path.'/'.$picture)?true:false;
}
@@ -946,20 +952,24 @@ abstract class Question
$description = DocumentManager::replace_urls_inside_content_html_from_copy_course($description, $this->course['id'], $course_info['id']);
$question = DocumentManager::replace_urls_inside_content_html_from_copy_course($question, $this->course['id'], $course_info['id']);
}
+
+ $course_id = $course_info['real_id'];
$options = self::readQuestionOption($this->id);
//Inserting in the new course db / or the same course db
- $sql="INSERT INTO $TBL_QUESTIONS(question, description, ponderation, position, type, level, extra ) VALUES('".Database::escape_string($question)."','".Database::escape_string($description)."','".Database::escape_string($weighting)."','".Database::escape_string($position)."','".Database::escape_string($type)."' ,'".Database::escape_string($level)."' ,'".Database::escape_string($extra)."' )";
+ $sql = "INSERT INTO $TBL_QUESTIONS (c_id, question, description, ponderation, position, type, level, extra )
+ VALUES('$course_id', '".Database::escape_string($question)."','".Database::escape_string($description)."','".Database::escape_string($weighting)."','".Database::escape_string($position)."','".Database::escape_string($type)."' ,'".Database::escape_string($level)."' ,'".Database::escape_string($extra)."' )";
Database::query($sql);
- $new_question_id =Database::insert_id();
+ $new_question_id = Database::insert_id();
if (!empty($options)) {
//Saving the quiz_options
foreach ($options as $item) {
- $item['question_id'] = $new_question_id;
+ $item['question_id'] = $new_question_id;
+ $item['c_id'] = $course_id;
unset($item['id']);
- Database::insert($TBL_QUESTION_OPTIONS,$item);
+ Database::insert($TBL_QUESTION_OPTIONS, $item);
}
}
diff --git a/main/exercice/question_list_admin.inc.php b/main/exercice/question_list_admin.inc.php
index 24fba0163c..b6259ed4b1 100644
--- a/main/exercice/question_list_admin.inc.php
+++ b/main/exercice/question_list_admin.inc.php
@@ -19,30 +19,8 @@
if(!defined('ALLOWED_TO_INCLUDE')) {
exit();
}
-/*
-// moves a question up in the list
-if(isset($_GET['moveUp'])) {
- $check = Security::get_token('get');
- if ($check) {
- $objExercise->moveUp(intval($_GET['moveUp']));
- $objExercise->save();
- }
- Security::clear_token();
-}
-
-// moves a question down in the list
-if(isset($_GET['moveDown'])) {
- $check = Security::get_token('get');
- if ($check) {
- $objExercise->moveDown(intval($_GET['moveDown']));
- $objExercise->save();
- }
- Security::clear_token();
-}
-*/
// deletes a question from the exercise (not from the data base)
-if($deleteQuestion) {
-
+if ($deleteQuestion) {
// if the question exists
if($objQuestionTmp = Question::read($deleteQuestion)) {
$objQuestionTmp->delete($exerciseId);
@@ -74,8 +52,7 @@ if($deleteQuestion) {