-
Notifications
You must be signed in to change notification settings - Fork 10
/
programming_plag_result_form.php
102 lines (84 loc) · 4.44 KB
/
programming_plag_result_form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package plagiarism
* @subpackage programming
* @author thanhtri
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot.'/lib/formslib.php');
require_once(dirname(__FILE__).'/detection_tools.php');
class programming_plag_result_form extends moodleform {
private $cmid;
private $detector;
public function __construct($cmid, $detector) {
$this->cmid = $cmid;
$this->detector = $detector;
parent::__construct(null, null, 'get');
}
protected function definition() {
global $DB, $detection_tools;
$assignment = $DB->get_record('plagiarism_programming', array('cmid' => $this->cmid));
$mform = $this->_form;
// similarity threshold
$mform->addElement('header', 'option_header', get_string('option_header', 'plagiarism_programming'));
$mform->addElement('text', 'lower_threshold', get_string('threshold', 'plagiarism_programming'));
$mform->setType('lower_threshold', PARAM_INT);
// select the similarity type average or maximal
$rate_type = array('max'=>'Maximum similarity', 'avg'=>'Average similarity');
$mform->addElement('select', 'rate_type', get_string('similarity_type', 'plagiarism_programming'), $rate_type);
// select the tool to display
$tools = array();
foreach ($detection_tools as $tool => $info) {
if ($assignment->$tool) {
$tools[$tool] = $info['name'];
}
}
$mform->addElement('select', 'tool', get_string('detection_tool', 'plagiarism_programming'), $tools);
// select the mode of display
$display_modes = array('group'=>'Grouping students', 'table'=>'Ordered table');
$mform->addElement('select', 'display_mode', get_string('display_mode', 'plagiarism_programming'), $display_modes);
// select the version history
$reports = $DB->get_records('plagiarism_programming_rpt', array('cmid'=>$this->cmid, 'detector'=>$this->detector), 'time_created DESC');
$report_select = array();
foreach ($reports as $report) {
$report_select[$report->version] = date('d M h.i A', $report->time_created);
}
$mform->addElement('select', 'version', get_string('version', 'plagiarism_programming'), $report_select);
// if having repository, include a checkbox to include repository files or not
$fs = get_file_storage();
$context = context_module::instance($this->cmid);
$repo_files = $fs->get_area_files($context->id, 'plagiarism_programming', 'codeseeding', $assignment->id, '', false);
if (!empty($repo_files)) {
$mform->addElement('advcheckbox', 'include_repository',
get_string('include_repository', 'plagiarism_programming'),
'', array('group' => 0), array(0, 1));
}
// other elements
$mform->addElement('hidden', 'cmid', $this->_customdata['cmid']);
$mform->setType('cmid', PARAM_INT);
$mform->addElement('hidden', 'student', $this->_customdata['student_id']);
$mform->setType('student', PARAM_INT);
$mform->addElement('submit', 'submitbutton', get_string('submit', 'plagiarism_programming'));
// help button
$mform->addHelpButton('lower_threshold', 'lower_threshold_hlp', 'plagiarism_programming');
$mform->addHelpButton('rate_type', 'rate_type_hlp', 'plagiarism_programming');
$mform->addHelpButton('tool', 'tool_hlp', 'plagiarism_programming');
$mform->addHelpButton('display_mode', 'display_mode_hlp', 'plagiarism_programming');
$mform->addHelpButton('version', 'version_hlp', 'plagiarism_programming');
}
}