Cleaning exercise classes in order to be loaded by a controller. This classes print echos when editing a question so it can't be managed by a controller.

skala
Julio Montoya 13 years ago
parent b0e315664c
commit 8010cd2e77
  1. 5
      main/css/base.css
  2. 2
      main/exercice/admin.php
  3. 4
      main/exercice/answer.class.php
  4. 39
      main/exercice/draggable.class.php
  5. 16
      main/exercice/exercise.class.php
  6. 167
      main/exercice/exercise_admin.php
  7. 2
      main/exercice/fill_blanks.class.php
  8. 4
      main/exercice/global_multiple_answer.class.php
  9. 2
      main/exercice/hotspot_savescore.inc.php
  10. 2
      main/exercice/matching.class.php
  11. 8
      main/exercice/multiple_answer.class.php
  12. 4
      main/exercice/multiple_answer_combination.class.php
  13. 6
      main/exercice/multiple_answer_true_false.class.php
  14. 83
      main/exercice/question.class.php
  15. 6
      main/exercice/question_admin.inc.php
  16. 16
      main/exercice/unique_answer.class.php
  17. 4
      main/exercice/unique_answer_image.class.php
  18. 4
      main/exercice/unique_answer_no_option.class.php
  19. 5
      main/inc/lib/database.lib.php

@ -5270,4 +5270,9 @@ i.size-32.icon-new-work {
.exercise_pagination {
margin: 0px;
}
#question_admin_form .media {
display:none;
}

