Adding modelType option to exercise (normal and committee) see BT#6312

skala
Julio Montoya 13 years ago
parent 3a032b4bd8
commit 0e8220b160
  1. 119
      main/exercice/exercise.class.php
  2. 6
      main/exercice/exercise_admin.php
  3. 12
      main/exercice/question.class.php
  4. 1
      main/install/1.10.0/db_course.sql
  5. 2
      main/install/1.10.0/db_main.sql
  6. 3
      main/install/1.10.0/migrate-db-1.9.0-1.10.0-pre.sql

@ -12,9 +12,13 @@
*/
use \ChamiloSession as Session;
// Page options
define('ALL_ON_ONE_PAGE', 1);
define('ONE_PER_PAGE', 2);
define('EXERCISE_MODEL_TYPE_NORMAL', 1);
define('EXERCISE_MODEL_TYPE_COMMITTEE', 2);
define('EXERCISE_FEEDBACK_TYPE_END', 0); //Feedback - show score and expected answers
define('EXERCISE_FEEDBACK_TYPE_DIRECT', 1); //DirectFeedback - Do not show score nor answers
define('EXERCISE_FEEDBACK_TYPE_EXAM', 2); //NoFeedback - Show score only
@ -76,6 +80,7 @@ class Exercise
public $emailNotificationTemplate = null;
public $countQuestions = 0;
public $fastEdition = false;
public $modelType = 1;
/**
* Constructor of the class
@ -101,10 +106,11 @@ class Exercise
$this->expired_time = '0000-00-00 00:00:00';
$this->propagate_neg = 0;
$this->review_answers = false;
$this->randomByCat = 0; //
$this->text_when_finished = ""; //
$this->randomByCat = 0;
$this->text_when_finished = "";
$this->display_category_name = 0;
$this->pass_percentage = null;
$this->modelType = 1;
if (!empty($course_id)) {
$course_info = api_get_course_info_by_id($course_id);
@ -164,6 +170,7 @@ class Exercise
$this->is_gradebook_locked = api_resource_is_locked_by_gradebook($id, LINK_EXERCISE);
$this->endButton = $object->end_button;
$this->emailNotificationTemplate = $object->email_notification_template;
$this->modelType = $object->model_type;
$this->review_answers = (isset($object->review_answers) && $object->review_answers == 1) ? true : false;
$sql = "SELECT max_score FROM $table_lp_item
@ -336,6 +343,11 @@ class Exercise
return $this->emailNotificationTemplate;
}
public function getModelType()
{
return $this->modelType;
}
/**
* @return int
*/
@ -1020,6 +1032,11 @@ class Exercise
$this->endButton = intval($value);
}
public function setModelType($value)
{
$this->modelType = intval($value);
}
/**
* @param array $categories
*/
@ -1217,6 +1234,7 @@ class Exercise
pass_percentage = '".Database::escape_string($pass_percentage)."',
end_button = '".$this->selectEndButton()."',
email_notification_template = '".Database::escape_string($this->selectEmailNotificationTemplate())."',
model_type = '".$this->getModelType()."',
results_disabled='".Database::escape_string($results_disabled)."'";
}
$sql .= " WHERE iid = ".Database::escape_string($id)." AND c_id = {$this->course_id}";
@ -1419,6 +1437,13 @@ class Exercise
// style="" and not "display:none" to avoid #4029 Random and number of attempt menu empty
$form->addElement('html', '<div id="options" style="">');
$radio = array(
$form->createElement('radio', 'model_type', null, get_lang('Normal'), EXERCISE_MODEL_TYPE_NORMAL),
$form->createElement('radio', 'model_type', null, get_lang('Committee'), EXERCISE_MODEL_TYPE_COMMITTEE)
);
$form->addGroup($radio, null, get_lang('ModelType'), '');
if ($type == 'full') {
//Can't modify a DirectFeedback question
if ($this->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_DIRECT) {
@ -1457,24 +1482,10 @@ class Exercise
);
$form->addGroup($radios_feedback, null, get_lang('FeedbackType'), '');
// test type
$radios = array();
$radios[] = $form->createElement(
'radio',
'exerciseType',
null,
get_lang('SimpleExercise'),
'1',
array('onclick' => 'check_per_page_all()', 'id' => 'option_page_all')
);
$radios[] = $form->createElement(
'radio',
'exerciseType',
null,
get_lang('SequentialExercise'),
'2',
array('onclick' => 'check_per_page_one()', 'id' => 'option_page_one')
// question
$radios = array(
$form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), ALL_ON_ONE_PAGE, array('onclick' => 'check_per_page_all()', 'id' => 'option_page_all')),
$form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), ONE_PER_PAGE, array('onclick' => 'check_per_page_one()', 'id' => 'option_page_one')),
);
$form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
@ -1542,17 +1553,11 @@ class Exercise
);
$form->addGroup($radios_feedback, null, get_lang('FeedbackType'));
//$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
// test type
$radios = array();
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1');
$radios[] = $form->createElement(
'radio',
'exerciseType',
null,
get_lang('SequentialExercise'),
'2'
// Exercise type
$radios = array(
$form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1'),
$form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2'),
$form->createElement('radio', 'exerciseType', null, get_lang('Committee'), '3')
);
$form->addGroup($radios, null, get_lang('ExerciseType'));
@ -1656,41 +1661,26 @@ class Exercise
);
// 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');
$radios_random_answers = array(
$form->createElement('radio', 'randomAnswers', null, get_lang('Yes'), '1'),
$form->createElement('radio', 'randomAnswers', null, get_lang('No'), '0')
);
$form->addGroup($radios_random_answers, null, get_lang('RandomAnswers'), '');
// Random by category.
$form->addElement('html', '<div class="clear">&nbsp;</div>');
$radiocat = array();
$radiocat[] = $form->createElement(
'radio',
'randomByCat',
null,
get_lang('YesWithCategoriesShuffled'),
'1'
$radiocat = array(
$form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'), '1'),
$form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'), '2'),
$form->createElement('radio', 'randomByCat', null, get_lang('No'), '0')
);
$radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'), '2');
$radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'), '0');
$form->addGroup($radiocat, null, get_lang('RandomQuestionByCategory'), '');
$form->addElement('html', '<div class="clear">&nbsp;</div>');
// Category name.
$radio_display_cat_name = array();
$radio_display_cat_name[] = $form->createElement(
'radio',
'display_category_name',
null,
get_lang('Yes'),
'1'
);
$radio_display_cat_name[] = $form->createElement(
'radio',
'display_category_name',
null,
get_lang('No'),
'0'
$radio_display_cat_name = array(
$form->createElement('radio', 'display_category_name', null, get_lang('Yes'), '1' ),
$form->createElement('radio', 'display_category_name', null, get_lang('No'), '0' )
);
$form->addGroup($radio_display_cat_name, null, get_lang('QuestionDisplayCategoryName'), '');
@ -1746,7 +1736,6 @@ class Exercise
$form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults'));
$form->addElement('html', '<div class="clear">&nbsp;</div>');
$form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers'));
$form->addElement('html', '<div id="divtimecontrol" style="display:'.$display.';">');
// Exercise timer.
@ -1790,10 +1779,11 @@ class Exercise
$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');
$group = array(
$form->createElement('radio', 'end_button', null, get_lang('ExerciseEndButtonCourseHome'), '0'),
$form->createElement('radio', 'end_button', null, get_lang('ExerciseEndButtonExerciseHome'), '1'),
$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>');
@ -1886,6 +1876,7 @@ class Exercise
$defaults['pass_percentage'] = $this->selectPassPercentage();
$defaults['end_button'] = $this->selectEndButton();
$defaults['email_notification_template'] = $this->selectEmailNotificationTemplate();
$defaults['model_type'] = $this->getModelType();
if (($this->start_time != '0000-00-00 00:00:00')) {
$defaults['activate_start_date_check'] = 1;
@ -1909,6 +1900,7 @@ class Exercise
$defaults['enabletimercontroltotalminutes'] = 0;
}
} else {
$defaults['model_type'] = 1;
$defaults['exerciseType'] = 2;
$defaults['exerciseAttempts'] = 0;
$defaults['randomQuestions'] = 0;
@ -1957,6 +1949,7 @@ class Exercise
$this->updateCategories($form->getSubmitValue('category'));
$this->updateEndButton($form->getSubmitValue('end_button'));
$this->updateEmailNotificationTemplate($form->getSubmitValue('email_notification_template'));
$this->setModelType($form->getSubmitValue('model_type'));
if ($form->getSubmitValue('activate_start_date_check') == 1) {
$start_time = $form->getSubmitValue('start_time');
@ -5935,7 +5928,7 @@ class Exercise
case ONE_PER_PAGE:
$exercise_actions .= $this->show_button($questionId, $current_question, null, $remindList);
break;
case ALL_ON_ONE_PAGE :
case ALL_ON_ONE_PAGE:
$button = '<a href="javascript://" class="btn" onclick="save_now(\''.$questionId.'\'); ">'.get_lang('SaveForNow').'</a>';
$button .= '<span id="save_for_now_'.$questionId.'" class="exercise_save_mini_message"></span>&nbsp;';
$exercise_actions .= Display::div($button, array('class'=>'exercise_save_now_button'));

@ -81,10 +81,10 @@ $htmlHeadXtra[] = '<script>
function advanced_parameters() {
if(document.getElementById(\'options\').style.display == \'none\') {
document.getElementById(\'options\').style.display = \'block\';
document.getElementById(\'img_plus_and_minus\').innerHTML=\' '.Display::return_icon('div_hide.gif').' '.addslashes(api_htmlentities(get_lang('AdvancedParameters'))).'\';
document.getElementById(\'img_plus_and_minus\').innerHTML=\' '.Display::return_icon('div_hide.gif').' '.addslashes(get_lang('AdvancedParameters')).'\';
} else {
document.getElementById(\'options\').style.display = \'none\';
document.getElementById(\'img_plus_and_minus\').innerHTML=\' '.Display::return_icon('div_show.gif').' '.addslashes(api_htmlentities(get_lang('AdvancedParameters'))).'\';
document.getElementById(\'img_plus_and_minus\').innerHTML=\' '.Display::return_icon('div_show.gif').' '.addslashes(get_lang('AdvancedParameters')).'\';
}
}
@ -190,7 +190,7 @@ function setFocus(){
$(document).ready(function () {
setFocus();
});
window.onload=advanced_parameters;
window.onload = advanced_parameters;
</script>';
// INIT EXERCISE

@ -1628,11 +1628,11 @@ abstract class Question
*/
abstract public function processAnswersCreation($form);
/**
* Displays the menu of question types
* @param Exercise $objExercise
*/
public static function display_type_menu($objExercise)
public static function display_type_menu(Exercise $objExercise)
{
$feedback_type = $objExercise->feedback_type;
$exerciseId = $objExercise->id;
@ -1643,6 +1643,7 @@ abstract class Question
if (!isset($feedback_type)) {
$feedback_type = 0;
}
if ($feedback_type == 1) {
//2. but if it is a feedback DIRECT we only show the UNIQUE_ANSWER type that is currently available
$question_type_custom_list = array(
@ -1655,8 +1656,15 @@ abstract class Question
echo '<div class="actionsbig">';
echo '<ul class="question_menu">';
$modelType = $objExercise->getModelType();
foreach ($question_type_custom_list as $i => $a_type) {
if ($modelType == EXERCISE_MODEL_TYPE_COMMITTEE) {
if ($a_type[1] != 'FreeAnswer') {
continue;
}
}
// include the class of the type
require_once $a_type[0];
// get the picture of the type and the langvar which describes it

@ -1306,6 +1306,7 @@ CREATE TABLE c_quiz (
autolaunch INT DEFAULT 0,
end_button int NOT NULL DEFAULT 0,
email_notification_template text default '',
model_type INT default 1,
PRIMARY KEY (iid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

@ -3550,4 +3550,4 @@ CREATE TABLE question_score (
-- Do not move this
UPDATE settings_current SET selected_value = '1.10.0.026' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.027' WHERE variable = 'chamilo_database_version';

@ -96,6 +96,7 @@ ALTER TABLE session ADD INDEX idx_id_session_admin_id (session_admin_id);
ALTER TABLE c_quiz_question ADD COLUMN parent_id INT unsigned NOT NULL DEFAULT 0;
ALTER TABLE c_quiz ADD COLUMN email_notification_template TEXT DEFAULT '';
ALTER TABLE c_quiz ADD COLUMN model_type INT DEFAULT 1;
CREATE TABLE IF NOT EXISTS gradebook_evaluation_type(id INT unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT, name varchar(255), external_id INT unsigned NOT NULL DEFAULT 0);
@ -311,4 +312,4 @@ CREATE TABLE question_score_name (id int NOT NULL AUTO_INCREMENT, score varchar
CREATE TABLE question_score ( id int NOT NULL AUTO_INCREMENT, name varchar(255) DEFAULT NULL, PRIMARY KEY (id)) DEFAULT CHARSET=utf8;
-- Do not move this
UPDATE settings_current SET selected_value = '1.10.0.026' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.027' WHERE variable = 'chamilo_database_version';

Loading…
Cancel
Save