Skip to content

Commit

Permalink
Merge branch 'release-8.6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 4, 2022
2 parents 66473b9 + 3cd236e commit 2b84f7c
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 17 deletions.
42 changes: 42 additions & 0 deletions migrations/Version202211031046021465QtiItemPci.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace oat\qtiItemPci\migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\Exception\IrreversibleMigration;
use oat\qtiItemPci\scripts\install\RegisterPciMathEntry;
use oat\tao\scripts\tools\migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version202211031046021465QtiItemPci extends AbstractMigration
{

public function getDescription(): string
{
return 'Update the Math Entry PCI, set response mapping default to 0 for incorrect responses';
}

public function up(Schema $schema): void
{
$this->addReport(
$this->propagate(
new RegisterPciMathEntry()
)(
['2.4.1']
)
);

}

public function down(Schema $schema): void
{
throw new IrreversibleMigration(
'In order to undo this migration, please revert the client-side changes and run ' . RegisterPciMathEntry::class
);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</div>
<div class="math-entry-score-wrap math-entry-response-correct">
<span class="math-entry-score-title math-entry-response-correct">{{__ "Score"}}</span>
<input value type="text" name="mathEntryScoreInput"
<input value="{{score}}" type="text" name="mathEntryScoreInput"
class="math-entry-score-input math-entry-response-correct" data-validate="$numeric"
data-validate-option="$allowEmpty; $event(type=keyup)" placeholder="{{placeholder}}">
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ define([
return parseInt(value) + 1;
});
let uidCounter = 0;
let defaultScoreValue = 1;

const MathEntryInteractionStateResponse = stateFactory.create(
MapState,
Expand All @@ -71,12 +72,6 @@ define([
let interaction = this.widget.element;
this.activeEditId = null;

const response = this.widget.element.getResponseDeclaration();
const getMappingDefault = response.getMappingAttribute('defaultValue');
if (getMappingDefault <= 0) {
response.setMappingAttribute('defaultValue', 1);
}

const pci = this.widget.element.data('pci');
const responsesManager = pci.getResponsesManager();

Expand All @@ -101,6 +96,17 @@ define([
}
};

MathEntryInteractionStateResponse.prototype.getScoreValue = function getScoreValue() {
const response = this.widget.element.getResponseDeclaration();
const getMappingDefault = response.getMappingAttribute('defaultValue');
if (+getMappingDefault !== 0) {
defaultScoreValue = getMappingDefault;
} else {
defaultScoreValue = 1;
}
return defaultScoreValue;
};

MathEntryInteractionStateResponse.prototype.checkValues = function (index) {
let inputValue = {};
if (this.correctResponses.has(index) && Object.keys(this.correctResponses.get(index)).includes('input')) {
Expand All @@ -118,8 +124,7 @@ define([
const $responseForm = this.widget.$responseForm;

const response = interaction.getResponseDeclaration();
const mapEntries = response.getMapEntries();
const mappingDisabled = _.isEmpty(mapEntries);
const mappingDisabled = false;
this.initResponseChangeEventListener();

$responseForm.html(responseFormTpl({
Expand Down Expand Up @@ -208,7 +213,7 @@ define([
this.correctResponses.set(newId, Object.assign(inputValue, { response: entry }));

if (mapEntries[entry] && index < 1) {
$score[0].value = mapEntries[entry] || response.getMappingAttribute('defaultValue');
$score[0].value = mapEntries[entry];
}
});
} else {
Expand Down Expand Up @@ -259,7 +264,8 @@ define([
const $input = $container.find('.math-entry-input');
const parent = $input[0].parentNode;
$(parent).prepend(scoreTpl({
placeholder: response.getMappingAttribute('defaultValue')
placeholder: response.getMappingAttribute('defaultValue'),
score: this.getScoreValue()
}));
const $correct = $container.find('.math-entry-correct-wrap');
$input.detach().appendTo($correct);
Expand Down Expand Up @@ -464,7 +470,7 @@ define([
const id = responseId || this.uid();

let gapValues = '';
let scoreValue = '';
let scoreValue = this.getScoreValue();
if (this.inGapMode() === true) {
if (this.correctResponses.has(responseId)) {
gapValues = {
Expand Down Expand Up @@ -495,12 +501,16 @@ define([
}
responseValue = this.gapTemplate;
this.correctResponses.set(id, { response: gapValues });
scoreValue = !!responseId && Object.keys(mapEntries).length > 0 && mapEntries[this.correctResponses.get(responseId).response.base.string] || '';
if (!!responseId && Object.keys(mapEntries).length > 0) {
scoreValue = mapEntries[this.correctResponses.get(responseId).response.base.string];
}
} else {
let value = this.correctResponses.has(responseId) && this.correctResponses.get(responseId).response;
responseValue = value || '';
this.correctResponses.set(id, { response: responseValue });
scoreValue = !!responseId && Object.keys(mapEntries).length > 0 && mapEntries[this.correctResponses.get(responseId).response] || '';
if (!!responseId && Object.keys(mapEntries).length > 0) {
scoreValue = mapEntries[this.correctResponses.get(responseId).response];
}
}

let alternativeNumber = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"label": "Math entry",
"short": "Math entry",
"description": "Allow test taker to type math formulas",
"version": "2.4.0",
"version": "2.4.1",
"author": "Christophe Noël",
"email": "christophe@taotesting.com",
"tags": [
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 2b84f7c

Please sign in to comment.