Skip to content

Commit

Permalink
Merge branch 'master_MDL-32226' of https://github.com/danmarsden/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Apr 8, 2021
2 parents 25b8cb9 + 21778d8 commit c33b5ef
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
1 change: 1 addition & 0 deletions mod/quiz/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,7 @@ function quiz_supports($feature) {
case FEATURE_SHOW_DESCRIPTION: return true;
case FEATURE_CONTROLS_GRADE_VISIBILITY: return true;
case FEATURE_USES_QUESTIONS: return true;
case FEATURE_PLAGIARISM: return true;

default: return null;
}
Expand Down
12 changes: 11 additions & 1 deletion mod/quiz/report/attemptsreport_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public function get_row_class($attempt) {
* @param int $slot the number used to identify this question within this usage.
*/
public function make_review_link($data, $attempt, $slot) {
global $OUTPUT;
global $OUTPUT, $CFG;

$flag = '';
if ($this->is_flagged($attempt->usageid, $slot)) {
Expand All @@ -273,6 +273,16 @@ public function make_review_link($data, $attempt, $slot) {
array('height' => 450, 'width' => 650)),
array('title' => get_string('reviewresponse', 'quiz')));

if (!empty($CFG->enableplagiarism)) {
require_once($CFG->libdir . '/plagiarismlib.php');
$output .= plagiarism_get_links([
'context' => $this->context->id,
'component' => 'qtype_'.$this->questions[$slot]->qtype,
'cmid' => $this->context->instanceid,
'area' => $attempt->usageid,
'itemid' => $slot,
'userid' => $attempt->userid]);
}
return $output;
}

Expand Down
6 changes: 5 additions & 1 deletion mod/quiz/report/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,18 @@ public abstract function display($cm, $course, $quiz);
* @param string $reportmode the report name.
*/
public function print_header_and_tabs($cm, $course, $quiz, $reportmode = 'overview') {
global $PAGE, $OUTPUT;
global $PAGE, $OUTPUT, $CFG;

// Print the page header.
$PAGE->set_title($quiz->name);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
$context = context_module::instance($cm->id);
echo $OUTPUT->heading(format_string($quiz->name, true, array('context' => $context)));
if (!empty($CFG->enableplagiarism)) {
require_once($CFG->libdir . '/plagiarismlib.php');
echo plagiarism_update_status($course, $cm);
}
}

/**
Expand Down
7 changes: 7 additions & 0 deletions plagiarism/upgrade.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
This files describes API changes for code that uses the plagiarism API.

=== 3.11 ===
* Support for Essay question type in Quiz has now been implemented, allowing plagiarism plugins to display information
on the quiz overview report and when viewing an essay question response.
To implement support, plugins should add a listener to the \mod_quiz\event\attempt_submitted event to send the data
to the plagiarism api using the essay question response summary (plain text response from the user).
The function plagiarism_get_links should only be called to render the results.

=== 3.9 ===

* The method get_form_elements_module has been deprecated. Please use {plugin name}_coursemodule_edit_post_actions() instead.
Expand Down
34 changes: 30 additions & 4 deletions question/type/essay/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
class qtype_essay_renderer extends qtype_renderer {
public function formulation_and_controls(question_attempt $qa,
question_display_options $options) {

global $CFG;
$question = $qa->get_question();
$responseoutput = $question->get_format_renderer($this->page);

Expand All @@ -57,6 +57,17 @@ public function formulation_and_controls(question_attempt $qa,
$step, $question->responsefieldlines, $options->context);
$answer .= html_writer::nonempty_tag('p', $question->get_word_count_message_for_review($step->get_qt_data()));

if (!empty($CFG->enableplagiarism)) {
require_once($CFG->libdir . '/plagiarismlib.php');

$answer .= plagiarism_get_links([
'context' => $options->context->id,
'component' => $qa->get_question()->qtype->plugin_name(),
'area' => $qa->get_usage_id(),
'itemid' => $qa->get_slot(),
'userid' => $step->get_user_id(),
'content' => $qa->get_response_summary()]);
}
}

$files = '';
Expand Down Expand Up @@ -94,13 +105,28 @@ public function formulation_and_controls(question_attempt $qa,
* not be displayed. Used to get the context.
*/
public function files_read_only(question_attempt $qa, question_display_options $options) {
global $CFG;
$files = $qa->get_last_qt_files('attachments', $options->context->id);
$output = array();

$step = $qa->get_last_step_with_qt_var('attachments');

foreach ($files as $file) {
$output[] = html_writer::tag('p', html_writer::link($qa->get_response_file_url($file),
$this->output->pix_icon(file_file_icon($file), get_mimetype_description($file),
'moodle', array('class' => 'icon')) . ' ' . s($file->get_filename())));
$out = html_writer::link($qa->get_response_file_url($file),
$this->output->pix_icon(file_file_icon($file), get_mimetype_description($file),
'moodle', array('class' => 'icon')) . ' ' . s($file->get_filename()));
if (!empty($CFG->enableplagiarism)) {
require_once($CFG->libdir . '/plagiarismlib.php');

$out .= plagiarism_get_links([
'context' => $options->context->id,
'component' => $qa->get_question()->qtype->plugin_name(),
'area' => $qa->get_usage_id(),
'itemid' => $qa->get_slot(),
'userid' => $step->get_user_id(),
'file' => $file]);
}
$output[] = html_writer::tag('p', $out);
}
return implode($output);
}
Expand Down

0 comments on commit c33b5ef

Please sign in to comment.