Skip to content

Commit

Permalink
Force to choose the same number of proposal than of answers - refs #7878
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Oct 13, 2015
1 parent 73a64d3 commit 5321bde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
14 changes: 2 additions & 12 deletions main/exercice/MatchingDraggable.php
Expand Up @@ -53,16 +53,12 @@ public function createAnswersForm($form)
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)) {
Expand Down Expand Up @@ -152,12 +148,6 @@ public function createAnswersForm($form)
$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
Expand Down
14 changes: 2 additions & 12 deletions main/exercice/matching.class.php
Expand Up @@ -58,16 +58,12 @@ public function createAnswersForm($form)
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)) {
Expand Down Expand Up @@ -160,12 +156,6 @@ public function createAnswersForm($form)
$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
Expand Down

0 comments on commit 5321bde

Please sign in to comment.