@ -204,7 +204,7 @@ if ($editQuestion || $newQuestion || $modifyQuestion || $modifyAnswers) {
// reads question data
if ($editQuestion) {
// question not found
if (!$objQuestion = Question::read($editQuestion)) {
if (!$objQuestion = Question::read($editQuestion, null, $objExercise)) {
api_not_allowed();
}
// saves the object into the session

@ -120,7 +120,7 @@ class Answer
*/
$sql = "SELECT iid, answer, correct, comment, ponderation, position, hotspot_coordinates, hotspot_type, destination
FROM $TBL_ANSWER
WHERE c_id = {$this->course_id} AND question_id ='".$questionId."' ORDER BY position";
WHERE question_id ='".$questionId."' ORDER BY position";
$result = Database::query($sql);
$counter = 1;
@ -605,7 +605,7 @@ class Answer
}
$question_info = Question::read($questionId);
if ($question_info->type == MATCHING) {
//Fixing real answer id

@ -100,7 +100,6 @@ class Draggable extends Matching
// DISPLAY MATCHES
$html = '<table class="data_table">
<tr>
<th width="40%">
'.get_lang('Answer').'
</th>
@ -112,7 +111,7 @@ class Draggable extends Matching
</th>
</tr>';
$form->addElement('label', get_lang('MakeCorrespond').'<br /> <img src="../img/fill_field.png">', $html);
$form->addElement('label', get_lang('MakeCorrespond').'<br /> '.Display::return_icon('fill_field.png'), $html);
if ($nb_matches < 1) {
$nb_matches = 1;
@ -122,9 +121,6 @@ class Draggable extends Matching
for ($i = 1; $i <= $nb_matches; ++$i) {
$form->addElement('html', '<tr><td>');
$group = array();
/*$puce = $form->createElement('text', null, null, 'value="'.$i.'"');
$puce->freeze();
$group[] = $puce;*/
$group[] = $form->createElement('text', 'answer['.$i.']', null, ' size="60" style="margin-left: 0em;"');
$group[] = $form->createElement('select', 'matches['.$i.']', null, $a_matches);
@ -138,13 +134,11 @@ class Draggable extends Matching
$form->addElement('html', '</td></tr>');
$defaults['option['.$i.']'] = $i;
//$defaults['matches['.$i.']'] = $i;
}
$form->addElement('html', '</table></div></div>');
$group = array();
$group[] = $form->createElement(
'style_submit_button',
'moreMatches',
@ -162,37 +156,6 @@ class Draggable extends Matching
$group[] = $form->createElement('style_submit_button', 'submitQuestion', $text, 'class="'.$class.'"');
$form->addGroup($group);
// DISPLAY OPTIONS
/*
$html = '<table class="data_table">
<tr style="text-align: center;">
<th width="10px">
'.get_lang('Number').'
</th>
<th width="90%"
'.get_lang('Answer').'
</th>
</tr>';
//$form -> addElement ('html', $html);
$form->addElement('label', null, $html);
if ($nb_options < 1)
{
$nb_options = 1;
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
}
for ($i = 1; $i <= $nb_matches; ++$i) {
$form->addElement('html', '<tr><td>');
$group = array();
$puce = $form->createElement('text', null, null, 'value="'.chr(64 + $i).'"');
$puce->freeze();
$group[] = $puce;
$group[] = $form->createElement('text', 'option['.$i.']', null, array('class' => 'span6'));
$form->addGroup($group, null, null, '</td><td>');
$form->addElement('html', '</td></tr>');
}*/
$form->addElement('html', '</table></div></div>');
if (!empty($this->id)) {

@ -1155,7 +1155,7 @@ class Exercise
'
<a href="javascript://" onclick=" return show_media()">
<span id="media_icon">
<img style="vertical-align: middle;" src="../img/looknfeel.png" alt="" /> '.addslashes(
'.Display::return_icon('looknfeel.png').' '.addslashes(
api_htmlentities(get_lang('ExerciseDescription'))
).'
</span>
@ -1168,16 +1168,18 @@ class Exercise
$editor_config = array_merge($editor_config, $type);
}
$form->addElement('html', '<div class="HideFCKEditor" id="HiddenFCKexerciseDescription" >');
$form->add_html_editor('exerciseDescription', get_lang('ExerciseDescription'), false, false, $editor_config);
$form->addElement('html', '</div>');
$form->addElement(
'advanced_settings',
'<a href="javascript://" onclick=" return advanced_parameters()"><span id="img_plus_and_minus"><div style="vertical-align:top;" >
<img style="vertical-align:middle;" src="../img/div_show.gif" alt="" /> '.addslashes(
api_htmlentities(get_lang('AdvancedParameters'))
).'</div></span></a>'
$form->addElement('advanced_settings',
'<a href="javascript://" onclick=" return advanced_parameters()">
<span id="img_plus_and_minus">
<div style="vertical-align:top;" >
'.Display::return_icon('div_show.gif').' '.addslashes(api_htmlentities(get_lang('AdvancedParameters'))).'</div>
</span>
</a>'
);
// Random questions

@ -30,7 +30,6 @@ $url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?1=1';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
$htmlHeadXtra[] = '<link href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
$htmlHeadXtra[] = '<script>
function check() {
$("#category_id option:selected").each(function() {
@ -81,107 +80,106 @@ $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=\' <img style="vertical-align:middle;" src="../img/div_hide.gif" alt="" /> '.addslashes(api_htmlentities(get_lang('AdvancedParameters'))).'\';
document.getElementById(\'img_plus_and_minus\').innerHTML=\' '.Display::return_icon('div_hide.gif').' '.addslashes(api_htmlentities(get_lang('AdvancedParameters'))).'\';
} else {
document.getElementById(\'options\').style.display = \'none\';
document.getElementById(\'img_plus_and_minus\').innerHTML=\' <img style="vertical-align:middle;" src="../img/div_show.gif" alt="" /> '.addslashes(api_htmlentities(get_lang('AdvancedParameters'))).'\';
document.getElementById(\'img_plus_and_minus\').innerHTML=\' '.Display::return_icon('div_show.gif').' '.addslashes(api_htmlentities(get_lang('AdvancedParameters'))).'\';
}
}
function FCKeditor_OnComplete( editorInstance ) {
if (document.getElementById ( \'HiddenFCK\' + editorInstance.Name )) {
HideFCKEditorByInstanceName (editorInstance.Name);
}
}
function HideFCKEditorByInstanceName ( editorInstanceName ) {
if (document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className == "HideFCKEditor" )
{
document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className = "media";
}
}
function show_media() {
var my_display = document.getElementById(\'HiddenFCKexerciseDescription\').style.display;
if(my_display== \'none\' || my_display == \'\') {
document.getElementById(\'HiddenFCKexerciseDescription\').style.display = \'block\';
document.getElementById(\'media_icon\').innerHTML=\' <img src="../img/looknfeelna.png" alt="" /> '.addslashes(api_htmlentities(get_lang('ExerciseDescription'))).'\';
} else {
document.getElementById(\'HiddenFCKexerciseDescription\').style.display = \'none\';
document.getElementById(\'media_icon\').innerHTML=\' <img src="../img/looknfeel.png" alt="" /> '.addslashes(api_htmlentities(get_lang('ExerciseDescription'))).'\';
}
}
function FCKeditor_OnComplete( editorInstance ) {
if (document.getElementById ( \'HiddenFCK\' + editorInstance.Name )) {
HideFCKEditorByInstanceName (editorInstance.Name);
}
}
function activate_start_date() {
if(document.getElementById(\'start_date_div\').style.display == \'none\') {
document.getElementById(\'start_date_div\').style.display = \'block\';
} else {
document.getElementById(\'start_date_div\').style.display = \'none\';
}
}
function HideFCKEditorByInstanceName ( editorInstanceName ) {
if (document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className == "HideFCKEditor" ) {
document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className = "media";
}
}
function activate_end_date() {
if(document.getElementById(\'end_date_div\').style.display == \'none\') {
document.getElementById(\'end_date_div\').style.display = \'block\';
function show_media() {
var my_display = document.getElementById(\'HiddenFCKexerciseDescription\').style.display;
if(my_display== \'none\' || my_display == \'\') {
document.getElementById(\'HiddenFCKexerciseDescription\').style.display = \'block\';
document.getElementById(\'media_icon\').innerHTML=\' '.Display::return_icon('looknfeel.png').' '.addslashes(api_htmlentities(get_lang('ExerciseDescription'))).'\';
} else {
document.getElementById(\'end_date_div\').style.display = \'none\';
document.getElementById(\'HiddenFCKexerciseDescription\').style.display = \'none\';
document.getElementById(\'media_icon\').innerHTML=\' '.Display::return_icon('looknfeel.png').' '.addslashes(api_htmlentities(get_lang('ExerciseDescription'))).'\';
}
}
function activate_start_date() {
if(document.getElementById(\'start_date_div\').style.display == \'none\') {
document.getElementById(\'start_date_div\').style.display = \'block\';
} else {
document.getElementById(\'start_date_div\').style.display = \'none\';
}
}
function activate_end_date() {
if(document.getElementById(\'end_date_div\').style.display == \'none\') {
document.getElementById(\'end_date_div\').style.display = \'block\';
} else {
document.getElementById(\'end_date_div\').style.display = \'none\';
}
}
function feedbackselection() {
var index = document.exercise_admin.exerciseFeedbackType.selectedIndex;
if (index == \'1\') {
document.exercise_admin.exerciseType[1].checked=true;
document.exercise_admin.exerciseType[0].disabled=true;
} else {
document.exercise_admin.exerciseType[0].disabled=false;
}
}
function feedbackselection() {
var index = document.exercise_admin.exerciseFeedbackType.selectedIndex;
function option_time_expired() {
if(document.getElementById(\'timercontrol\').style.display == \'none\')
{
document.getElementById(\'timercontrol\').style.display = \'block\';
} else {
document.getElementById(\'timercontrol\').style.display = \'none\';
}
}
function check_per_page_one() {
/*if (document.getElementById(\'divtimecontrol\').style.display==\'none\') {
document.getElementById(\'divtimecontrol\').style.display=\'block\';
document.getElementById(\'divtimecontrol\').display=block;
document.getElementById(\'timecontrol\').display=none;
}*/
document.getElementById(\'exerciseType_0\').checked=true;
}
if (index == \'1\') {
document.exercise_admin.exerciseType[1].checked=true;
document.exercise_admin.exerciseType[0].disabled=true;
} else {
document.exercise_admin.exerciseType[0].disabled=false;
}
}
function check_per_page_all() {
/*if (document.getElementById(\'divtimecontrol\').style.display==\'block\') {
document.getElementById(\'divtimecontrol\').style.display=\'none\';
document.getElementById(\'enabletimercontroltotalminutes\').value=\'\';
}*/
function option_time_expired() {
if(document.getElementById(\'timercontrol\').style.display == \'none\')
{
document.getElementById(\'timercontrol\').style.display = \'block\';
} else {
document.getElementById(\'timercontrol\').style.display = \'none\';
}
}
if (document.getElementById(\'exerciseType_1\') && document.getElementById(\'exerciseType_1\').checked) {
document.getElementById(\'exerciseType_0\').checked = true;
}
}
function check_per_page_one() {
/*if (document.getElementById(\'divtimecontrol\').style.display==\'none\') {
document.getElementById(\'divtimecontrol\').style.display=\'block\';
document.getElementById(\'divtimecontrol\').display=block;
document.getElementById(\'timecontrol\').display=none;
}*/
document.getElementById(\'exerciseType_0\').checked=true;
}
function check_feedback() {
document.getElementById(\'result_disabled_0\').checked = true;
}
function check_per_page_all() {
/*if (document.getElementById(\'divtimecontrol\').style.display==\'block\') {
document.getElementById(\'divtimecontrol\').style.display=\'none\';
document.getElementById(\'enabletimercontroltotalminutes\').value=\'\';
}*/
function check_direct_feedback() {
document.getElementById(\'option_page_one\').checked = true;
document.getElementById(\'result_disabled_0\').checked = true;
}
if (document.getElementById(\'exerciseType_1\') && document.getElementById(\'exerciseType_1\').checked) {
document.getElementById(\'exerciseType_0\').checked = true;
}
}
function check_results_disabled() {
document.getElementById(\'exerciseType_2\').checked = true;
}
</script>';
function check_feedback() {
document.getElementById(\'result_disabled_0\').checked = true;
}
function check_direct_feedback() {
document.getElementById(\'option_page_one\').checked = true;
document.getElementById(\'result_disabled_0\').checked = true;
}
function check_results_disabled() {
document.getElementById(\'exerciseType_2\').checked = true;
}
</script>';
// to correct #4029 Random and number of attempt menu empty added window.onload=advanced_parameters;
$htmlHeadXtra[] = '<script>
@ -265,9 +263,6 @@ if ($form->validate()) {
Display::display_error_message(get_lang('SearchXapianModuleNotInstalled'));
}
// to hide the exercise description
echo '<style> .media { display:none;}</style>';
if ($objExercise->id != 0 && $objExercise->edit_exercise_in_lp == false) {
$form->freeze();
}

@ -126,7 +126,7 @@ class FillBlanks extends Question
// answer
$form -> addElement ('label', null, '<br /><br />'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank'));
$form -> addElement ('html_editor', 'answer', '<img src="../img/fill_field.png">','id="answer" cols="122" rows="6" onkeyup="javascript: updateBlanks(this);"', array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350'));
$form -> addElement ('html_editor', 'answer', Display::return_icon('fill_field.png'),'id="answer" cols="122" rows="6" onkeyup="javascript: updateBlanks(this);"', array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350'));
$form -> addRule ('answer',get_lang('GiveText'),'required');
$form -> addRule ('answer',get_lang('DefineBlanks'),'regex','/\[.*\]/');

@ -25,7 +25,7 @@ class GlobalMultipleAnswer extends Question
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4;
$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
$obj_ex = $_SESSION['objExercise'];
$obj_ex = $this->exercise;
/* Mise en variable de Affichage "Reponses" et son icone, "N<EFBFBD>", "Vrai", "Reponse" */
$html = '<table class="data_table">
@ -47,7 +47,7 @@ class GlobalMultipleAnswer extends Question
$html .='</tr>';
$form->addElement('label', get_lang('Answers') . '<br /> <img src="../img/fill_field.png">', $html);
$form->addElement('label', get_lang('Answers') . '<br />'.Display::return_icon('fill_field.png'), $html);
/* Initialiation variable */
$defaults = array();

@ -17,7 +17,7 @@ include('../inc/lib/database.lib.php');
$courseCode = $_GET['coursecode'];
$questionId = $_GET['questionId'];
$coordinates = $_GET['coord'];
$objExcercise = $_SESSION['objExercise'];
$objExcercise = $this->exercise;
$exerciseId = $objExcercise->selectId();
// Save clicking order
$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids'])+1;

@ -113,7 +113,7 @@ class Matching extends Question
</th>
</tr>';
$form->addElement('label', get_lang('MakeCorrespond').'<br /> <img src="../img/fill_field.png">', $html);
$form->addElement('label', get_lang('MakeCorrespond').'<br /> '.Display::return_icon('fill_field.png'), $html);
if ($nb_matches < 1) {
$nb_matches = 1;

@ -28,8 +28,8 @@ class MultipleAnswer extends Question {
*/
function MultipleAnswer() {
parent::question();
$this -> type = MULTIPLE_ANSWER;
$this -> isContent = $this-> getIsContent();
$this ->type = MULTIPLE_ANSWER;
$this ->isContent = $this-> getIsContent();
}
/**
@ -42,7 +42,7 @@ class MultipleAnswer extends Question {
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4; // The previous default value was 2. See task #1759.
$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
$obj_ex = $_SESSION['objExercise'];
$obj_ex = $this->exercise;
$html='<table class="data_table">
<tr>
@ -65,7 +65,7 @@ class MultipleAnswer extends Question {
'.get_lang('Weighting').'
</th>
</tr>';
$form -> addElement ('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
$form -> addElement ('label', get_lang('Answers').'<br />'.Display::return_icon('fill_field.png'), $html);
$defaults = array();
$correct = 0;

@ -42,7 +42,7 @@ class MultipleAnswerCombination extends Question
function createAnswersForm ($form) {
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2;
$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
$obj_ex = $_SESSION['objExercise'];
$obj_ex = $this->exercise;
$html= '<table class="data_table">
<tr style="text-align: center;">
<th width="10px">
@ -59,7 +59,7 @@ class MultipleAnswerCombination extends Question
$html .='<th>'.get_lang('Comment').'</th>';
}
$html .= '</tr>';
$form -> addElement ('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
$form -> addElement ('label', get_lang('Answers').'<br />'.Display::return_icon('fill_field.png'), $html);
$defaults = array();
$correct = 0;

@ -43,7 +43,7 @@ class MultipleAnswerTrueFalse extends Question
$course_id = api_get_course_int_id();
$obj_ex = $_SESSION['objExercise'];
$obj_ex = $this->exercise;
$renderer = & $form->defaultRenderer();
@ -68,7 +68,7 @@ class MultipleAnswerTrueFalse extends Question
$html .='<th>'.get_lang('Comment').'</th>';
}
$html .= '</tr>';
$form -> addElement ('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
$form -> addElement ('label', get_lang('Answers').'<br />'.Display::return_icon('fill_field.png'), $html);
$correct = 0;
if (!empty($this -> id)) {
@ -101,7 +101,7 @@ class MultipleAnswerTrueFalse extends Question
$answer_number->freeze();
if (is_object($answer)) {
$answer_id = $answer->getRealAnswerIdFromList($i);
$defaults['answer['.$i.']'] = $answer->answer[$answer_id];

@ -35,13 +35,14 @@ abstract class Question
public $parent_id;
public $isContent;
public $course;
static $typePicture = 'new_question.png';
static $explanationLangVar = '';
public static $typePicture = 'new_question.png';
public static $explanationLangVar = '';
public $question_table_class = 'table table-striped';
public $editionMode = 'normal';
public $exercise; // exercise obj
public $setDefaultValues = false;
static $questionTypes = array(
public static $questionTypes = array(
UNIQUE_ANSWER => array('unique_answer.class.php', 'UniqueAnswer'),
MULTIPLE_ANSWER => array('multiple_answer.class.php', 'MultipleAnswer'),
FILL_IN_BLANKS => array('fill_blanks.class.php', 'FillBlanks'),
@ -129,7 +130,7 @@ abstract class Question
*
* @return boolean - true if question exists, otherwise false
*/
static function read($id, $course_id = null)
static function read($id, $course_id = null, Exercise $exercise = null)
{
$id = intval($id);
@ -142,13 +143,14 @@ abstract class Question
$course_id = $course_info['real_id'];
if (empty($course_id) || $course_id == -1) {
return false;
//return false;
}
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$sql = "SELECT * FROM $TBL_QUESTIONS WHERE iid = $id AND c_id = $course_id";
//$sql = "SELECT * FROM $TBL_QUESTIONS WHERE iid = $id AND c_id = $course_id";
$sql = "SELECT * FROM $TBL_QUESTIONS WHERE iid = $id";
$result = Database::query($sql);
@ -170,8 +172,10 @@ abstract class Question
$objQuestion->course = $course_info;
$objQuestion->parent_id = $object->parent_id;
$objQuestion->category_list = Testcategory::getCategoryForQuestion($id);
$objQuestion->exercise = $exercise;
$sql = "SELECT exercice_id FROM $TBL_EXERCICE_QUESTION WHERE c_id = $course_id AND question_id = $id";
//$sql = "SELECT exercice_id FROM $TBL_EXERCICE_QUESTION WHERE c_id = $course_id AND question_id = $id";
$sql = "SELECT exercice_id FROM $TBL_EXERCICE_QUESTION WHERE question_id = $id";
$result_exercise_list = Database::query($sql);
// fills the array with the exercises which this question is in
@ -1305,14 +1309,16 @@ abstract class Question
* @param integer $type the type of the question
* @return an instance of a Question subclass (or of Questionc class by default)
*/
static function getInstance($type)
static function getInstance($type, Exercise $exercise = null)
{
if (!is_null($type)) {
list($file_name, $class_name) = self::get_question_type($type);
if (!empty($file_name)) {
include_once $file_name;
if (class_exists($class_name)) {
return new $class_name();
$obj = new $class_name();
$obj->exercise = $exercise;
return $obj;
} else {
echo 'Can\'t instanciate class '.$class_name.' of type '.$type;
}
@ -1325,16 +1331,15 @@ abstract class Question
/**
* Creates the form to create / edit a question
* A subclass can redifine this function to add fields...
*
* @param FormValidator $form the formvalidator instance (by reference)
*/
function createForm(&$form, $fck_config = 0)
public function createForm(&$form, $fck_config = 0)
{
$url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?1=1';
echo '<style>
.media { display:none;}
</style>';
$js = null;
if ($this->type != MEDIA_QUESTION) {
echo '<script>
$js = '<script>
function check() {
$("#category_id option:selected").each(function() {
var id = $(this).val();
@ -1378,7 +1383,8 @@ abstract class Question
});
</script>';
}
echo '<script>
$js .= '<script>
// hack to hide http://cksource.com/forums/viewtopic.php?f=6&t=8700
function FCKeditor_OnComplete( editorInstance ) {
@ -1395,38 +1401,35 @@ abstract class Question
function show_media(){
var my_display = document.getElementById(\'HiddenFCKquestionDescription\').style.display;
if(my_display== \'none\' || my_display == \'\') {
if (my_display== \'none\' || my_display == \'\') {
document.getElementById(\'HiddenFCKquestionDescription\').style.display = \'block\';
document.getElementById(\'media_icon\').innerHTML=\'&nbsp;<img style="vertical-align: middle;" src="../img/looknfeelna.png" alt="" />&nbsp;'.get_lang(
'EnrichQuestion'
).'\';
document.getElementById(\'media_icon\').innerHTML=\'&nbsp;'.Display::return_icon('looknfeelna.png').'&nbsp;'.get_lang('EnrichQuestion').'\';
} else {
document.getElementById(\'HiddenFCKquestionDescription\').style.display = \'none\';
document.getElementById(\'media_icon\').innerHTML=\'&nbsp;<img style="vertical-align: middle;" src="../img/looknfeel.png" alt="" />&nbsp;'.get_lang(
'EnrichQuestion'
).'\';
document.getElementById(\'media_icon\').innerHTML=\'&nbsp;'.Display::return_icon('looknfeel.png').'&nbsp;'.get_lang('EnrichQuestion').'\';
}
}
// hub 13-12-2010
function visiblerDevisibler(in_id) {
if (document.getElementById(in_id)) {
if (document.getElementById(in_id).style.display == "none") {
document.getElementById(in_id).style.display = "block";
if (document.getElementById(in_id+"Img")) {
document.getElementById(in_id+"Img").src = "../img/div_hide.gif";
document.getElementById(in_id+"Img").html = "'.addslashes(Display::return_icon('div_hide.gif')).'";
}
}
else {
} else {
document.getElementById(in_id).style.display = "none";
if (document.getElementById(in_id+"Img")) {
document.getElementById(in_id+"Img").src = "../img/div_show.gif";
document.getElementById(in_id+"Img").html = "dsdsds'.addslashes(Display::return_icon('div_show.gif')).'";
}
}
}
}
</script>';
$form->addElement('html', $js);
// question name
$form->addElement('text', 'questionName', get_lang('Question'), array('class' => 'span6'));
$form->addRule('questionName', get_lang('GiveQuestion'), 'required');
@ -1450,9 +1453,8 @@ abstract class Question
$form->addElement(
'advanced_settings',
'<a href="javascript://" onclick=" return show_media()"><span id="media_icon"><img style="vertical-align: middle;" src="../img/looknfeel.png" alt="" />&nbsp;'.get_lang(
'EnrichQuestion'
).'</span></a>
'<a href="javascript://" onclick=" return show_media()"><span id="media_icon">
'.Display::return_icon('looknfeel.png').'&nbsp;'.get_lang('EnrichQuestion').'</span></a>
'
);
@ -1467,18 +1469,13 @@ abstract class Question
if ($this->type != MEDIA_QUESTION) {
// Advanced parameters
$form->addElement(
'advanced_settings',
'<a href="javascript:void(0)" onclick="visiblerDevisibler(\'id_advancedOption\')"><img id="id_advancedOptionImg" style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;'.get_lang(
"AdvancedParameters"
).'</a>'
);
$form->addElement('advanced_settings', '<a class="btn btn-show advanced_parameters" id="advanced_params" href="javascript://">'.get_lang('AdvancedParameters').'</a>');
$form->addElement('html', '<div id="id_advancedOption" style="display:none;">');
$form->addElement('html', '<div id="advanced_params_options" style="display:none;">');
$select_level = Question::get_default_levels();
$form->addElement('select', 'questionLevel', get_lang('Difficulty'), $select_level);
$categoryJS = null;
if (!empty($this->category_list)) {
$trigger = '';
foreach ($this->category_list as $category_id) {
@ -1489,8 +1486,9 @@ abstract class Question
}
}
}
echo '<script>$(function() { '.$trigger.' });</script>';
$categoryJS .= '<script>$(function() { '.$trigger.' });</script>';
}
$form->addElement('html', $categoryJS);
$form->addElement(
'select',
@ -1542,8 +1540,7 @@ abstract class Question
}
// default values
$defaults = array();
$defaults = array();
$defaults['questionName'] = $this->question;
$defaults['questionDescription'] = $this->description;
$defaults['questionLevel'] = $this->level;
@ -1562,6 +1559,10 @@ abstract class Question
$form->setDefaults($defaults);
}
}
if ($this->setDefaultValues) {
$form->setDefaults($defaults);
}
}

@ -15,15 +15,17 @@ $course_id = api_get_course_int_id();
// INIT QUESTION
if (isset($_GET['editQuestion'])) {
$objQuestion = Question::read($_GET['editQuestion']);
$objQuestion = Question::read($_GET['editQuestion'], null, $objExercise);
$action = api_get_self()."?".api_get_cidreq(
)."&myid=1&modifyQuestion=".$modifyQuestion."&editQuestion=".$objQuestion->id."&exerciseId=$exerciseId";
} else {
$objQuestion = Question :: getInstance($_REQUEST['answerType']);
$objQuestion = Question::getInstance($_REQUEST['answerType'], $objExercise);
$action = api_get_self()."?".api_get_cidreq(
)."&modifyQuestion=".$modifyQuestion."&newQuestion=".$newQuestion."&exerciseId=$exerciseId";
}
/** @var Question $objQuestion */
if (is_object($objQuestion)) {
//Form creation
$form = new FormValidator('question_admin_form', 'post', $action);

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
/**
* File containing the UNIQUE_ANSWER class.
* File containing the UNIQUE_ANSWER class.
* @package chamilo.exercise
* @author Eric Marguin
*/
@ -29,7 +29,7 @@ class UniqueAnswer extends Question
/**
* Constructor
*/
function UniqueAnswer()
public function UniqueAnswer()
{
//this is highly important
parent::question();
@ -42,10 +42,10 @@ class UniqueAnswer extends Question
* @param the formvalidator instance
* @param the answers number to display
*/
function createAnswersForm($form)
public function createAnswersForm($form)
{
// Getting the exercise list
$obj_ex = $_SESSION['objExercise'];
$obj_ex = $this->exercise;
$editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125');
@ -91,7 +91,7 @@ class UniqueAnswer extends Question
</th>
</tr>';
$form->addElement('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
$form->addElement('label', get_lang('Answers').'<br />'.Display::return_icon('fill_field.png'), $html);
$defaults = array();
$correct = 0;
@ -316,7 +316,7 @@ class UniqueAnswer extends Question
* @param the formvalidator instance
* @param the answers number to display
*/
function processAnswersCreation($form)
public function processAnswersCreation($form)
{
$questionWeighting = $nbrGoodAnswers = 0;
@ -396,7 +396,7 @@ class UniqueAnswer extends Question
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false)
public function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false)
{
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header .= '<table class="'.$this->question_table_class.'">
@ -427,7 +427,7 @@ class UniqueAnswer extends Question
* @assert (1,null,'a','',1,1,null) === false
* @assert (1,1,'','',1,1,null) === false
*/
function create_answer(
public function create_answer(
$id = 1,
$question_id,
$answer_title,

@ -45,7 +45,7 @@ class UniqueAnswerImage extends UniqueAnswer
function createAnswersForm($form)
{
// Getting the exercise list
$obj_ex = $_SESSION['objExercise'];
$obj_ex = $this->exercise;
$editor_config = array('ToolbarSet' => 'UniqueAnswerImage', 'Width' => '100%', 'Height' => '125');
@ -84,7 +84,7 @@ class UniqueAnswerImage extends UniqueAnswer
</th>
</tr>';
$form->addElement('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
$form->addElement('label', get_lang('Answers').'<br />'.Display::return_icon('fill_field.png'), $html);
$defaults = array();
$correct = 0;

@ -44,7 +44,7 @@ class UniqueAnswerNoOption extends Question
*/
function createAnswersForm ($form) {
// getting the exercise list
$obj_ex = $_SESSION['objExercise'];
$obj_ex = $this->exercise;
$editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125');
@ -88,7 +88,7 @@ class UniqueAnswerNoOption extends Question
'.get_lang('Weighting').'
</th>
</tr>';
$form->addElement('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
$form->addElement('label', get_lang('Answers').'<br />'.Display::return_icon('fill_field.png'), $html);
$defaults = array();
$correct = 0;

@ -775,7 +775,10 @@ class Database
strpos($query, 'c_id') === false &&
strpos($query, 'c_quiz_question_rel_category') === false &&
strpos($query, 'c_quiz_category') === false &&
strpos($query, 'c_quiz_rel_question') === false &&
strpos($query, 'c_quiz_answer') === false &&
strpos($query, 'c_quiz_question') === false &&
strpos($query, 'c_quiz_rel_question') === false &&
strpos($query, 'create table') === false &&
strpos($query, 'CREATE TABLE') === false &&
strpos($query, 'AUTO_INCREMENT') === false

Loading…
Cancel
Save