Minor - format code

pull/2487/head
jmontoyaa 9 years ago
parent da186f0311
commit e5aa87622d
  1. 35
      main/exercise/UniqueAnswerImage.php
  2. 1
      main/exercise/annotation_user.php
  3. 6
      main/exercise/calculated_answer.class.php
  4. 46
      main/exercise/fill_blanks.class.php
  5. 45
      main/exercise/global_multiple_answer.class.php
  6. 11
      main/exercise/live_stats.php
  7. 24
      main/exercise/multiple_answer.class.php
  8. 6
      main/exercise/multiple_answer_combination.class.php
  9. 10
      main/exercise/multiple_answer_true_false.class.php
  10. 2
      main/exercise/oral_expression.class.php
  11. 27
      main/exercise/unique_answer.class.php
  12. 43
      main/exercise/unique_answer_no_option.class.php

@ -30,7 +30,6 @@ class UniqueAnswerImage extends UniqueAnswer
public function createAnswersForm($form) public function createAnswersForm($form)
{ {
$objExercise = Session::read('objExercise'); $objExercise = Session::read('objExercise');
$editorConfig = array( $editorConfig = array(
'ToolbarSet' => 'TestFreeAnswer', 'ToolbarSet' => 'TestFreeAnswer',
'Width' => '100%', 'Width' => '100%',
@ -132,7 +131,8 @@ class UniqueAnswerImage extends UniqueAnswer
$defaults['answer['.$i.']'] = $answer->answer[$i]; $defaults['answer['.$i.']'] = $answer->answer[$i];
$defaults['comment['.$i.']'] = $answer->comment[$i]; $defaults['comment['.$i.']'] = $answer->comment[$i];
$defaults['weighting['.$i.']'] = float_format( $defaults['weighting['.$i.']'] = float_format(
$answer->weighting[$i], 1 $answer->weighting[$i],
1
); );
$itemList = explode('@@', $answer->destination[$i]); $itemList = explode('@@', $answer->destination[$i]);
@ -143,13 +143,11 @@ class UniqueAnswerImage extends UniqueAnswer
$url = $itemList[3]; $url = $itemList[3];
$try = 0; $try = 0;
if ($try != 0) { if ($try != 0) {
$tryResult = 1; $tryResult = 1;
} }
$urlResult = ''; $urlResult = '';
if ($url != 0) { if ($url != 0) {
$urlResult = $url; $urlResult = $url;
} }
@ -169,9 +167,7 @@ class UniqueAnswerImage extends UniqueAnswer
} }
$defaults['scenario'] = $tempScenario; $defaults['scenario'] = $tempScenario;
$renderer = $form->defaultRenderer(); $renderer = $form->defaultRenderer();
$renderer->setElementTemplate( $renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
'correct' 'correct'
@ -202,7 +198,13 @@ class UniqueAnswerImage extends UniqueAnswer
$form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
$form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editorConfig); $form->addHtmlEditor(
'comment['.$i.']',
null,
null,
false,
$editorConfig
);
// Direct feedback // Direct feedback
// Adding extra feedback fields // Adding extra feedback fields
$group = array(); $group = array();
@ -243,16 +245,13 @@ class UniqueAnswerImage extends UniqueAnswer
$form->addHtml('</tbody>'); $form->addHtml('</tbody>');
$form->addHtml('</table>'); $form->addHtml('</table>');
global $text, $class; global $text;
$buttonGroup = []; $buttonGroup = [];
if ($objExercise->edit_exercise_in_lp == true) { if ($objExercise->edit_exercise_in_lp == true) {
//setting the save button here and not in the question class.php //setting the save button here and not in the question class.php
$buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true); $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true);
$buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true); $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true);
$buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true); $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true);
$form->addGroup($buttonGroup); $form->addGroup($buttonGroup);
} }
@ -318,8 +317,7 @@ class UniqueAnswerImage extends UniqueAnswer
$destinationStr.=$destination_id.';'; $destinationStr.=$destination_id.';';
} */ } */
$goodAnswer = ($correct == $i) ? true : false; $goodAnswer = $correct == $i ? true : false;
if ($goodAnswer) { if ($goodAnswer) {
$nbrGoodAnswers++; $nbrGoodAnswers++;
$weighting = abs($weighting); $weighting = abs($weighting);
@ -348,7 +346,16 @@ class UniqueAnswerImage extends UniqueAnswer
//1@@1;2;@@2;4;4;@@http://www.chamilo.org //1@@1;2;@@2;4;4;@@http://www.chamilo.org
$dest = $try . '@@' . $lp . '@@' . $destination . '@@' . $url; $dest = $try . '@@' . $lp . '@@' . $destination . '@@' . $url;
$objAnswer->createAnswer($answer, $goodAnswer, $comment, $weighting, $i, null, null, $dest); $objAnswer->createAnswer(
$answer,
$goodAnswer,
$comment,
$weighting,
$i,
null,
null,
$dest
);
} }
// saves the answers into the data base // saves the answers into the data base

