@@ -89,19 +89,17 @@ public function formulation_and_controls(question_attempt $qa, question_display_
89
89
};
90
90
$ iframesrc = $ this ->get_iframe_document ($ options ->context , $ question , $ formulationcb );
91
91
92
- // A hidden input field is used to tell the quiz autosaver that the user changed their question answer
93
- // in the iframe. The value is increased by one every time. The autosaver detects this modification and will
94
- // save all answers.
95
92
$ iframeid = $ questiondivid . '-iframe ' ;
96
- $ autosavehintname = 'qpy-autosave- ' . $ questiondivid ;
97
- $ this ->page ->requires ->js_call_amd (
98
- 'qtype_questionpy/view_question ' ,
99
- 'addIframeFormDataOnSubmit ' ,
100
- [$ iframeid , $ qa ->get_field_prefix () . constants::QT_VAR_RESPONSE ]
101
- );
102
93
103
- $ result = '' ;
94
+ if (!$ options ->readonly ) {
95
+ $ this ->page ->requires ->js_call_amd (
96
+ 'qtype_questionpy/view_question ' ,
97
+ 'addIframeFormDataOnSubmit ' ,
98
+ [$ iframeid , $ qa ->get_field_prefix () . constants::QT_VAR_RESPONSE ]
99
+ );
100
+ }
104
101
102
+ $ result = '' ;
105
103
if (
106
104
($ options ->qpyattemptdetailslink ?? question_display_options::VISIBLE ) === question_display_options::VISIBLE
107
105
&& has_capability (constants::ROLE_VIEW_DETAILS , $ options ->context )
@@ -114,6 +112,11 @@ public function formulation_and_controls(question_attempt $qa, question_display_
114
112
. get_string ('attempt_detail_link ' , 'qtype_questionpy ' ) . '</a> ' ;
115
113
}
116
114
115
+ // A hidden input field is used to tell the quiz autosaver that the user changed their question answer
116
+ // in the iframe. The value is increased by one every time. The autosaver detects this modification and will
117
+ // save all answers.
118
+ $ autosavehintname = 'qpy-autosave- ' . $ questiondivid ;
119
+
117
120
$ result .= <<<EOA
118
121
<input type="hidden" name=" {$ autosavehintname }" id=" {$ autosavehintid }" value="0">
119
122
<iframe id=" {$ iframeid }" srcdoc=" {$ iframesrc }"></iframe>
0 commit comments