@@ -616,12 +616,16 @@ public function import_from_xml($xml, $question, qformat_xml $format, $extra = n
616616 $ question ->partindex [$ i ] = $ partindex ;
617617 }
618618 foreach (self ::PART_BASIC_FIELDS as $ field ) {
619- // Older questions do not have this field, so we do not want to issue an error message.
620- // Also, for maximum backwards compatibility, we set the default value to 1. With this,
621- // nothing changes for old questions.
619+ // Older questions do not have the 'answernotunique' field, so we do not want to issue an
620+ // error message. For maximum backwards compatibility, we set the default value to 1. With
621+ // this, nothing changes for old questions. Also, questions exported prior to version 6.2
622+ // won't have the 'emptyallowed' field. We will set it to 0 (false) for backwards compatiblity.
622623 if ($ field === 'answernotunique ' ) {
623624 $ ifnotexists = '' ;
624625 $ default = '1 ' ;
626+ } else if ($ field === 'emptyallowed ' ) {
627+ $ ifnotexists = '' ;
628+ $ default = '0 ' ;
625629 } else {
626630 $ ifnotexists = get_string ('error_import_missing_field ' , 'qtype_formulas ' , $ field );
627631 $ default = '0 ' ;
@@ -861,11 +865,6 @@ public function check_and_filter_parts(object $data): object {
861865 $ partdata [$ i ] = (object )['questionid ' => $ data ->id ];
862866 // Set the basic fields, e.g. mark, placeholder or definition of local variables.
863867 foreach (self ::PART_BASIC_FIELDS as $ field ) {
864- // FIXME: remove this later, when the DB is updated
865- if ($ field === 'emptyallowed ' ) {
866- $ partdata [$ i ]->emptyallowed = 1 ;
867- continue ;
868- }
869868 // In the edit form, the part's 'unitpenalty' and 'ruleid' are set via the global options
870869 // 'globalunitpenalty' and 'globalruleid'. When importing a question, they do not need
871870 // special treatment, because they are already stored with the part. Also, all other fields
0 commit comments