@@ -52,6 +52,9 @@ public function formulation_and_controls(question_attempt $qa, question_display_
52
52
53
53
$ question = $ qa ->get_question ();
54
54
$ qid = $ question ->id ;
55
+ // Answer field.
56
+ $ step = $ qa ->get_last_step_with_qt_var ('answer ' );
57
+
55
58
if (empty ($ USER ->coderunnerquestionids )) {
56
59
$ USER ->coderunnerquestionids = array ($ qid ); // Record in case of AJAX request.
57
60
} else {
@@ -169,6 +172,18 @@ public function formulation_and_controls(question_attempt $qa, question_display_
169
172
array ($ responsefieldid ));
170
173
}
171
174
175
+ if (!empty ($ options ->readonly ) && !empty ($ CFG ->enableplagiarism )) {
176
+ require_once ($ CFG ->libdir . '/plagiarismlib.php ' );
177
+
178
+ $ qtext .= plagiarism_get_links ([
179
+ 'context ' => $ options ->context ->id ,
180
+ 'component ' => $ qa ->get_question ()->qtype ->plugin_name (),
181
+ 'area ' => $ qa ->get_usage_id (),
182
+ 'itemid ' => $ qa ->get_slot (),
183
+ 'userid ' => $ step ->get_user_id (),
184
+ 'content ' => $ qa ->get_response_summary ()
185
+ ]);
186
+ }
172
187
return $ qtext ;
173
188
}
174
189
@@ -558,13 +573,27 @@ public function correct_response(question_attempt $qa) {
558
573
* not be displayed. Used to get the context.
559
574
*/
560
575
public function files_read_only (question_attempt $ qa , question_display_options $ options ) {
576
+ global $ CFG ;
561
577
$ files = $ qa ->get_last_qt_files ('attachments ' , $ options ->context ->id );
562
578
$ output = array ();
563
-
579
+ $ step = $ qa -> get_last_step_with_qt_var ( ' attachments ' );
564
580
foreach ($ files as $ file ) {
565
- $ output [] = html_writer::tag ('p ' , html_writer::link ($ qa ->get_response_file_url ($ file ),
566
- $ this ->output ->pix_icon (file_file_icon ($ file ), get_mimetype_description ($ file ),
567
- 'moodle ' , array ('class ' => 'icon ' )) . ' ' . s ($ file ->get_filename ())));
581
+ $ out = html_writer::link ($ qa ->get_response_file_url ($ file ),
582
+ $ this ->output ->pix_icon (file_file_icon ($ file ), get_mimetype_description ($ file ),
583
+ 'moodle ' , array ('class ' => 'icon ' )) . ' ' . s ($ file ->get_filename ()));
584
+ if (!empty ($ CFG ->enableplagiarism )) {
585
+ require_once ($ CFG ->libdir . '/plagiarismlib.php ' );
586
+
587
+ $ out .= plagiarism_get_links ([
588
+ 'context ' => $ options ->context ->id ,
589
+ 'component ' => $ qa ->get_question ()->qtype ->plugin_name (),
590
+ 'area ' => $ qa ->get_usage_id (),
591
+ 'itemid ' => $ qa ->get_slot (),
592
+ 'userid ' => $ step ->get_user_id (),
593
+ 'file ' => $ file
594
+ ]);
595
+ }
596
+ $ output [] = html_writer::tag ('p ' , $ out );
568
597
}
569
598
return implode ($ output );
570
599
}
0 commit comments