Adding exercise review questions optional in the exercise settings see #3958

skala
Julio Montoya 14 years ago
parent a1cb277c55
commit df1bcbc6a5
  1. 59
      main/css/base.css
  2. 99
      main/exercice/exercise.class.php
  3. 51
      main/exercice/exercise_submit.php
  4. 36
      main/exercice/question.class.php
  5. 40
      main/exercice/question_list_admin.inc.php
  6. 2
      main/forum/index.php
  7. BIN
      main/img/icons/22/accept_na.png
  8. 4
      main/inc/lib/add_course.lib.inc.php
  9. 2
      main/install/migrate-db-1.8.8-1.9.0-pre.sql

@ -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;
}
}
/************************************************************************************
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;
}

@ -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','</div>');
$form->addElement('html','<div class="row">
<div class="label">&nbsp;</div>
<div class="formw">
@ -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','<div id="divtimecontrol" style="display:'.$diplay.';">');
@ -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 .= '<a href="javascript://" class="a_button blue medium" onclick="save_now('.$question_id.'); ">'.$label.'</a>';
$all_button .= '<a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.'); ">'.$label.'</a>';
//$all_button .= '&nbsp;<span id="save_all_reponse"></span>';
$all_button .= '<span id="save_for_now_'.$question_id.'"></span>&nbsp;';
$html .= $all_button;
} else {
$all_button = '<a href="javascript://" class="a_button green" onclick="validate_all(); ">'.get_lang('ReviewQuestions').'</a>';
} 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 = '<a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>';
$all_button .= '&nbsp;<span id="save_all_reponse"></span>';
$html .= $all_button;
}

@ -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 = '<a href="javascript://" class="a_button orange medium" onclick="save_now(\''.$questionId.'\'); ">'.get_lang('SaveForNow').'</a>';
$button .= '<span id="save_for_now_'.$questionId.'"></span>&nbsp;';
$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'));

@ -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);
}
}

@ -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) {
<script>
$(function() {
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog-confirm" ).dialog({
autoOpen: false,
show: "blind",
@ -162,7 +139,9 @@ echo '</div><div style="clear:both;"></div>';
echo '<div id="message"></div>';
$token = Security::get_token();
//deletes a session when using don't know question type (ugly fix)
unset($_SESSION['less_answer']);
unset($_SESSION['less_answer']);
echo '<div id="question_list">';
if ($nbrQuestions) {
$my_exercise = new Exercise();
@ -170,9 +149,7 @@ if ($nbrQuestions) {
$my_exercise->read($_GET['exerciseId']);
$questionList=$my_exercise->selectQuestionList();
if (is_array($questionList)) {
echo '<div id="question_list">';
if (is_array($questionList)) {
foreach($questionList as $id) {
//To avoid warning messages
if (!is_numeric($id)) {
@ -220,7 +197,8 @@ if ($nbrQuestions) {
echo '</div>';
}
}
echo '</div>';
if(!$nbrQuestions) {
echo Display::display_warning_message(get_lang('NoQuestion'));
}
}
echo '</div>';

@ -191,6 +191,8 @@ if (api_is_allowed_to_edit(false, true)) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;gradebook='.$gradebook.'&amp;action=add&amp;content=forum&amp;lp_id='.$lp_id.'"> '.Display::return_icon('new_forum.png', get_lang('AddForum'),'','32').'</a>';
}
}
var_dump(api_is_coach());
echo '</div>';
/* Display Forum Categories and the Forums in it */

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

@ -626,8 +626,7 @@ function update_Db_course($course_db_name = null) {
*/
// Exercise tool - Tests/exercises
$sql = "
CREATE TABLE `".$TABLEQUIZ . "` (
$sql = "CREATE TABLE `".$TABLEQUIZ . "` (
$add_to_all_tables
id mediumint unsigned NOT NULL auto_increment,
title varchar(255) NOT NULL,
@ -646,6 +645,7 @@ function update_Db_course($course_db_name = null) {
expired_time int NOT NULL default '0',
session_id smallint default 0,
propagate_neg INT NOT NULL DEFAULT 0,
review_answers INT NOT NULL DEFAULT 0,
PRIMARY KEY (c_id, id)
)" . $charset_clause;
Database::query($sql);

@ -125,4 +125,6 @@ ALTER TABLE lp ADD COLUMN hide_toc_frame TINYINT NOT NULL DEFAULT 0;
ALTER TABLE lp ADD COLUMN seriousgame_mode TINYINT NOT NULL DEFAULT 0;
ALTER TABLE lp_item_view modify column suspend_data longtext;
INSERT INTO course_setting(variable,value,category) VALUES ('course_grading_model','','gradebook');
ALTER TABLE quiz ADD COLUMN review_answers INT NOT NULL DEFAULT 0;

Loading…
Cancel
Save