Merge branch '1.10.x' of github.com:chamilo/chamilo-lms into 1.10.x

1.10.x
Julio 10 years ago
commit abb074d544
  1. 14
      main/exercice/MatchingDraggable.php
  2. 19
      main/exercice/answer.class.php
  3. 14
      main/exercice/matching.class.php

@ -53,16 +53,12 @@ class MatchingDraggable extends Question
if ($form->isSubmitted()) {
$nb_matches = $form->getSubmitValue('nb_matches');
$nb_options = $form->getSubmitValue('nb_options');
if (isset($_POST['lessMatches'])) {
$nb_matches--;
}
if (isset($_POST['moreMatches'])) {
$nb_matches++;
}
if (isset($_POST['lessOptions'])) {
$nb_matches--;
$nb_options--;
}
if (isset($_POST['moreOptions'])) {
$nb_matches++;
$nb_options++;
}
} else if (!empty($this->id)) {
@ -152,12 +148,6 @@ class MatchingDraggable extends Question
$form->addHtml('</tbody></table>');
$group = array();
$renderer->setElementTemplate('<div class="form-group"><div class="col-sm-offset-2">{element}', 'lessMatches');
$renderer->setElementTemplate('{element}</div></div>', 'moreMatches');
$group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessMatches', true);
$group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreMatches', true);
$form->addGroup($group);
// DISPLAY OPTIONS

@ -621,6 +621,25 @@ class Answer
if ($autoId) {
$sql = "UPDATE $answerTable SET id = iid, id_auto = iid WHERE iid = $autoId";
Database::query($sql);
$questionType = $this->getQuestionType();
if (in_array(
$questionType,
[MATCHING, MATCHING_DRAGGABLE]
)) {
$answer = new Answer($this->questionId);
$answer->read();
$correctAnswerId = $answer->selectAnswerIdByPosition($correct);
$correctAnswerAutoId = $answer->selectAutoId($correctAnswerId);
Database::update(
$answerTable,
['correct' => $correctAnswerAutoId ? $correctAnswerAutoId : 0],
['iid = ?' => $autoId]
);
}
}
} else {
// https://support.chamilo.org/issues/6558

@ -58,16 +58,12 @@ class Matching extends Question
if ($form->isSubmitted()) {
$nb_matches = $form->getSubmitValue('nb_matches');
$nb_options = $form->getSubmitValue('nb_options');
if (isset($_POST['lessMatches'])) {
$nb_matches--;
}
if (isset($_POST['moreMatches'])) {
$nb_matches++;
}
if (isset($_POST['lessOptions'])) {
$nb_matches--;
$nb_options--;
}
if (isset($_POST['moreOptions'])) {
$nb_matches++;
$nb_options++;
}
} else if (!empty($this->id)) {
@ -160,12 +156,6 @@ class Matching extends Question
$form->addHtml('</tbody></table>');
$group = array();
$renderer->setElementTemplate('<div class="form-group"><div class="col-sm-offset-2">{element}', 'lessMatches');
$renderer->setElementTemplate('{element}</div></div>', 'moreMatches');
$group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessMatches', true);
$group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreMatches', true);
$form->addGroup($group);
// DISPLAY OPTIONS

Loading…
Cancel
Save