@ -54,7 +54,6 @@ if (!empty($attemptList) && isset($attemptList[$questionId])) {
$data['answers']['paths'][] = $points; $data['answers']['paths'][] = $points;
break; break;
case 'T': case 'T':
$text = [ $text = [
'text' => array_shift($parts) 'text' => array_shift($parts)
]; ];

@ -158,7 +158,11 @@ class CalculatedAnswer extends Question
$form->setDefaults(array('weighting' => '10')); $form->setDefaults(array('weighting' => '10'));
$form->addElement('text', 'answerVariations', get_lang('AnswerVariations')); $form->addElement('text', 'answerVariations', get_lang('AnswerVariations'));
$form->addRule('answerVariations', get_lang('GiveAnswerVariations'),'required'); $form->addRule(
'answerVariations',
get_lang('GiveAnswerVariations'),
'required'
);
$form->setDefaults(array('answerVariations' => '1')); $form->setDefaults(array('answerVariations' => '1'));
global $text; global $text;

@ -1165,8 +1165,14 @@ class FillBlanks extends Question
* @param bool $showTotalScoreAndUserChoices * @param bool $showTotalScoreAndUserChoices
* @return string * @return string
*/ */
public static function getHtmlAnswer($answer, $correct, $right, $feedbackType, $resultsDisabled = false, $showTotalScoreAndUserChoices = false) public static function getHtmlAnswer(
{ $answer,
$correct,
$right,
$feedbackType,
$resultsDisabled = false,
$showTotalScoreAndUserChoices = false
) {
$hideExpectedAnswer = false; $hideExpectedAnswer = false;
if ($feedbackType == 0 && ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ONLY)) { if ($feedbackType == 0 && ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ONLY)) {
$hideExpectedAnswer = true; $hideExpectedAnswer = true;
@ -1233,9 +1239,21 @@ class FillBlanks extends Question
* *
* @return string * @return string
*/ */
public static function getHtmlRightAnswer($answer, $correct, $feedbackType, $resultsDisabled = false, $showTotalScoreAndUserChoices = false) public static function getHtmlRightAnswer(
{ $answer,
return self::getHtmlAnswer($answer, $correct, true, $feedbackType, $resultsDisabled, $showTotalScoreAndUserChoices); $correct,
$feedbackType,
$resultsDisabled = false,
$showTotalScoreAndUserChoices = false
) {
return self::getHtmlAnswer(
$answer,
$correct,
true,
$feedbackType,
$resultsDisabled,
$showTotalScoreAndUserChoices
);
} }
/** /**
@ -1246,9 +1264,21 @@ class FillBlanks extends Question
* *
* @return string * @return string
*/ */
public static function getHtmlWrongAnswer($answer, $correct, $feedbackType, $resultsDisabled = false, $showTotalScoreAndUserChoices = false) public static function getHtmlWrongAnswer(
{ $answer,
return self::getHtmlAnswer($answer, $correct, false, $feedbackType, $resultsDisabled, $showTotalScoreAndUserChoices); $correct,
$feedbackType,
$resultsDisabled = false,
$showTotalScoreAndUserChoices = false
) {
return self::getHtmlAnswer(
$answer,
$correct,
false,
$feedbackType,
$resultsDisabled,
$showTotalScoreAndUserChoices
);
} }
/** /**

@ -12,7 +12,7 @@ class GlobalMultipleAnswer extends Question
public static $explanationLangVar = 'GlobalMultipleAnswer'; public static $explanationLangVar = 'GlobalMultipleAnswer';
/** /**
* * GlobalMultipleAnswer constructor.
*/ */
public function __construct() public function __construct()
{ {
@ -107,26 +107,51 @@ class GlobalMultipleAnswer extends Question
$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>', '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>', 'weighting['.$i.']');
$answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"'); $answer_number = $form->addElement(
'text',
'counter['.$i.']',
null,
'value="'.$i.'"'
);
$answer_number->freeze(); $answer_number->freeze();
$form->addElement('checkbox', 'correct[' . $i . ']', null, null, 'class="checkbox"'); $form->addElement('checkbox', 'correct[' . $i . ']', null, null, 'class="checkbox"');
$boxes_names[] = 'correct[' . $i . ']'; $boxes_names[] = 'correct[' . $i . ']';
$form->addElement('html_editor', 'answer[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')); $form->addElement(
'html_editor',
'answer['.$i.']',
null,
array(),
array(
'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%',
'Height' => '100',
)
);
$form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement(
$form->addElement('html_editor', 'comment[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')); 'html_editor',
'comment['.$i.']',
null,
array(),
array(
'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%',
'Height' => '100',
)
);
$form->addElement('html', '</tr>'); $form->addElement('html', '</tr>');
} }
//--------- Mise en variable du score global lors d'une modification de la question/r<EFBFBD>ponse //--------- Mise en variable du score global lors d'une modification de la question/r<EFBFBD>ponse
$defaults['weighting[1]'] = (round($scoreG)); $defaults['weighting[1]'] = (round($scoreG));
$form->addElement('html', '</div></div></table>'); $form->addElement('html', '</div></div></table>');
$form->add_multiple_required_rule(
//$form -> addElement ('html', '<br />'); $boxes_names,
$form->add_multiple_required_rule($boxes_names, get_lang('ChooseAtLeastOneCheckbox'), 'multiple_required'); get_lang('ChooseAtLeastOneCheckbox'),
'multiple_required'
);
//only 1 answer the all deal ... //only 1 answer the all deal ...
$form->addElement('text', 'weighting[1]', get_lang('Score')); $form->addElement('text', 'weighting[1]', get_lang('Score'));
@ -138,7 +163,7 @@ class GlobalMultipleAnswer extends Question
// Affiche un message si le score n'est pas renseign<EFBFBD> // Affiche un message si le score n'est pas renseign<EFBFBD>
$form->addRule('weighting[1]', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('weighting[1]', get_lang('ThisFieldIsRequired'), 'required');
global $text, $class; global $text;
if ($obj_ex->edit_exercise_in_lp == true) { if ($obj_ex->edit_exercise_in_lp == true) {
$form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers'); $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers');

@ -93,7 +93,16 @@ function refreshGrid() {
$(function() { $(function() {
<?php <?php
echo Display::grid_js('live_stats', $url, $columns, $column_model, $extra_params, array(), null, true); echo Display::grid_js(
'live_stats',
$url,
$columns,
$column_model,
$extra_params,
array(),
null,
true
);
?> ?>
refreshGrid(); refreshGrid();
}); });

@ -123,8 +123,13 @@ class MultipleAnswer extends Question
$answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"'); $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
$answer_number->freeze(); $answer_number->freeze();
$form->addElement('checkbox', 'correct[' . $i . ']', null, null, $form->addElement(
'class="checkbox" style="margin-left: 0em;"'); 'checkbox',
'correct['.$i.']',
null,
null,
'class="checkbox" style="margin-left: 0em;"'
);
$boxes_names[] = 'correct['.$i.']'; $boxes_names[] = 'correct['.$i.']';
$form->addHtmlEditor("answer[$i]", null, null, true, $editorConfig); $form->addHtmlEditor("answer[$i]", null, null, true, $editorConfig);
@ -139,10 +144,13 @@ class MultipleAnswer extends Question
$form->addHtml('</tbody>'); $form->addHtml('</tbody>');
$form->addHtml('</table>'); $form->addHtml('</table>');
$form->add_multiple_required_rule($boxes_names, get_lang('ChooseAtLeastOneCheckbox'), 'multiple_required'); $form->add_multiple_required_rule(
$boxes_names,
get_lang('ChooseAtLeastOneCheckbox'),
'multiple_required'
);
$buttonGroup = []; $buttonGroup = [];
global $text; global $text;
if ($obj_ex->edit_exercise_in_lp == true) { if ($obj_ex->edit_exercise_in_lp == true) {
// setting the save button here and not in the question class.php // setting the save button here and not in the question class.php
@ -192,7 +200,13 @@ class MultipleAnswer extends Question
if ($weighting > 0) { if ($weighting > 0) {
$questionWeighting += $weighting; $questionWeighting += $weighting;
} }
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i); $objAnswer->createAnswer(
$answer,
$goodAnswer,
$comment,
$weighting,
$i
);
} }
// saves the answers into the data base // saves the answers into the data base

@ -112,7 +112,8 @@ class MultipleAnswerCombination extends Question
$answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"'); $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
$answer_number->freeze(); $answer_number->freeze();
$form->addElement('checkbox', $form->addElement(
'checkbox',
'correct['.$i.']', 'correct['.$i.']',
null, null,
null, null,
@ -141,7 +142,6 @@ class MultipleAnswerCombination extends Question
} }
$form->addElement('html', '</tbody></table>'); $form->addElement('html', '</tbody></table>');
$form->add_multiple_required_rule( $form->add_multiple_required_rule(
$boxes_names, $boxes_names,
get_lang('ChooseAtLeastOneCheckbox'), get_lang('ChooseAtLeastOneCheckbox'),
@ -152,9 +152,7 @@ class MultipleAnswerCombination extends Question
$form->addText('weighting[1]', get_lang('Score'), false, ['value' => 10]); $form->addText('weighting[1]', get_lang('Score'), false, ['value' => 10]);
global $text; global $text;
//ie6 fix
if ($obj_ex->edit_exercise_in_lp == true) { if ($obj_ex->edit_exercise_in_lp == true) {
// setting the save button here and not in the question class.php // setting the save button here and not in the question class.php
$buttonGroup = [ $buttonGroup = [
$form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true), $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true),

@ -75,8 +75,6 @@ class MultipleAnswerTrueFalse extends Question
} }
$form->addElement('hidden', 'nb_answers'); $form->addElement('hidden', 'nb_answers');
$boxes_names = array();
if ($nb_answers < 1) { if ($nb_answers < 1) {
$nb_answers = 1; $nb_answers = 1;
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer')); Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
@ -139,8 +137,6 @@ class MultipleAnswerTrueFalse extends Question
$defaults['correct[' . $i . ']'] = ''; $defaults['correct[' . $i . ']'] = '';
} }
$boxes_names[] = 'correct[' . $i . ']';
$form->addHtmlEditor( $form->addHtmlEditor(
"answer[$i]", "answer[$i]",
get_lang('ThisFieldIsRequired'), get_lang('ThisFieldIsRequired'),
@ -221,7 +217,6 @@ class MultipleAnswerTrueFalse extends Question
} }
global $text; global $text;
if ($obj_ex->edit_exercise_in_lp == true) { if ($obj_ex->edit_exercise_in_lp == true) {
// setting the save button here and not in the question class.php // setting the save button here and not in the question class.php
$buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true); $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true);
@ -234,9 +229,7 @@ class MultipleAnswerTrueFalse extends Question
if (!empty($this->id)) { if (!empty($this->id)) {
$form->setDefaults($defaults); $form->setDefaults($defaults);
} else { } else {
//if ($this -> isContent == 1) {
$form->setDefaults($defaults); $form->setDefaults($defaults);
//}
} }
$form->setConstants(array('nb_answers' => $nb_answers)); $form->setConstants(array('nb_answers' => $nb_answers));
} }
@ -278,7 +271,6 @@ class MultipleAnswerTrueFalse extends Question
it's possible that there are more options in the future */ it's possible that there are more options in the future */
$new_options = Question::readQuestionOption($this->id, $course_id); $new_options = Question::readQuestionOption($this->id, $course_id);
$sorted_by_position = array(); $sorted_by_position = array();
foreach ($new_options as $item) { foreach ($new_options as $item) {
$sorted_by_position[$item['position']] = $item; $sorted_by_position[$item['position']] = $item;
@ -304,13 +296,11 @@ class MultipleAnswerTrueFalse extends Question
$goodAnswer = $sorted_by_position[$goodAnswer]['id']; $goodAnswer = $sorted_by_position[$goodAnswer]['id'];
} }
$questionWeighting += $extra_values[0]; //By default 0 has the correct answers $questionWeighting += $extra_values[0]; //By default 0 has the correct answers
$objAnswer->createAnswer($answer, $goodAnswer, $comment, '', $i); $objAnswer->createAnswer($answer, $goodAnswer, $comment, '', $i);
} }
// saves the answers into the database // saves the answers into the database
$objAnswer->save(); $objAnswer->save();
// sets the total weighting of the question // sets the total weighting of the question
$this->updateWeighting($questionWeighting); $this->updateWeighting($questionWeighting);
$this->save(); $this->save();

