Adding end_button setting in exercises see BT#6221

skala
Julio Montoya 13 years ago
parent bb23a48dd7
commit 0af851e415
  1. 9
      main/exercice/addlimits.php
  2. 1
      main/exercice/admin.php
  3. 100
      main/exercice/exercise.class.php
  4. 12
      main/exercice/exercise_reminder.php
  5. 13
      main/exercice/exercise_result.php
  6. 2
      main/exercice/exercise_show.php
  7. 5
      main/exercice/exercise_submit.php
  8. 5
      main/exercice/mark_free_answer.php
  9. 1
      main/inc/lib/template.lib.php
  10. 3
      main/install/1.10.0/db_course.sql
  11. 2
      main/install/1.10.0/db_main.sql
  12. 3
      main/install/1.10.0/migrate-db-1.9.0-1.10.0-pre.sql

@ -19,18 +19,15 @@ require_once 'question.class.php';
require_once 'answer.class.php';
// name of the language file that needs to be included
$language_file='exercice';
$language_file = 'exercice';
/* section (for the tabs) */
$this_section=SECTION_COURSES;
$this_section = SECTION_COURSES;
api_protect_course_script();
$dsp_percent = false;
$debug=0;
if($debug>0) {
echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";exervar_dump($_POST);
}
// general parameters passed via POST/GET
if ( empty ( $origin ) )
{
@ -185,4 +182,4 @@ if (isset($_POST['ok'])) {
$query = "UPDATE ".$TBL_EXERCICES." SET num_attempts = 0 WHERE id= $exercise_id";
Database::query($query);
}
}
}

