Skip to content

Commit

Permalink
Fix xml import
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusgreen committed Apr 2, 2024
1 parent 19afc07 commit b82aee9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public function save_defaults_for_new_questions(stdClass $fromform): void {
public function save_question_options($formdata) {
global $DB;
$context = $formdata->context;

$options = $DB->get_record('qtype_aitext', array('questionid' => $formdata->id));
if (!$options) {
$options = new stdClass();
Expand Down Expand Up @@ -121,6 +120,7 @@ public function save_question_options($formdata) {
$options->graderinfoformat = $formdata->graderinfo['format'];
$options->responsetemplate = $formdata->responsetemplate['text'];
$options->responsetemplateformat = $formdata->responsetemplate['format'];

$DB->update_record('qtype_aitext', $options);
}
/**
Expand Down Expand Up @@ -279,6 +279,12 @@ public function import_from_xml($data, $question, qformat_xml $format, $extra=nu
foreach ($extraquestionfields as $field) {
$qo->$field = $format->getpath($data, array('#', $field, 0, '#'), '');
}
// TODO add in other text fields.
$textfields = ['responsetemplate'];
foreach ($textfields as $field) {
$fmt = $format->get_format($format->getpath($data, array('#', $field.'format', 0, '#'), 0));
$qo->$field = $format->import_text_with_files($data, array('#', $field, 0), '', $fmt);
}

$extraanswersfields = $this->extra_answer_fields();
if (is_array($extraanswersfields)) {
Expand Down

0 comments on commit b82aee9

Please sign in to comment.