Minor - format code

pull/2487/head
jmontoyaa 9 years ago
parent da186f0311
commit e5aa87622d
  1. 43
      main/exercise/UniqueAnswerImage.php
  2. 1
      main/exercise/annotation_user.php
  3. 10
      main/exercise/calculated_answer.class.php
  4. 58
      main/exercise/fill_blanks.class.php
  5. 45
      main/exercise/global_multiple_answer.class.php
  6. 4
      main/exercise/hotpotatoes_exercise_result.class.php
  7. 11
      main/exercise/live_stats.php
  8. 30
      main/exercise/multiple_answer.class.php
  9. 10
      main/exercise/multiple_answer_combination.class.php
  10. 10
      main/exercise/multiple_answer_combination_true_false.class.php
  11. 46
      main/exercise/multiple_answer_true_false.class.php
  12. 6
      main/exercise/oral_expression.class.php
  13. 31
      main/exercise/unique_answer.class.php
  14. 189
      main/exercise/unique_answer_no_option.class.php

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

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

@ -158,7 +158,11 @@ class CalculatedAnswer extends Question
$form->setDefaults(array('weighting' => '10'));
$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'));
global $text;
@ -199,12 +203,12 @@ class CalculatedAnswer extends Question
$this->weighting = $form->getSubmitValue('weighting');
// Create as many answers as $answerVariations
for ($j=0 ; $j < $answerVariations; $j++) {
for ($j = 0; $j < $answerVariations; $j++) {
$auxAnswer = $answer;
$auxFormula = $formula;
$nb = preg_match_all('/\[[^\]]*\]/', $auxAnswer, $blanks);
if ($nb > 0) {
for ($i=0 ; $i < $nb; ++$i) {
for ($i = 0; $i < $nb; ++$i) {
$blankItem = $blanks[0][$i];
$replace = array("[", "]");
$newBlankItem = str_replace($replace, "", $blankItem);

@ -2,11 +2,11 @@
/* For licensing terms, see /license.txt */
/**
* Class FillBlanks
* Class FillBlanks
*
* @author Eric Marguin
* @author Julio Montoya multiple fill in blank option added
* @package chamilo.exercise
* @author Eric Marguin
* @author Julio Montoya multiple fill in blank option added
* @package chamilo.exercise
**/
class FillBlanks extends Question
{
@ -430,7 +430,7 @@ class FillBlanks extends Question
// input width
$answer .= ":";
for ($i=0; $i < $nb; ++$i) {
for ($i = 0; $i < $nb; ++$i) {
// enter the width of input for word $i
$answer .= $form->getSubmitValue('sizeofinput['.$i.']');
// not the last word, add ","
@ -1165,8 +1165,14 @@ class FillBlanks extends Question
* @param bool $showTotalScoreAndUserChoices
* @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;
if ($feedbackType == 0 && ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ONLY)) {
$hideExpectedAnswer = true;
@ -1191,7 +1197,7 @@ class FillBlanks extends Question
$listPossibleAnswers = self::getFillTheBlankMenuAnswers($correct, false);
$correctAnswerHtml .= "<span style='color: green'>".$listPossibleAnswers[0]."</span>";
$correctAnswerHtml .= " <span style='font-weight:normal'>(";
for ($i=1; $i < count($listPossibleAnswers); $i++) {
for ($i = 1; $i < count($listPossibleAnswers); $i++) {
$correctAnswerHtml .= $listPossibleAnswers[$i];
if ($i != count($listPossibleAnswers) - 1) {
$correctAnswerHtml .= " | ";
@ -1233,9 +1239,21 @@ class FillBlanks extends Question
*
* @return string
*/
public static function getHtmlRightAnswer($answer, $correct, $feedbackType, $resultsDisabled = false, $showTotalScoreAndUserChoices = false)
{
return self::getHtmlAnswer($answer, $correct, true, $feedbackType, $resultsDisabled, $showTotalScoreAndUserChoices);
public static function getHtmlRightAnswer(
$answer,
$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
*/
public static function getHtmlWrongAnswer($answer, $correct, $feedbackType, $resultsDisabled = false, $showTotalScoreAndUserChoices = false)
{
return self::getHtmlAnswer($answer, $correct, false, $feedbackType, $resultsDisabled, $showTotalScoreAndUserChoices);
public static function getHtmlWrongAnswer(
$answer,
$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';
/**
*
* GlobalMultipleAnswer constructor.
*/
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>', '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();
$form->addElement('checkbox', 'correct[' . $i . ']', null, null, 'class="checkbox"');
$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->addElement('html_editor', 'comment[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
$form->addElement(
'html_editor',
'comment['.$i.']',
null,
array(),
array(
'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%',
'Height' => '100',
)
);
$form->addElement('html', '</tr>');
}
//--------- Mise en variable du score global lors d'une modification de la question/r<EFBFBD>ponse
$defaults['weighting[1]'] = (round($scoreG));
$form->addElement('html', '</div></div></table>');
//$form -> addElement ('html', '<br />');
$form->add_multiple_required_rule($boxes_names, get_lang('ChooseAtLeastOneCheckbox'), 'multiple_required');
$form->add_multiple_required_rule(
$boxes_names,
get_lang('ChooseAtLeastOneCheckbox'),
'multiple_required'
);
//only 1 answer the all deal ...
$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>
$form->addRule('weighting[1]', get_lang('ThisFieldIsRequired'), 'required');
global $text, $class;
global $text;
if ($obj_ex->edit_exercise_in_lp == true) {
$form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers');

@ -26,8 +26,8 @@ class HotpotatoesExerciseResult
$TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
$TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
$cid = api_get_course_id();
$course_id = api_get_course_int_id();
$cid = api_get_course_id();
$course_id = api_get_course_int_id();
//$user_id = intval($user_id);
$user_id = null;
$session_id_and = ' AND te.session_id = ' . api_get_session_id() . ' ';

@ -93,7 +93,16 @@ function refreshGrid() {
$(function() {
<?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();
});

@ -123,9 +123,14 @@ class MultipleAnswer extends Question
$answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
$answer_number->freeze();
$form->addElement('checkbox', 'correct[' . $i . ']', null, null,
'class="checkbox" style="margin-left: 0em;"');
$boxes_names[] = 'correct[' . $i . ']';
$form->addElement(
'checkbox',
'correct['.$i.']',
null,
null,
'class="checkbox" style="margin-left: 0em;"'
);
$boxes_names[] = 'correct['.$i.']';
$form->addHtmlEditor("answer[$i]", null, null, true, $editorConfig);
$form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
@ -139,10 +144,13 @@ class MultipleAnswer extends Question
$form->addHtml('</tbody>');
$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 = [];
global $text;
if ($obj_ex->edit_exercise_in_lp == true) {
// setting the save button here and not in the question class.php
@ -177,7 +185,7 @@ class MultipleAnswer extends Question
$objAnswer = new Answer($this->id);
$nb_answers = $form->getSubmitValue('nb_answers');
for($i=1 ; $i <= $nb_answers ; $i++) {
for ($i = 1; $i <= $nb_answers; $i++) {
$answer = trim(str_replace(['<p>', '</p>'], '', $form -> getSubmitValue('answer['.$i.']')));
$comment = trim(str_replace(['<p>', '</p>'], '', $form -> getSubmitValue('comment['.$i.']')));
$weighting = trim($form -> getSubmitValue('weighting['.$i.']'));
@ -189,10 +197,16 @@ class MultipleAnswer extends Question
$weighting = abs($weighting);
$weighting = -$weighting;
}
if($weighting > 0) {
if ($weighting > 0) {
$questionWeighting += $weighting;
}
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i);
$objAnswer->createAnswer(
$answer,
$goodAnswer,
$comment,
$weighting,
$i
);
}
// saves the answers into the data base

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

@ -2,13 +2,13 @@
/* For licensing terms, see /license.txt */
/**
* Class MultipleAnswerCombinationTrueFalse
* Class MultipleAnswerCombinationTrueFalse
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
* extending the class question
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
* extending the class question
*
* @author Eric Marguin
* @package chamilo.exercise
* @author Eric Marguin
* @package chamilo.exercise
**/
class MultipleAnswerCombinationTrueFalse extends MultipleAnswerCombination
{

@ -75,8 +75,6 @@ class MultipleAnswerTrueFalse extends Question
}
$form->addElement('hidden', 'nb_answers');
$boxes_names = array();
if ($nb_answers < 1) {
$nb_answers = 1;
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
@ -139,8 +137,6 @@ class MultipleAnswerTrueFalse extends Question
$defaults['correct[' . $i . ']'] = '';
}
$boxes_names[] = 'correct[' . $i . ']';
$form->addHtmlEditor(
"answer[$i]",
get_lang('ThisFieldIsRequired'),
@ -221,7 +217,6 @@ class MultipleAnswerTrueFalse extends Question
}
global $text;
if ($obj_ex->edit_exercise_in_lp == true) {
// setting the save button here and not in the question class.php
$buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true);
@ -234,9 +229,7 @@ class MultipleAnswerTrueFalse extends Question
if (!empty($this->id)) {
$form->setDefaults($defaults);
} else {
//if ($this -> isContent == 1) {
$form->setDefaults($defaults);
//}
}
$form->setConstants(array('nb_answers' => $nb_answers));
}
@ -263,14 +256,14 @@ class MultipleAnswerTrueFalse extends Question
Question::updateQuestionOption($id, $optionData, $course_id);
}
} else {
for ($i=1 ; $i <= 3 ; $i++) {
for ($i = 1; $i <= 3; $i++) {
$last_id = Question::saveQuestionOption(
$this->id,
$this->options[$i],
$course_id,
$i
);
$correct[$i] = $last_id;
$correct[$i] = $last_id;
}
}
@ -278,7 +271,6 @@ class MultipleAnswerTrueFalse extends Question
it's possible that there are more options in the future */
$new_options = Question::readQuestionOption($this->id, $course_id);
$sorted_by_position = array();
foreach ($new_options as $item) {
$sorted_by_position[$item['position']] = $item;
@ -288,13 +280,13 @@ class MultipleAnswerTrueFalse extends Question
the true, false, doubt options registered in this format
XX:YY:ZZZ where XX is a float score value.*/
$extra_values = array();
for ($i=1 ; $i <= 3 ; $i++) {
for ($i = 1; $i <= 3; $i++) {
$score = trim($form -> getSubmitValue('option['.$i.']'));
$extra_values[]= $score;
}
$this->setExtra(implode(':', $extra_values));
for ($i = 1; $i <= $nb_answers; $i++) {
for ($i = 1; $i <= $nb_answers; $i++) {
$answer = trim($form->getSubmitValue('answer['.$i.']'));
$comment = trim($form->getSubmitValue('comment['.$i.']'));
$goodAnswer = trim($form->getSubmitValue('correct['.$i.']'));
@ -304,17 +296,15 @@ class MultipleAnswerTrueFalse extends Question
$goodAnswer = $sorted_by_position[$goodAnswer]['id'];
}
$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 data base
// saves the answers into the database
$objAnswer->save();
// sets the total weighting of the question
$this->updateWeighting($questionWeighting);
$this->save();
}
}
/**
* @param int $feedback_type
@ -325,17 +315,17 @@ class MultipleAnswerTrueFalse extends Question
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 .'">
<tr>
<th>'.get_lang("Choice").'</th>
<th>'. get_lang("ExpectedChoice").'</th>
<th>'. get_lang("Answer").'</th>';
if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
$header .= '<th>'.get_lang("Comment").'</th>';
} else {
$header .= '<th>&nbsp;</th>';
}
$header .= '<table class="'.$this->question_table_class .'">
<tr>
<th>'.get_lang("Choice").'</th>
<th>'. get_lang("ExpectedChoice").'</th>
<th>'. get_lang("Answer").'</th>';
if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
$header .= '<th>'.get_lang("Comment").'</th>';
} else {
$header .= '<th>&nbsp;</th>';
}
$header .= '</tr>';
return $header;
}
}
}

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

@ -198,21 +198,37 @@ class UniqueAnswer extends Question
);
$answer_number = $form->addElement(
'text', 'counter[' . $i . ']', null, ' value = "' . $i . '"'
'text',
'counter['.$i.']',
null,
' value = "'.$i.'"'
);
$answer_number->freeze();
$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->addRule(
'answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required'
'answer['.$i.']',
get_lang('ThisFieldIsRequired'),
'required'
);
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
//Adding extra feedback fields
$group = array();
@ -260,16 +276,13 @@ class UniqueAnswer extends Question
$form->addHtml('</table>');
global $text;
$buttonGroup = [];
//ie6 fix
if ($obj_ex->edit_exercise_in_lp == true) {
//setting the save button here and not in the question class.php
$buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true);
$buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true);
$buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true);
$form->addGroup($buttonGroup);
}
@ -440,8 +453,8 @@ class UniqueAnswer extends Question
$sql = "SELECT max(position) as max_position
FROM $tbl_quiz_answer
WHERE
c_id = $course_id AND
question_id = $question_id";
c_id = $course_id AND
question_id = $question_id";
$rs_max = Database::query($sql);
$row_max = Database::fetch_object($rs_max);
$position = $row_max->max_position + 1;

@ -49,7 +49,6 @@ class UniqueAnswerNoOption extends Question
$feedback_title = '';
$comment_title = '';
if ($obj_ex->selectFeedbackType() == 1) {
$editor_config['Width'] = '250';
$editor_config['Height'] = '110';
@ -86,7 +85,6 @@ class UniqueAnswerNoOption extends Question
}
$temp_scenario = array();
if ($nb_answers < 1) {
$nb_answers = 1;
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
@ -119,7 +117,6 @@ class UniqueAnswerNoOption extends Question
foreach ($new_list as $key) {
$i = $key;
$form->addElement('html', '<tr>');
if (is_object($answer)) {
if ($answer->position[$i] == 666) {
//we set nothing
@ -144,15 +141,17 @@ class UniqueAnswerNoOption extends Question
$list_dest = $item_list[2];
$url = $item_list[3];
if ($try == 0)
if ($try == 0) {
$try_result = 0;
else
} else {
$try_result = 1;
}
if ($url == 0)
if ($url == 0) {
$url_result = '';
else
} else {
$url_result = $url;
}
$temp_scenario['url' . $i] = $url_result;
$temp_scenario['try' . $i] = $try_result;
@ -257,7 +256,7 @@ class UniqueAnswerNoOption extends Question
$buttonGroup = [];
global $text, $class;
global $text;
//ie6 fix
if ($obj_ex->edit_exercise_in_lp == true) {
//setting the save button here and not in the question class.php
@ -291,96 +290,115 @@ class UniqueAnswerNoOption extends Question
*/
function processAnswersCreation($form)
{
$questionWeighting = $nbrGoodAnswers = 0;
$correct = $form -> getSubmitValue('correct');
$objAnswer = new Answer($this->id);
$nb_answers = $form -> getSubmitValue('nb_answers');
$minus = 1;
if ($form -> getSubmitValue('new_question')) {
$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');
//$list_destination = $form -> getSubmitValue('destination'.$i);
//$destination_str = $form -> getSubmitValue('destination'.$i);
$try = $scenario['try'.$i];
$lp = $scenario['lp'.$i];
$destination = $scenario['destination'.$i];
$url = trim($scenario['url'.$i]);
/*
How we are going to parse the destination value
here we parse the destination value which is a string
1@@3@@2;4;4;@@http://www.chamilo.org
where: try_again@@lp_id@@selected_questions@@url
try_again = is 1 || 0
lp_id = id of a learning path (0 if dont select)
selected_questions= ids of questions
url= an url
*/
/*
$destination_str='';
foreach ($list_destination as $destination_id)
{
$destination_str.=$destination_id.';';
}*/
$goodAnswer= ($correct == $i) ? true : false;
if ($goodAnswer) {
$nbrGoodAnswers++;
$weighting = abs($weighting);
if($weighting > 0) {
$questionWeighting = $nbrGoodAnswers = 0;
$correct = $form->getSubmitValue('correct');
$objAnswer = new Answer($this->id);
$nb_answers = $form->getSubmitValue('nb_answers');
$minus = 1;
if ($form -> getSubmitValue('new_question')) {
$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');
//$list_destination = $form -> getSubmitValue('destination'.$i);
//$destination_str = $form -> getSubmitValue('destination'.$i);
$try = $scenario['try'.$i];
$lp = $scenario['lp'.$i];
$destination = $scenario['destination'.$i];
$url = trim($scenario['url'.$i]);
/*
How we are going to parse the destination value
here we parse the destination value which is a string
1@@3@@2;4;4;@@http://www.chamilo.org
where: try_again@@lp_id@@selected_questions@@url
try_again = is 1 || 0
lp_id = id of a learning path (0 if dont select)
selected_questions= ids of questions
url= an url
*/
/*
$destination_str='';
foreach ($list_destination as $destination_id)
{
$destination_str.=$destination_id.';';
}*/
$goodAnswer= ($correct == $i) ? true : false;
if ($goodAnswer) {
$nbrGoodAnswers++;
$weighting = abs($weighting);
if ($weighting > 0) {
$questionWeighting += $weighting;
}
}
}
if (empty($try))
$try=0;
if (empty($try)) {
$try = 0;
}
if (empty($lp)) {
$lp=0;
}
if (empty($lp)) {
$lp = 0;
}
if (empty($destination)) {
$destination=0;
}
if (empty($destination)) {
$destination = 0;
}
if ($url=='') {
$url=0;
}
if ($url == '') {
$url = 0;
}
//1@@1;2;@@2;4;4;@@http://www.chamilo.org
$dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest);
//1@@1;2;@@2;4;4;@@http://www.chamilo.org
$dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
$objAnswer->createAnswer(
$answer,
$goodAnswer,
$comment,
$weighting,
$i,
null,
null,
$dest
);
}
//Create 666 answer
$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 = '';
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest);
$answer = trim($form->getSubmitValue('answer['.$i.']'));
$comment = trim($form->getSubmitValue('comment['.$i.']'));
$weighting = trim($form->getSubmitValue('weighting['.$i.']'));
$goodAnswer = $correct == $i ? true : false;
$dest = '';
$objAnswer->createAnswer(
$answer,
$goodAnswer,
$comment,
$weighting,
$i,
null,
null,
$dest
);
// saves the answers into the data base
$objAnswer -> save();
// saves the answers into the data base
$objAnswer->save();
// sets the total weighting of the question
$this -> updateWeighting($questionWeighting);
$this -> save();
$this->updateWeighting($questionWeighting);
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null)
@ -393,6 +411,7 @@ class UniqueAnswerNoOption extends Question
<th>'. get_lang("Answer").'</th>';
$header .= '<th>'.get_lang("Comment").'</th>';
$header .= '</tr>';
return $header;
}
}
}

Loading…
Cancel
Save