Skip to content

Commit

Permalink
Dev: Make sure question editor doesn't break at question theme error
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Jun 3, 2021
1 parent 7a2c14d commit e2a45f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions application/models/QuestionTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,18 @@ public static function findQuestionMetaData($question_type, $question_template =
// todo: object or array?
$baseQuestion = self::model()->query($criteria, false);

if (empty($baseQuestion)) {
$settings = new StdClass();
$settings->class = '';
$settings->answerscales = 0;
return [
'title' => gT('Question theme error: Missing metadata'),
'name' => gT('Question theme error: Missing metadata'),
'question_type' => '',
'settings' => $settings
];
}

// language settings
$baseQuestion->title = gT($baseQuestion->title, "html", $language);
$baseQuestion->group = gT($baseQuestion->group, "html", $language);
Expand Down
1 change: 1 addition & 0 deletions application/views/questionAdministration/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class="btn navbar-btn button white btn-success"
<!-- Question code and question type selector -->
<div class="row">
<?php
// TODO: Change this to $question->question_theme->config->metadata
$questionTheme = QuestionTheme::findQuestionMetaData($oQuestion->type, $questionTemplate);
$this->renderPartial(
"codeAndType",
Expand Down

0 comments on commit e2a45f5

Please sign in to comment.