mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-32226 mod_quiz: Add Plagiarism hooks to quiz and essay question.
This commit is contained in:
parent
d65ed58e73
commit
21778d8d16
@ -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;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ abstract class quiz_attempts_report_table extends table_sql {
|
||||
* @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)) {
|
||||
@ -273,6 +273,16 @@ abstract class quiz_attempts_report_table extends table_sql {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ abstract class quiz_default_report {
|
||||
* @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);
|
||||
@ -69,6 +69,10 @@ abstract class quiz_default_report {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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.
|
||||
|
@ -36,7 +36,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
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);
|
||||
|
||||
@ -57,6 +57,17 @@ class qtype_essay_renderer extends qtype_renderer {
|
||||
$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 = '';
|
||||
@ -94,13 +105,28 @@ class qtype_essay_renderer extends qtype_renderer {
|
||||
* 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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user