@ -141,6 +141,7 @@ $aType = array(
);
$fastEdition = api_get_course_setting('allow_fast_exercise_edition') == 1 ? true : false;
$fastEdition = false;
if ($fastEdition) {
$htmlHeadXtra[] = api_get_jqgrid_js();

@ -65,6 +65,7 @@ class Exercise
public $categories;
public $categories_grouping = true;
public $fastExerciseEdition = false;
public $endButton = 0;
/**
* Constructor of the class
@ -149,6 +150,7 @@ class Exercise
$this->display_category_name = $object->display_category_name;
$this->pass_percentage = $object->pass_percentage;
$this->is_gradebook_locked = api_resource_is_locked_by_gradebook($id, LINK_EXERCISE);
$this->endButton = $object->end_button;
$this->review_answers = (isset($object->review_answers) && $object->review_answers == 1) ? true : false;
$sql = "SELECT max_score FROM $table_lp_item
@ -288,30 +290,35 @@ class Exercise
* Returns the exercise type
*
* @author - Olivier Brouckaert
* @return - integer - exercise type
* @return integer - exercise type
*/
function selectType()
public function selectType()
{
return $this->type;
}
/**
* @author - hubert borderiou 30-11-11
* @return - integer : do we display the question category name for students
* @return integer : do we display the question category name for students
*/
function selectDisplayCategoryName()
public function selectDisplayCategoryName()
{
return $this->display_category_name;
}
/**
* @return null
* @return string
*/
function selectPassPercentage()
{
return $this->pass_percentage;
}
public function selectEndButton()
{
return $this->endButton;
}
/**
* @author - hubert borderiou 30-11-11
* @return - : modify object to update the switch display_category_name
@ -776,6 +783,11 @@ class Exercise
$this->pass_percentage = $value;
}
public function updateEndButton($value)
{
$this->endButton = intval($value);
}
/**
* @param array $categories
*/
@ -971,6 +983,7 @@ class Exercise
text_when_finished = '".Database::escape_string($text_when_finished)."',
display_category_name = '".Database::escape_string($display_category_name)."',
pass_percentage = '".Database::escape_string($pass_percentage)."',
end_button = '".$this->selectEndButton()."',
results_disabled='".Database::escape_string($results_disabled)."'";
}
$sql .= " WHERE iid = ".Database::escape_string($id)." AND c_id = {$this->course_id}";
@ -1078,7 +1091,7 @@ class Exercise
* @param - integer $questionId - question ID
* @return - boolean - true if the question has been removed, otherwise false
*/
function removeFromList($questionId)
public function removeFromList($questionId)
{
// searches the position of the question ID in the list
$pos = array_search($questionId, $this->questionList);
@ -1108,7 +1121,7 @@ class Exercise
*
* @author - Olivier Brouckaert
*/
function delete()
public function delete()
{
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$sql = "UPDATE $TBL_EXERCICES
@ -1125,8 +1138,9 @@ class Exercise
/**
* Creates the form to create / edit an exercise
* @param FormValidator $form the formvalidator instance (by reference)
* @param string
*/
function createForm($form, $type = 'full')
public function createForm($form, $type = 'full')
{
global $id;
@ -1408,7 +1422,7 @@ class Exercise
}
}
// number of random question
// Number of random question.
$max = ($this->id > 0) ? $this->selectNbrQuestions() : 10;
$option = range(0, $max);
@ -1422,13 +1436,13 @@ class Exercise
array('id' => 'randomQuestions', 'class' => 'chzn-select')
);
//random answers
// Random answers.
$radios_random_answers = array();
$radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'), '1');
$radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'), '0');
$form->addGroup($radios_random_answers, null, get_lang('RandomAnswers'), '');
//randow by category
// Random by category.
$form->addElement('html', '<div class="clear">&nbsp;</div>');
$radiocat = array();
$radiocat[] = $form->createElement(
@ -1443,7 +1457,7 @@ class Exercise
$form->addGroup($radiocat, null, get_lang('RandomQuestionByCategory'), '');
$form->addElement('html', '<div class="clear">&nbsp;</div>');
// add the radio display the category name for student
// Category name .
$radio_display_cat_name = array();
$radio_display_cat_name[] = $form->createElement(
'radio',
@ -1461,7 +1475,7 @@ class Exercise
);
$form->addGroup($radio_display_cat_name, null, get_lang('QuestionDisplayCategoryName'), '');
//Attempts
// Attempts.
$attempt_option = range(0, 10);
$attempt_option[0] = get_lang('Infinite');
@ -1473,7 +1487,7 @@ class Exercise
array('id' => 'exerciseAttempts', 'class' => 'chzn-select')
);
// Exercice time limit
// Exercise time limit.
$form->addElement(
'checkbox',
'activate_start_date_check',
@ -1482,18 +1496,17 @@ class Exercise
array('onclick' => 'activate_start_date()')
);
$var = Exercise::selectTimeLimit();
//$var = Exercise::selectTimeLimit();
// Start time.
if (($this->start_time != '0000-00-00 00:00:00')) {
$form->addElement('html', '<div id="start_date_div" style="display:block;">');
} else {
$form->addElement('html', '<div id="start_date_div" style="display:none;">');
}
$form->addElement('datepicker', 'start_time', '', array('form_name' => 'exercise_admin'), 5);
$form->addElement('html', '</div>');
// End time.
$form->addElement(
'checkbox',
'activate_end_date_check',
@ -1507,11 +1520,10 @@ class Exercise
} else {
$form->addElement('html', '<div id="end_date_div" style="display:none;">');
}
$form->addElement('datepicker', 'end_time', '', array('form_name' => 'exercise_admin'), 5);
$form->addElement('html', '</div>');
//$check_option=$this->selectType();
// Propagate negative values.
$diplay = 'block';
$form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults'));
$form->addElement('html', '<div class="clear">&nbsp;</div>');
@ -1519,9 +1531,7 @@ class Exercise
$form->addElement('html', '<div id="divtimecontrol" style="display:'.$diplay.';">');
//Timer control
//$time_hours_option = range(0,12);
//$time_minutes_option = range(0,59);
// Timer control.
$form->addElement(
'checkbox',
'enabletimercontrol',
@ -1540,6 +1550,7 @@ class Exercise
} else {
$form->addElement('html', '<div id="timercontrol" style="display:none;">');
}
$form->addElement(
'text',
'enabletimercontroltotalminutes',
@ -1548,6 +1559,7 @@ class Exercise
);
$form->addElement('html', '</div>');
// Pass percentage.
$form->addElement(
'text',
'pass_percentage',
@ -1556,9 +1568,17 @@ class Exercise
);
$form->addRule('pass_percentage', get_lang('Numeric'), 'numeric');
// add the text_when_finished textbox
// Text when ending an exam
$form->add_html_editor('text_when_finished', get_lang('TextWhenFinished'), false, false, $editor_config);
// Exam end button.
$group = array();
$group[] = $form->createElement('radio', 'end_button', null, get_lang('ExerciseEndButtonCourseHome'), '0');
$group[] = $form->createElement('radio', 'end_button', null, get_lang('ExerciseEndButtonExerciseHome'), '1');
$group[] = $form->createElement('radio', 'end_button', null, get_lang('ExerciseEndButtonDisconnect'), '2');
$form->addGroup($group, null, get_lang('ExerciseEndButton'));
$form->addElement('html', '<div class="clear">&nbsp;</div>');
$defaults = array();
if (api_get_setting('search_enabled') === 'true') {
@ -1592,7 +1612,7 @@ class Exercise
$form->addElement('html', '</div>');
}
//Category selection
// Category selection.
$cat = new Testcategory();
$cat_form = $cat->return_category_form($this);
@ -1634,6 +1654,8 @@ class Exercise
$defaults['text_when_finished'] = $this->selectTextWhenFinished(); //
$defaults['display_category_name'] = $this->selectDisplayCategoryName(); //
$defaults['pass_percentage'] = $this->selectPassPercentage();
$defaults['end_button'] = $this->selectEndButton();
if (($this->start_time != '0000-00-00 00:00:00')) {
$defaults['activate_start_date_check'] = 1;
@ -1687,7 +1709,6 @@ class Exercise
*/
function processCreation($form, $type = '')
{
$this->updateTitle($form->getSubmitValue('exerciseTitle'));
$this->updateDescription($form->getSubmitValue('exerciseDescription'));
$this->updateAttempts($form->getSubmitValue('exerciseAttempts'));
@ -1704,6 +1725,7 @@ class Exercise
$this->updateReviewAnswers($form->getSubmitValue('review_answers'));
$this->updatePassPercentage($form->getSubmitValue('pass_percentage'));
$this->updateCategories($form->getSubmitValue('category'));
$this->updateEndButton($form->getSubmitValue('end_button'));
if ($form->getSubmitValue('activate_start_date_check') == 1) {
$start_time = $form->getSubmitValue('start_time');
@ -5125,7 +5147,8 @@ class Exercise
/**
* @param array $categories
*/
function save_categories_in_exercise($categories) {
function save_categories_in_exercise($categories)
{
if (!empty($categories) && !empty($this->id)) {
$table = Database::get_course_table(TABLE_QUIZ_REL_CATEGORY);
$sql = "DELETE FROM $table WHERE exercise_id = {$this->id} AND c_id = {$this->course_id}";
@ -5143,4 +5166,27 @@ class Exercise
}
}
}
/**
* Returns a HTML link when the exercise ends (exercise result page)
* @return string
*/
public function returnEndButtonHTML()
{
$endButtonSetting = $this->selectEndButton();
$html = '';
switch ($endButtonSetting) {
case '0':
$html = Display::url(get_lang('ReturnToCourseHomepage'), api_get_course_url(), array('class' => 'btn btn-large'));
break;
case '1':
$html = Display::url(get_lang('ReturnToExerciseList'), api_get_path(WEB_CODE_PATH).'exercice/exercice.php?'.api_get_cidreq(), array('class' => 'btn btn-large'));
break;
case '2':
$html = Display::url(get_lang('Logout'), api_get_path(WEB_PUBLIC_PATH).'logout', array('class' => 'btn btn-large'));
break;
}
return $html;
}
}

@ -31,16 +31,12 @@ $this_section = SECTION_COURSES;
// notice for unauthorized people.
api_protect_course_script(true);
if($debug>0){error_log('Entered exercise_result.php: '.print_r($_POST,1));}
// general parameters passed via POST/GET
// General parameters passed via POST/GET
if ( empty ( $origin ) ) { $origin = Security::remove_XSS($_REQUEST['origin']);}
if ( empty ( $learnpath_id ) ) { $learnpath_id = intval($_REQUEST['learnpath_id']);}
if ( empty ( $learnpath_item_id ) ) { $learnpath_item_id = intval($_REQUEST['learnpath_item_id']);}
if ( empty ( $learnpath_item_view_id ) ) { $learnpath_item_view_id = intval($_REQUEST['learnpath_item_view_id']);}
if ( empty ($exerciseId)) { $exerciseId = intval($_REQUEST['exerciseId']);}
if ( empty ($objExercise)) { $objExercise = $_SESSION['objExercise'];}
if (!$objExercise) {
@ -54,18 +50,18 @@ $time_control = false;
$clock_expired_time = ExerciseLib::get_session_time_control_key($objExercise->id, $learnpath_id, $learnpath_item_id);
if ($objExercise->expired_time != 0 && !empty($clock_expired_time)) {
$time_control = true;
$time_control = true;
}
if ($time_control) {
// Get time left for exipiring time
$time_left = api_strtotime($clock_expired_time,'UTC') - time();
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/stylesheet/jquery.epiclock.css');
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/stylesheet/jquery.epiclock.css');
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');
$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
}
if (isset($_SESSION['exe_id'])) {

@ -60,8 +60,8 @@ if (empty($remind_list)) {
$exe_id = isset($_REQUEST['exe_id']) ? intval($_REQUEST['exe_id']) : 0;
if (empty($objExercise)) {
//Redirect to the exercise overview
//Check if the exe_id exists
// Redirect to the exercise overview
// Check if the exe_id exists
$objExercise = new Exercise();
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
if (!empty($exercise_stat_info) && isset($exercise_stat_info['exe_exo_id'])) {
@ -112,13 +112,13 @@ $learnpath_item_id = $exercise_stat_info['orig_lp_item_id'];
$learnpath_item_view_id = $exercise_stat_info['orig_lp_item_view_id'];
if ($origin == 'learnpath') {
?>
?>
<form method="GET" action="exercice.php?<?php echo api_get_cidreq() ?>">
<input type="hidden" name="origin" value="<?php echo $origin; ?>" />
<input type="hidden" name="learnpath_id" value="<?php echo $learnpath_id; ?>" />
<input type="hidden" name="learnpath_item_id" value="<?php echo $learnpath_item_id; ?>" />
<input type="hidden" name="learnpath_item_view_id" value="<?php echo $learnpath_item_view_id; ?>" />
<?php
<?php
}
$i = $total_score = $total_weight = 0;
@ -156,7 +156,8 @@ ExerciseLib::delete_chat_exercise_session($exe_id);
if ($origin != 'learnpath') {
echo '<hr>';
echo Display::url(get_lang('ReturnToCourseHomepage'), api_get_course_url(), array('class' => 'btn btn-large'));
echo $objExercise->returnEndButtonHTML();
if (api_is_allowed_to_session_edit()) {
Session::erase('objExercise');
@ -179,4 +180,4 @@ if ($origin != 'learnpath') {
echo "<script>window.parent.API.void_save_asset('$total_score', '$total_weight', 0, 'completed');</script>";
echo '<script type="text/javascript">'.$href.'</script>';
echo '</body></html>';
}
}

@ -43,7 +43,7 @@ $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_
$TBL_TRACK_ATTEMPT = Database::get_statistic_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 ($debug) { error_log('Entered exercise_show.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; }

@ -1089,7 +1089,6 @@ if (!empty($error)) {
echo '<script>
$(function() {
//$(".exercise_save_now_button").hide();
$(".main_question").mouseover(function() {
//$(this).find(".exercise_save_now_button").show();
//$(this).addClass("question_highlight");
@ -1145,7 +1144,7 @@ if (!empty($error)) {
//3. Hotspots
var hotspot = $(\'*[name*="hotspot[\'+question_id+\']"]\').serialize();
//Checking FCK
// Checking FCK
if (typeof(FCKeditorAPI) !== "undefined") {
var oEditor = FCKeditorAPI.GetInstance("choice["+question_id+"]") ;
var fck_content = "";
@ -1165,7 +1164,7 @@ if (!empty($error)) {
// Only for the first time
$("#save_for_now_"+question_id).html(" '.addslashes(Display::return_icon('loading1.gif')).'");
$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('loading1.gif')).'");
$.ajax({
type:"post",

@ -13,10 +13,10 @@
* Code
*/
// name of the language file that needs to be included
$language_file='exercice';
$language_file = 'exercice';
// name of the language file that needs to be included
include('../inc/global.inc.php');
require_once '../inc/global.inc.php';
// including additional libraries
require_once 'exercise.class.php';
@ -25,7 +25,6 @@ require_once 'answer.class.php';
//debug param. 0: no display - 1: debug display
$debug=0;
if($debug>0){echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";var_dump($_POST);}
// general parameters passed via POST/GET
$my_course_code = $_GET['cid'];

@ -322,6 +322,7 @@ class Template
'web_img' => api_get_path(WEB_IMG_PATH),
'web_plugin' => api_get_path(WEB_PLUGIN_PATH),
'web_lib' => api_get_path(WEB_LIBRARY_PATH),
'public_web' => api_get_path(WEB_PUBLIC_PATH)
);
$this->assign('_p', $_p);

@ -1304,6 +1304,7 @@ CREATE TABLE c_quiz (
display_category_name int(11) NOT NULL DEFAULT '1',
pass_percentage int(11) DEFAULT NULL,
autolaunch INT DEFAULT 0,
end_button int NOT NULL DEFAULT 0,
PRIMARY KEY (iid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -1986,4 +1987,4 @@ CREATE TABLE c_wiki_mailcue (
PRIMARY KEY (c_id,id,user_id),
KEY c_id (c_id,id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40101 SET character_set_client = @saved_cs_client */;

@ -3521,4 +3521,4 @@ CREATE TABLE ext_log_entries (
) DEFAULT CHARSET=utf8;
-- Do not move this
UPDATE settings_current SET selected_value = '1.10.0.011' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.012' WHERE variable = 'chamilo_database_version';

@ -279,6 +279,7 @@ ALTER TABLE user_field_values ADD COLUMN comment VARCHAR(100) default '';
ALTER TABLE session_field_values ADD COLUMN comment VARCHAR(100) default '';
ALTER TABLE course_field_values ADD COLUMN comment VARCHAR(100) default '';
ALTER TABLE question_field_values ADD COLUMN comment VARCHAR(100) default '';
ALTER TABLE c_quiz ADD COLUMN end_button int NOT NULL default 0;
-- Do not move this
UPDATE settings_current SET selected_value = '1.10.0.011' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.012' WHERE variable = 'chamilo_database_version';

Loading…
Cancel
Save