diff --git a/main/css/base.css b/main/css/base.css index b3acc56433..6f956edae8 100755 --- a/main/css/base.css +++ b/main/css/base.css @@ -5820,3 +5820,41 @@ ul.holder li.bit-box{ border-radius: 50%; border: 5px solid rgba(0,0,30,0.8); } + +.question_options .exercise-unique-answer-image { + +} + +@media (min-width: 768px) { + .question_options .exercise-unique-answer-image:nth-child(2n-1) { + clear: both; + } +} + +@media (min-width: 992px) { + .question_options .exercise-unique-answer-image:nth-child(2n-1) { + clear: none; + } + + .question_options .exercise-unique-answer-image:nth-child(3n-2) { + clear: both; + } +} + +.question_options label > input + div.thumbnail { + border-color: transparent; + border-width: 5px; +} + +.question_options label > input:checked + div.thumbnail { + border: 5px solid red; +} + +.question_options div.thumbnail p { + margin: 0; +} + +.question_options div.thumbnail img { + height: auto !important; + max-width: 100%; +} diff --git a/main/exercice/UniqueAnswerImage.php b/main/exercice/UniqueAnswerImage.php new file mode 100644 index 0000000000..cbcc1d46c7 --- /dev/null +++ b/main/exercice/UniqueAnswerImage.php @@ -0,0 +1,360 @@ + + */ +class UniqueAnswerImage extends UniqueAnswer +{ + + static $typePicture = 'mcua.png'; + static $explanationLangVar = 'UniqueSelect'; + + public function __construct() + { + //this is highly important + parent::__construct(); + $this->type = UNIQUE_ANSWER_IMAGE; + $this->isContent = $this->getIsContent(); + } + + public function createAnswersForm($form) + { + $objExercise = $_SESSION['objExercise']; + + $editorConfig = array( + 'ToolbarSet' => 'UniqueAnswerImage', + 'Width' => '100%', + 'Height' => '125' + ); + + //this line defines how many questions by default appear when creating a choice question + // The previous default value was 2. See task #1759. + $numberAnswers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 4; + $numberAnswers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); + + $feedbackTitle = ''; + + if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { + //Scenario + $commentTitle = '
' . get_lang('Number') . ' | +' . get_lang('True') . ' | +' . get_lang('Answer') . ' | + ' . $commentTitle . ' + ' . $feedbackTitle . ' +' . get_lang('Weighting') . ' | +||
---|---|---|---|---|---|
{error} {element} | ',
+ 'correct'
+ );
+ $renderer->setElementTemplate(
+ '{error} {element} | ',
+ 'counter[' . $i . ']'
+ );
+ $renderer->setElementTemplate(
+ '{error} {element} | ',
+ 'answer[' . $i . ']'
+ );
+ $renderer->setElementTemplate(
+ '{error} {element} | ',
+ 'comment[' . $i . ']'
+ );
+ $renderer->setElementTemplate(
+ '{error} {element} | ',
+ 'weighting[' . $i . ']'
+ );
+
+ $answerNumber = $form->addElement('text', 'counter[' . $i . ']', null, ' value = "' . $i . '"');
+ $answerNumber->freeze();
+
+ $form->addElement('radio', 'correct', null, null, $i, 'class="checkbox"');
+ $form->addHtmlEditor('answer[' . $i . ']', null, null, true, $editorConfig);
+
+ $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
+
+ if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
+ $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editorConfig);
+ // Direct feedback
+ //Adding extra feedback fields
+ $group = array();
+ $group['try' . $i] = $form->createElement('checkbox', 'try' . $i, null, get_lang('TryAgain'));
+ $group['lp' . $i] = $form->createElement(
+ 'select',
+ 'lp' . $i,
+ get_lang('SeeTheory') . ': ',
+ $selectLpId
+ );
+ $group['destination' . $i] = $form->createElement(
+ 'select',
+ 'destination' . $i,
+ get_lang('GoToQuestion') . ': ',
+ $selectQuestion
+ );
+ $group['url' . $i] = $form->createElement(
+ 'text', 'url' . $i,
+ get_lang('Other') . ': ',
+ array(
+ 'class' => 'col-md-2',
+ 'placeholder' => get_lang('Other')
+ )
+ );
+ $form->addGroup($group, 'scenario');
+
+ $renderer->setElementTemplate(
+ '{error} {element}', + 'scenario' + ); + } else { + $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editorConfig); + } + $form->addText('weighting[' . $i . ']', null, null, array('class' => "col-md-1", 'value' => '0')); + $form->addHtml(' |