@ -42,7 +42,7 @@ class OralExpression extends Question
get_lang('Weighting'), get_lang('Weighting'),
array('class' => 'span1') array('class' => 'span1')
); );
global $text, $class; global $text;
// setting the save button here and not in the question class.php // setting the save button here and not in the question class.php
$form->addButtonSave($text, 'submitQuestion'); $form->addButtonSave($text, 'submitQuestion');
if (!empty($this->id)) { if (!empty($this->id)) {

@ -198,21 +198,37 @@ class UniqueAnswer extends Question
); );
$answer_number = $form->addElement( $answer_number = $form->addElement(
'text', 'counter[' . $i . ']', null, ' value = "' . $i . '"' 'text',
'counter['.$i.']',
null,
' value = "'.$i.'"'
); );
$answer_number->freeze(); $answer_number->freeze();
$form->addElement( $form->addElement(
'radio', 'correct', null, null, $i, 'class="checkbox"' 'radio',
'correct',
null,
null,
$i,
'class="checkbox"'
); );
$form->addHtmlEditor('answer[' . $i . ']', null, null, true, $editor_config); $form->addHtmlEditor('answer[' . $i . ']', null, null, true, $editor_config);
$form->addRule( $form->addRule(
'answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required' 'answer['.$i.']',
get_lang('ThisFieldIsRequired'),
'required'
); );
if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
$form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editor_config); $form->addHtmlEditor(
'comment['.$i.']',
null,
null,
false,
$editor_config
);
// Direct feedback // Direct feedback
//Adding extra feedback fields //Adding extra feedback fields
$group = array(); $group = array();
@ -260,16 +276,13 @@ class UniqueAnswer extends Question
$form->addHtml('</table>'); $form->addHtml('</table>');
global $text; global $text;
$buttonGroup = []; $buttonGroup = [];
//ie6 fix //ie6 fix
if ($obj_ex->edit_exercise_in_lp == true) { if ($obj_ex->edit_exercise_in_lp == true) {
//setting the save button here and not in the question class.php //setting the save button here and not in the question class.php
$buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true); $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true);
$buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true); $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true);
$buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true); $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true);
$form->addGroup($buttonGroup); $form->addGroup($buttonGroup);
} }

