Skip to content

Commit

Permalink
Exercise - add 4 type of questions with global score - refs BT#19930
Browse files Browse the repository at this point in the history
  • Loading branch information
cfasanando committed May 6, 2022
1 parent fb3ce1d commit 6b59b41
Show file tree
Hide file tree
Showing 21 changed files with 390 additions and 44 deletions.
21 changes: 21 additions & 0 deletions main/exercise/FillBlanksGlobal.php
@@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /license.txt */

/**
* FillBlanksGlobal.
*/
class FillBlanksGlobal extends FillBlanks
{
public $typePicture = 'fill_in_blanks.png';
public $explanationLangVar = 'FillBlanksGlobal';

/**
* Constructor.
*/
public function __construct()
{
parent::__construct();
$this->type = FILL_IN_BLANKS_GLOBAL;
$this->isContent = $this->getIsContent();
}
}
20 changes: 20 additions & 0 deletions main/exercise/HotSpotGlobal.php
@@ -0,0 +1,20 @@
<?php
/* For licensing terms, see /license.txt */

/**
* HotSpotGlobal.
*/
class HotSpotGlobal extends HotSpot
{
public $typePicture = 'hotspot.png';
public $explanationLangVar = 'HotSpotGlobal';

/**
* HotSpot constructor.
*/
public function __construct()
{
parent::__construct();
$this->type = HOT_SPOT_GLOBAL;
}
}
27 changes: 25 additions & 2 deletions main/exercise/MatchingDraggable.php
Expand Up @@ -96,14 +96,19 @@ public function createAnswersForm($form)
$form->addElement('hidden', 'nb_matches', $nb_matches);
$form->addElement('hidden', 'nb_options', $nb_options);

$thWeighting = '';
if (MATCHING_DRAGGABLE === $this->type) {
$thWeighting = '<th width="10">'.get_lang('Weighting').'</th>';
}

// DISPLAY MATCHES
$html = '<table class="table table-striped table-hover">
<thead>
<tr>
<th width="10">'.get_lang('Number').'</th>
<th width="85%">'.get_lang('Answer').'</th>
<th width="15%">'.get_lang('MatchesTo').'</th>
<th width="10">'.get_lang('Weighting').'</th>
'.$thWeighting.'
</tr>
</thead>
<tbody>';
Expand Down Expand Up @@ -152,7 +157,11 @@ public function createAnswersForm($form)
);

$form->addSelect("matches[$i]", null, $matches);
$form->addText("weighting[$i]", null, true, ['style' => 'width: 60px;', 'value' => 10]);
if (MATCHING_DRAGGABLE === $this->type) {
$form->addText("weighting[$i]", null, true, ['style' => 'width: 60px;', 'value' => 10]);
} else {
$form->addHidden("weighting[$i]", "0");
}
$form->addHtml('</tr>');
}

Expand Down Expand Up @@ -196,6 +205,15 @@ public function createAnswersForm($form)
}

$form->addHtml('</table>');

if (MATCHING_DRAGGABLE_GLOBAL === $this->type) {
//only 1 answer the all deal ...
$form->addText('questionWeighting', get_lang('Score'), true, ['value' => 10]);
if (!empty($this->iid)) {
$defaults['questionWeighting'] = $this->weighting;
}
}

global $text;
$group = [];
// setting the save button here and not in the question class.php
Expand Down Expand Up @@ -254,6 +272,11 @@ public function processAnswersCreation($form, $exercise)
$position
);
}

if (MATCHING_DRAGGABLE_GLOBAL == $this->type) {
$this->weighting = $form->getSubmitValue('questionWeighting');
}

$objAnswer->save();
$this->save($exercise);
}
Expand Down
21 changes: 21 additions & 0 deletions main/exercise/MatchingDraggableGlobal.php
@@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /license.txt */

/**
* MatchingDraggableGlobal.
*/
class MatchingDraggableGlobal extends MatchingDraggable
{
public $typePicture = 'matchingdrag.png';
public $explanationLangVar = 'MatchingDraggableGlobal';

/**
* Constructor.
*/
public function __construct()
{
parent::__construct();
$this->type = MATCHING_DRAGGABLE_GLOBAL;
$this->isContent = $this->getIsContent();
}
}
21 changes: 21 additions & 0 deletions main/exercise/MatchingGlobal.php
@@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /license.txt */

/**
* MatchingGlobal.
*/
class MatchingGlobal extends Matching
{
public $typePicture = 'matching.png';
public $explanationLangVar = 'MatchingGlobal';

/**
* Constructor.
*/
public function __construct()
{
parent::__construct();
$this->type = MATCHING_GLOBAL;
$this->isContent = $this->getIsContent();
}
}

0 comments on commit 6b59b41

Please sign in to comment.