mirror of
https://github.com/PlagiarismCheck/moodle-plagiarism_pchkorg.git
synced 2024-12-22 04:10:07 +00:00
Add new options for min percent of plagiarism
This commit is contained in:
parent
10b4ac6dd3
commit
9151e57228
@ -32,7 +32,6 @@ if (!defined('MOODLE_INTERNAL')) {
|
||||
|
||||
class capability
|
||||
{
|
||||
|
||||
/**
|
||||
* ENABLE
|
||||
*/
|
||||
@ -41,4 +40,8 @@ class capability
|
||||
* VIEW_SIMILARITY
|
||||
*/
|
||||
const VIEW_SIMILARITY = 'plagiarism/pchkorg:viewsimilarity';
|
||||
/**
|
||||
* CHANGE_MIN_PERCENT_FILTER
|
||||
*/
|
||||
const CHANGE_MIN_PERCENT_FILTER = 'plagiarism/pchkorg:changeminpercentfilter';
|
||||
}
|
||||
|
@ -45,4 +45,15 @@ $capabilities = array(
|
||||
'coursecreator' => CAP_ALLOW
|
||||
),
|
||||
),
|
||||
'plagiarism/pchkorg:changeminpercentfilter' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW,
|
||||
'student' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -23,6 +23,12 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
//function pchkorg_check_pchkorg_min_percent($value)
|
||||
//{
|
||||
// return 0 <= $value && $value < 100;
|
||||
//}
|
||||
|
||||
/**
|
||||
* Class defined plugin settings form.
|
||||
*/
|
||||
@ -55,6 +61,16 @@ class plagiarism_pchkorg_setup_form extends moodleform {
|
||||
$mform->addRule('pchkorg_token', null, 'required', null, 'client');
|
||||
$mform->setType('pchkorg_token', PARAM_TEXT);
|
||||
|
||||
$mform->registerRule('check_pchkorg_min_percent', 'callback', 'pchkorg_check_pchkorg_min_percent');
|
||||
|
||||
$mform->addElement('text', 'pchkorg_min_percent', get_string('pchkorg_min_percent', 'plagiarism_pchkorg'));
|
||||
$mform->addHelpButton('pchkorg_min_percent', 'pchkorg_min_percent', 'plagiarism_pchkorg');
|
||||
$mform->addRule('pchkorg_min_percent', null, 'numeric', null, 'client');
|
||||
$mform->addRule('pchkorg_min_percent', get_string('pchkorg_min_percent_range', 'plagiarism_pchkorg'), 'check_pchkorg_min_percent');
|
||||
$mform->setType('pchkorg_min_percent', PARAM_INT);
|
||||
|
||||
|
||||
$this->add_action_buttons(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ $string['pchkorg_submit'] = 'Submit';
|
||||
$string['pchkorg_check_for_plagiarism_report'] = 'View report';
|
||||
$string['savedconfigsuccess'] = 'Settings had been changed';
|
||||
$string['pchkorg_check_for_plagiarism'] = 'Check for plagiarism';
|
||||
$string['pchkorg_min_percent'] = 'Exclude sources below X% similarity';
|
||||
$string['pchkorg_min_percent_help'] = 'Exclude sources below X% similarity';
|
||||
$string['pchkorg_min_percent_range'] = 'Must be between 0 and 99';
|
||||
$string['pchkorg_disclosure'] = 'Submission will be sent to <a target="_blank" href="https://plagiarismcheck.org/">PlagiarismCheck.org</a> for check.
|
||||
<br />
|
||||
By submitting assignment I agree with <a target="_blank" href="https://plagiarismcheck.org/terms-of-service/">Terms & Conditions</a>
|
||||
@ -70,3 +73,4 @@ $string['pchkorg_label_sent'] = 'ID: %s Sent';
|
||||
$string['pchkorg_label_queued'] = 'In queue';
|
||||
$string['pchkorg:enable'] = 'Allow to enable/disable PlagiarismCheck.org inside an activity';
|
||||
$string['pchkorg:viewsimilarity'] = 'Allow to view similarity value from PlagiarismCheck.org';
|
||||
$string['pchkorg:changeminpercentfilter'] = 'Allow changing "Exclude sources below X% similarity"';
|
||||
|
36
lib.php
36
lib.php
@ -34,6 +34,11 @@ require_once(__DIR__ . '/classes/permissions/capability.class.php');
|
||||
|
||||
use plagiarism_pchkorg\classes\permissions\capability;
|
||||
|
||||
function pchkorg_check_pchkorg_min_percent($value)
|
||||
{
|
||||
return 0 <= $value && $value < 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class plagiarism_plugin_pchkorg
|
||||
*/
|
||||
@ -213,21 +218,29 @@ display: inline-block;"
|
||||
if (!isset($data->pchkorg_module_use)) {
|
||||
return;
|
||||
}
|
||||
$fields = array('pchkorg_module_use', 'pchkorg_min_percent');
|
||||
|
||||
$records = $DB->get_records('plagiarism_pchkorg_config', array(
|
||||
'cm' => $data->coursemodule
|
||||
));
|
||||
|
||||
if (empty($records)) {
|
||||
$insert = new \stdClass();
|
||||
$insert->cm = $data->coursemodule;
|
||||
$insert->name = 'pchkorg_module_use';
|
||||
$insert->value = $data->pchkorg_module_use;
|
||||
$DB->insert_record('plagiarism_pchkorg_config', $insert);
|
||||
} else {
|
||||
foreach ($fields as $field) {
|
||||
$isfounded = false;
|
||||
foreach ($records as $record) {
|
||||
if ($record->name === $field) {
|
||||
$isfounded = true;
|
||||
$record->value = $data->{$record->name};
|
||||
$DB->update_record('plagiarism_pchkorg_config', $record);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$isfounded) {
|
||||
$insert = new \stdClass();
|
||||
$insert->cm = $data->coursemodule;
|
||||
$insert->name = $field;
|
||||
$insert->value = $data->{$field};
|
||||
|
||||
$DB->insert_record('plagiarism_pchkorg_config', $insert);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -278,6 +291,15 @@ display: inline-block;"
|
||||
if (!isset($mform->exportValues()[$setting]) || is_null($mform->exportValues()[$setting])) {
|
||||
$mform->setDefault($setting, '1');
|
||||
}
|
||||
|
||||
$mform->registerRule('check_pchkorg_min_percent', 'callback', 'pchkorg_check_pchkorg_min_percent');
|
||||
|
||||
$mform->addElement('text', 'pchkorg_min_percent', get_string('pchkorg_min_percent', 'plagiarism_pchkorg'));
|
||||
$mform->addHelpButton('pchkorg_min_percent', 'pchkorg_min_percent', 'plagiarism_pchkorg');
|
||||
$mform->addRule('pchkorg_min_percent', null, 'numeric', null, 'client');
|
||||
$mform->addRule('pchkorg_min_percent', get_string('pchkorg_min_percent_range', 'plagiarism_pchkorg'), 'check_pchkorg_min_percent');
|
||||
$mform->setType('pchkorg_min_percent', PARAM_INT);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user