|
@@ -11,8 +11,6 @@
|
|
|
* Code
|
|
|
*/
|
|
|
|
|
|
-if(!class_exists('UniqueAnswerNoOption')):
|
|
|
-
|
|
|
|
|
|
CLASS UNIQUE_ANSWER
|
|
|
*
|
|
@@ -24,8 +22,8 @@ if(!class_exists('UniqueAnswerNoOption')):
|
|
|
* @package chamilo.exercise
|
|
|
**/
|
|
|
|
|
|
-class UniqueAnswerNoOption extends Question {
|
|
|
-
|
|
|
+class UniqueAnswerNoOption extends Question
|
|
|
+{
|
|
|
static $typePicture = 'mcuao.gif';
|
|
|
static $explanationLangVar = 'UniqueAnswerNoOption';
|
|
|
|
|
@@ -52,7 +50,7 @@ class UniqueAnswerNoOption extends Question {
|
|
|
|
|
|
|
|
|
$nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 3;
|
|
|
- $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
|
|
|
+ $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
|
|
|
|
|
|
|
|
|
Types of Feedback
|
|
@@ -89,32 +87,32 @@ class UniqueAnswerNoOption extends Question {
|
|
|
'.$feedback_title.'
|
|
|
<th width="60px">
|
|
|
'.get_lang('Weighting').'
|
|
|
- </th>
|
|
|
+ </th>
|
|
|
</tr>';
|
|
|
$form -> addElement ('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
|
|
|
|
|
|
$defaults = array();
|
|
|
$correct = 0;
|
|
|
-
|
|
|
+
|
|
|
if (!empty($this -> id)) {
|
|
|
$answer = new Answer($this -> id);
|
|
|
$answer -> read();
|
|
|
if (count($answer->nbrAnswers)>0 && !$form->isSubmitted()) {
|
|
|
- $nb_answers = $answer->nbrAnswers;
|
|
|
+ $nb_answers = $answer->nbrAnswers;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$temp_scenario = array();
|
|
|
-
|
|
|
+
|
|
|
if ($nb_answers < 1) {
|
|
|
$nb_answers = 1;
|
|
|
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
|
|
|
- }
|
|
|
+ }
|
|
|
if ($_GET['editQuestion']) {
|
|
|
-
|
|
|
+
|
|
|
|
|
|
$new_list = array();
|
|
|
- $count = 1;
|
|
|
+ $count = 1;
|
|
|
if (isset($_POST['lessAnswers'])) {
|
|
|
if (!isset($_SESSION['less_answer'])) {
|
|
|
$_SESSION['less_answer'] = $this -> id;
|
|
@@ -122,106 +120,106 @@ class UniqueAnswerNoOption extends Question {
|
|
|
}
|
|
|
}
|
|
|
for ($k = 1 ; $k <= $nb_answers; ++$k) {
|
|
|
- if ($answer->position[$k] != '666') {
|
|
|
+ if ($answer->position[$k] != '666') {
|
|
|
$new_list[$count] = $count;
|
|
|
$count++;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
} else {
|
|
|
- for ($k = 1 ; $k <= $nb_answers; ++$k) {
|
|
|
- $new_list[$k] = $k;
|
|
|
- }
|
|
|
+ for ($k = 1 ; $k <= $nb_answers; ++$k) {
|
|
|
+ $new_list[$k] = $k;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$i = 1;
|
|
|
-
|
|
|
+
|
|
|
foreach ($new_list as $key) {
|
|
|
- $i = $key;
|
|
|
- $form -> addElement ('html', '<tr>');
|
|
|
-
|
|
|
+ $i = $key;
|
|
|
+ $form -> addElement ('html', '<tr>');
|
|
|
+
|
|
|
if (is_object($answer)) {
|
|
|
if($answer->position[$i] == 666) {
|
|
|
-
|
|
|
- } else {
|
|
|
+
|
|
|
+ } else {
|
|
|
if ($answer->correct[$i]) {
|
|
|
$correct = $i;
|
|
|
}
|
|
|
- $answer_result = $answer->answer[$i];
|
|
|
+ $answer_result = $answer->answer[$i];
|
|
|
$weight_result = float_format($answer->weighting[$i], 1);
|
|
|
if ($nb_answers == $i) {
|
|
|
$weight_result = '0';
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$defaults['answer['.$i.']'] = $answer_result;
|
|
|
$defaults['comment['.$i.']'] = $answer->comment[$i];
|
|
|
$defaults['weighting['.$i.']'] = $weight_result;
|
|
|
-
|
|
|
+
|
|
|
$item_list=explode('@@',$answer -> destination[$i]);
|
|
|
-
|
|
|
+
|
|
|
$try = $item_list[0];
|
|
|
$lp = $item_list[1];
|
|
|
$list_dest = $item_list[2];
|
|
|
$url = $item_list[3];
|
|
|
-
|
|
|
+
|
|
|
if ($try==0)
|
|
|
$try_result=0;
|
|
|
else
|
|
|
$try_result=1;
|
|
|
-
|
|
|
+
|
|
|
if ($url==0)
|
|
|
$url_result='';
|
|
|
else
|
|
|
$url_result=$url;
|
|
|
-
|
|
|
+
|
|
|
$temp_scenario['url'.$i] = $url_result;
|
|
|
$temp_scenario['try'.$i] = $try_result;
|
|
|
$temp_scenario['lp'.$i] = $lp;
|
|
|
$temp_scenario['destination'.$i]= $list_dest;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$defaults['scenario']=$temp_scenario;
|
|
|
$renderer = & $form->defaultRenderer();
|
|
|
-
|
|
|
- $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct');
|
|
|
- $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter['.$i.']');
|
|
|
- $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer['.$i.']');
|
|
|
- $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment['.$i.']');
|
|
|
- $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'weighting['.$i.']');
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct');
|
|
|
+ $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter['.$i.']');
|
|
|
+ $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer['.$i.']');
|
|
|
+ $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment['.$i.']');
|
|
|
+ $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'weighting['.$i.']');
|
|
|
+
|
|
|
+
|
|
|
$answer_number=$form->addElement('text', 'counter['.$i.']', null,'value="'.$i.'"');
|
|
|
$answer_number->freeze();
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
$form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"');
|
|
|
$form->addElement('html_editor', 'answer['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
|
|
|
-
|
|
|
+
|
|
|
$form->addElement('html_editor', 'comment['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
|
|
|
$form->addElement('text', 'weighting['.$i.']', null, array('class' => "span1", 'value' => '0'));
|
|
|
$form->addElement('html', '</tr>');
|
|
|
- $i++;
|
|
|
- }
|
|
|
-
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+
|
|
|
if (empty($this -> id)) {
|
|
|
$form->addElement('hidden', 'new_question', 1);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
- $i = 666;
|
|
|
- $form -> addElement ('html', '<tr>');
|
|
|
+ $i = 666;
|
|
|
+ $form -> addElement ('html', '<tr>');
|
|
|
|
|
|
$defaults['answer['.$i.']'] = get_lang('DontKnow');
|
|
|
$defaults['weighting['.$i.']'] = 0;
|
|
|
$defaults['scenario']=$temp_scenario;
|
|
|
$renderer = & $form->defaultRenderer();
|
|
|
|
|
|
- $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct');
|
|
|
- $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter['.$i.']');
|
|
|
- $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer['.$i.']');
|
|
|
- $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment['.$i.']');
|
|
|
- $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'weighting['.$i.']');
|
|
|
+ $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct');
|
|
|
+ $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter['.$i.']');
|
|
|
+ $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer['.$i.']');
|
|
|
+ $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment['.$i.']');
|
|
|
+ $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'weighting['.$i.']');
|
|
|
|
|
|
$answer_number=$form->addElement('text', 'counter['.$i.']',null,'value="-"');
|
|
|
$answer_number->freeze();
|
|
@@ -241,9 +239,7 @@ class UniqueAnswerNoOption extends Question {
|
|
|
$form->addElement('text', 'weighting['.$i.']', null, array('class' => "span1", 'value' => '0', 'readonly' =>'readonly'));
|
|
|
$form->addElement ('html', '</tr>');
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
$form -> addElement ('html', '</table>');
|
|
|
$form -> addElement ('html', '<br />');
|
|
|
$navigator_info = api_get_navigator();
|
|
@@ -251,15 +247,15 @@ class UniqueAnswerNoOption extends Question {
|
|
|
global $text, $class;
|
|
|
|
|
|
if ($obj_ex->edit_exercise_in_lp == true) {
|
|
|
- if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') {
|
|
|
- $form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'),'class="btn plus"');
|
|
|
+ if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') {
|
|
|
+ $form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'),'class="btn plus"');
|
|
|
$form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'),'class="btn minus"');
|
|
|
$form->addElement('submit','submitQuestion',$text, 'class="'.$class.'"');
|
|
|
} else {
|
|
|
-
|
|
|
+
|
|
|
$form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'),'class="btn minus"');
|
|
|
$form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'),'class="btn plus"');
|
|
|
- $form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
|
|
|
+ $form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
|
|
|
}
|
|
|
}
|
|
|
$renderer->setElementTemplate('{element} ','submitQuestion');
|
|
@@ -278,13 +274,13 @@ class UniqueAnswerNoOption extends Question {
|
|
|
$form -> setDefaults($defaults);
|
|
|
} else {
|
|
|
$form -> setDefaults($defaults);
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
$form->addElement('hidden', 'nb_answers');
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
$form->setConstants(array('nb_answers' => $nb_answers));
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -301,19 +297,19 @@ class UniqueAnswerNoOption extends Question {
|
|
|
$nb_answers = $form -> getSubmitValue('nb_answers');
|
|
|
$minus = 1;
|
|
|
if ($form -> getSubmitValue('new_question')) {
|
|
|
- $minus = 0;
|
|
|
- }
|
|
|
-
|
|
|
+ $minus = 0;
|
|
|
+ }
|
|
|
+
|
|
|
for ($i=1 ; $i <= $nb_answers - $minus; $i++) {
|
|
|
$position = trim($form -> getSubmitValue('position['.$i.']'));
|
|
|
$answer = trim($form -> getSubmitValue('answer['.$i.']'));
|
|
|
$comment = trim($form -> getSubmitValue('comment['.$i.']'));
|
|
|
$weighting = trim($form -> getSubmitValue('weighting['.$i.']'));
|
|
|
$scenario = $form -> getSubmitValue('scenario');
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -362,7 +358,7 @@ class UniqueAnswerNoOption extends Question {
|
|
|
if (empty($destination)) {
|
|
|
$destination=0;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if ($url=='') {
|
|
|
$url=0;
|
|
|
}
|
|
@@ -371,17 +367,17 @@ class UniqueAnswerNoOption extends Question {
|
|
|
$dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
|
|
|
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
$i = 666;
|
|
|
$answer = trim($form -> getSubmitValue('answer['.$i.']'));
|
|
|
$comment = trim($form -> getSubmitValue('comment['.$i.']'));
|
|
|
$weighting = trim($form -> getSubmitValue('weighting['.$i.']'));
|
|
|
$goodAnswer= ($correct == $i) ? true : false;
|
|
|
- $dest = '';
|
|
|
-
|
|
|
+ $dest = '';
|
|
|
+
|
|
|
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest);
|
|
|
-
|
|
|
+
|
|
|
|
|
|
$objAnswer -> save();
|
|
|
|
|
@@ -389,17 +385,16 @@ class UniqueAnswerNoOption extends Question {
|
|
|
$this -> updateWeighting($questionWeighting);
|
|
|
$this -> save();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function return_header($feedback_type = null, $counter = null, $score = null) {
|
|
|
$header = parent::return_header($feedback_type, $counter, $score);
|
|
|
- $header .= '<table class="'.$this->question_table_class .'">
|
|
|
+ $header .= '<table class="'.$this->question_table_class .'">
|
|
|
<tr>
|
|
|
<th>'.get_lang("Choice").'</th>
|
|
|
<th>'. get_lang("ExpectedChoice").'</th>
|
|
|
<th>'. get_lang("Answer").'</th>';
|
|
|
$header .= '<th>'.get_lang("Comment").'</th>';
|
|
|
$header .= '</tr>';
|
|
|
- return $header;
|
|
|
+ return $header;
|
|
|
}
|
|
|
}
|
|
|
-endif;
|