@ -49,7 +49,6 @@ class UniqueAnswerNoOption extends Question
$feedback_title = ''; $feedback_title = '';
$comment_title = ''; $comment_title = '';
if ($obj_ex->selectFeedbackType() == 1) { if ($obj_ex->selectFeedbackType() == 1) {
$editor_config['Width'] = '250'; $editor_config['Width'] = '250';
$editor_config['Height'] = '110'; $editor_config['Height'] = '110';
@ -86,7 +85,6 @@ class UniqueAnswerNoOption extends Question
} }
$temp_scenario = array(); $temp_scenario = array();
if ($nb_answers < 1) { if ($nb_answers < 1) {
$nb_answers = 1; $nb_answers = 1;
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer')); Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
@ -119,7 +117,6 @@ class UniqueAnswerNoOption extends Question
foreach ($new_list as $key) { foreach ($new_list as $key) {
$i = $key; $i = $key;
$form->addElement('html', '<tr>'); $form->addElement('html', '<tr>');
if (is_object($answer)) { if (is_object($answer)) {
if ($answer->position[$i] == 666) { if ($answer->position[$i] == 666) {
//we set nothing //we set nothing
@ -144,15 +141,17 @@ class UniqueAnswerNoOption extends Question
$list_dest = $item_list[2]; $list_dest = $item_list[2];
$url = $item_list[3]; $url = $item_list[3];
if ($try == 0) if ($try == 0) {
$try_result = 0; $try_result = 0;
else } else {
$try_result = 1; $try_result = 1;
}
if ($url == 0) if ($url == 0) {
$url_result = ''; $url_result = '';
else } else {
$url_result = $url; $url_result = $url;
}
$temp_scenario['url' . $i] = $url_result; $temp_scenario['url' . $i] = $url_result;
$temp_scenario['try' . $i] = $try_result; $temp_scenario['try' . $i] = $try_result;
@ -257,7 +256,7 @@ class UniqueAnswerNoOption extends Question
$buttonGroup = []; $buttonGroup = [];
global $text, $class; global $text;
//ie6 fix //ie6 fix
if ($obj_ex->edit_exercise_in_lp == true) { if ($obj_ex->edit_exercise_in_lp == true) {
//setting the save button here and not in the question class.php //setting the save button here and not in the question class.php
@ -345,8 +344,9 @@ class UniqueAnswerNoOption extends Question
} }
} }
if (empty($try)) if (empty($try)) {
$try = 0; $try = 0;
}
if (empty($lp)) { if (empty($lp)) {
$lp = 0; $lp = 0;
@ -362,7 +362,16 @@ class UniqueAnswerNoOption extends Question
//1@@1;2;@@2;4;4;@@http://www.chamilo.org //1@@1;2;@@2;4;4;@@http://www.chamilo.org
$dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url; $dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest); $objAnswer->createAnswer(
$answer,
$goodAnswer,
$comment,
$weighting,
$i,
null,
null,
$dest
);
} }
//Create 666 answer //Create 666 answer
@ -370,10 +379,19 @@ class UniqueAnswerNoOption extends Question
$answer = trim($form->getSubmitValue('answer['.$i.']')); $answer = trim($form->getSubmitValue('answer['.$i.']'));
$comment = trim($form->getSubmitValue('comment['.$i.']')); $comment = trim($form->getSubmitValue('comment['.$i.']'));
$weighting = trim($form->getSubmitValue('weighting['.$i.']')); $weighting = trim($form->getSubmitValue('weighting['.$i.']'));
$goodAnswer= ($correct == $i) ? true : false; $goodAnswer = $correct == $i ? true : false;
$dest = ''; $dest = '';
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest); $objAnswer->createAnswer(
$answer,
$goodAnswer,
$comment,
$weighting,
$i,
null,
null,
$dest
);
// saves the answers into the data base // saves the answers into the data base
$objAnswer->save(); $objAnswer->save();
@ -393,6 +411,7 @@ class UniqueAnswerNoOption extends Question
<th>'. get_lang("Answer").'</th>'; <th>'. get_lang("Answer").'</th>';
$header .= '<th>'.get_lang("Comment").'</th>'; $header .= '<th>'.get_lang("Comment").'</th>';
$header .= '</tr>'; $header .= '</tr>';
return $header; return $header;
} }
} }

Loading…
Cancel
Save