Skip to content

Commit abf40e9

Browse files
author
Qihui Chan
committed
Add plagiarism hook to coderunner questions
1 parent 497ad6f commit abf40e9

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

renderer.php

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,19 @@ public function formulation_and_controls(question_attempt $qa, question_display_
126126
$currentanswer = "\n" . $currentanswer;
127127
}
128128

129+
if (!empty($CFG->enableplagiarism)) {
130+
require_once($CFG->libdir . '/plagiarismlib.php');
131+
132+
$currentanswer .= plagiarism_get_links([
133+
'context' => $options->context->id,
134+
'component' => $qa->get_question()->qtype->plugin_name(),
135+
'area' => $qa->get_usage_id(),
136+
'itemid' => $qa->get_slot(),
137+
'userid' => $step->get_user_id(),
138+
'content' => $qa->get_response_summary()
139+
]);
140+
}
141+
129142
$rows = isset($question->answerboxlines) ? $question->answerboxlines : constants::DEFAULT_NUM_ROWS;
130143
$taattributes = $this->answerbox_attributes($responsefieldname, $rows,
131144
$question, $currentlanguage, $options->readonly);
@@ -558,13 +571,27 @@ public function correct_response(question_attempt $qa) {
558571
* not be displayed. Used to get the context.
559572
*/
560573
public function files_read_only(question_attempt $qa, question_display_options $options) {
574+
global $CFG;
561575
$files = $qa->get_last_qt_files('attachments', $options->context->id);
562576
$output = array();
563577

564578
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())));
579+
$out = html_writer::link($qa->get_response_file_url($file),
580+
$this->output->pix_icon(file_file_icon($file), get_mimetype_description($file),
581+
'moodle', array('class' => 'icon')) . ' ' . s($file->get_filename()));
582+
if (!empty($CFG->enableplagiarism)) {
583+
require_once($CFG->libdir . '/plagiarismlib.php');
584+
585+
$out .= plagiarism_get_links([
586+
'context' => $options->context->id,
587+
'component' => $qa->get_question()->qtype->plugin_name(),
588+
'area' => $qa->get_usage_id(),
589+
'itemid' => $qa->get_slot(),
590+
'userid' => $step->get_user_id(),
591+
'file' => $file
592+
]);
593+
}
594+
$output[] = html_writer::tag('p', $out);
568595
}
569596
return implode($output);
570597
}

0 commit comments

Comments
 (0)