@@ -150,16 +150,19 @@ public static function convert_backup_to_questiondata(array $backupdata): stdCla
150
150
$ questiondata = parent ::convert_backup_to_questiondata ($ backupdata );
151
151
$ qtype = $ questiondata ->qtype ;
152
152
153
- $ questiondata ->options ->testcases = [];
154
- foreach ($ backupdata ["plugin_qtype_ {$ qtype }_question " ]['coderunner_testcases ' ]['coderunner_testcase ' ] as $ record ) {
155
- $ testcase = new stdClass ();
156
- $ fields = [ 'testcode ' , 'testtype ' , 'expected ' , 'useasexample ' , 'display ' ,
157
- 'hiderestiffail ' , 'mark ' , 'stdin ' , 'extra ' ];
158
- foreach ($ fields as $ field ) {
159
- $ testcase ->$ field = $ record [$ field ];
153
+ if (isset ($ backupdata ["plugin_qtype_ {$ qtype }_question " ]['coderunner_testcases ' ])) {
154
+ $ questiondata ->options ->testcases = [];
155
+ foreach ($ backupdata ["plugin_qtype_ {$ qtype }_question " ]['coderunner_testcases ' ]['coderunner_testcase ' ] as $ record ) {
156
+ $ testcase = new stdClass ();
157
+ $ fields = [ 'testcode ' , 'testtype ' , 'expected ' , 'useasexample ' , 'display ' ,
158
+ 'hiderestiffail ' , 'mark ' , 'stdin ' , 'extra ' ];
159
+ foreach ($ fields as $ field ) {
160
+ $ testcase ->$ field = $ record [$ field ];
161
+ }
162
+ $ questiondata ->options ->testcases [] = $ testcase ;
160
163
}
161
- $ questiondata ->options ->testcases [] = $ testcase ;
162
164
}
165
+
163
166
if (isset ($ backupdata ["plugin_qtype_ {$ qtype }_question " ]['coderunner_options ' ])) {
164
167
$ questiondata ->options = (object ) array_merge (
165
168
(array ) $ questiondata ->options ,
0 commit comments