Skip to content

Commit

Permalink
Merge pull request #1 from otacke/fix-question-type-contract
Browse files Browse the repository at this point in the history
Fix question type contract when called on empty content
  • Loading branch information
patrickfrohmann authored Nov 29, 2024
2 parents 4cebf32 + a03416b commit 8576b37
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 59 deletions.
131 changes: 76 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
"eslint-config-snordian-h5p": "github:otacke/eslint-config-snordian-h5p",
"mini-css-extract-plugin": "^2.9.2",
"resolve-url-loader": "^5.0.0",
"sass": "^1.80.6",
"sass": "^1.81.0",
"sass-loader": "^16.0.3",
"stylelint": "^16.10.0",
"stylelint": "^16.11.0",
"stylelint-config-recommended": "^14.0.1",
"stylelint-config-recommended-scss": "^14.1.0",
"webpack": "^5.96.1",
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/components/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export default class Content {
* @returns {boolean} True, if answer was given.
*/
getAnswerGiven() {
const choices = this.questionScreen.getChoices();
const choices = this.questionScreen?.getChoices() ?? [];

for (const panel of choices) {
if (panel.options.some((option) => option.selected)) {
Expand All @@ -256,7 +256,7 @@ export default class Content {
* @returns {number} Current position.
*/
getCurrentPosition() {
return this.questionScreen.getCurrentPanelIndex();
return this.questionScreen?.getCurrentPanelIndex() ?? 0;
}

/**
Expand Down

0 comments on commit 8576b37

Please sign in to comment.