Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
Jane Adelmann | faaca3e8ac | |
Jane Adelmann | 6208bf4ff3 | |
Jane Adelmann | aa44efdf0b | |
Jane Adelmann | 04a22a1d3d | |
Jane Adelmann | 830b77e6f7 | |
Jane Adelmann | dd15b4983d |
|
@ -1,2 +1,2 @@
|
|||
.idea
|
||||
|
||||
.vscode
|
||||
|
|
|
@ -658,7 +658,7 @@ class plagiarism_pchkorg_api_provider {
|
|||
global $USER;
|
||||
|
||||
if ($this->is_group_token()) {
|
||||
return $this->token . '::' . hash('sha256', $this->token . $USER->email);
|
||||
return $this->token . '::' . hash('sha256', $this->token . strtolower($USER->email));
|
||||
}
|
||||
|
||||
return $this->token;
|
||||
|
|
|
@ -26,6 +26,16 @@ namespace plagiarism_pchkorg\privacy;
|
|||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use core_privacy\local\metadata\collection;
|
||||
use core_privacy\local\request\contextlist;
|
||||
use core_privacy\local\request\approved_contextlist;
|
||||
use core_privacy\local\request\userlist;
|
||||
use core_privacy\local\request\approved_userlist;
|
||||
|
||||
if (interface_exists('\core_privacy\local\request\userlist')) {
|
||||
interface my_userlist extends \core_privacy\local\request\userlist{}
|
||||
} else {
|
||||
interface my_userlist {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Class provider
|
||||
|
@ -33,8 +43,10 @@ use core_privacy\local\metadata\collection;
|
|||
* @package plagiarism_pchkorg\privacy
|
||||
*/
|
||||
class provider implements
|
||||
my_userlist,
|
||||
\core_privacy\local\metadata\provider,
|
||||
\core_privacy\local\request\plugin\provider {
|
||||
\core_privacy\local\request\plugin\provider,
|
||||
\core_privacy\local\request\core_userlist_provider {
|
||||
|
||||
// This trait must be included.
|
||||
use \core_privacy\local\legacy_polyfill;
|
||||
|
@ -92,4 +104,80 @@ class provider implements
|
|||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of contexts that contain user information for the specified user.
|
||||
*
|
||||
* @param int $userid The user to search.
|
||||
* @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
|
||||
*/
|
||||
public static function _get_contexts_for_userid(int $userid) : contextlist {
|
||||
$contextlist = new contextlist();
|
||||
$sql = "SELECT DISTINCT cm FROM {plagiarism_pchkorg_files} WHERE userid = :userid";
|
||||
$params = [
|
||||
'userid' => $userid
|
||||
];
|
||||
$contextlist->add_from_sql($sql, $params);
|
||||
|
||||
return $contextlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of users who have data within a context.
|
||||
*
|
||||
* @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination.
|
||||
*/
|
||||
public static function get_users_in_context(userlist $userlist) {
|
||||
$context = $userlist->get_context();
|
||||
if (!$context instanceof \context_module) {
|
||||
return;
|
||||
}
|
||||
$params = [
|
||||
'cm' => $context->instanceid,
|
||||
];
|
||||
$sql = "SELECT DISTINCT userid FROM {plagiarism_pchkorg_files} WHERE cm = :cm";
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export all user data for the specified user, in the specified contexts.
|
||||
*
|
||||
* @param approved_contextlist $contextlist The approved contexts to export information for.
|
||||
*/
|
||||
public static function _export_user_data(approved_contextlist $contextlist) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete multiple users within a single context.
|
||||
*
|
||||
* @param approved_userlist $userlist The approved context and user information to delete information for.
|
||||
*/
|
||||
public static function delete_data_for_users(approved_userlist $userlist) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Export all user preferences for the plugin.
|
||||
*
|
||||
* @param int $userid The userid of the user whose data is to be exported.
|
||||
*/
|
||||
public static function _export_user_preferences(int $userid) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete all data for all users in the specified context.
|
||||
*
|
||||
* @param context $context The specific context to delete data for.
|
||||
*/
|
||||
public static function _delete_data_for_all_users_in_context(\context $context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all user data for the specified user, in the specified contexts.
|
||||
*
|
||||
* @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
|
||||
*/
|
||||
public static function _delete_data_for_user(approved_contextlist $contextlist) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="state" TYPE="int" LENGTH="3" NOTNULL="false" SEQUENCE="false"/>
|
||||
<FIELD NAME="score" TYPE="float" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="scoreai" TYPE="float" NOTNULL="false" DEFAULT="NULL" SEQUENCE="false"/>
|
||||
<FIELD NAME="scoreai" TYPE="number" LENGTH="4" NOTNULL="false" SEQUENCE="false" DECIMALS="2"/>
|
||||
<FIELD NAME="created_at" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
||||
<FIELD NAME="textid" TYPE="int" LENGTH="11" NOTNULL="false" SEQUENCE="false"/>
|
||||
<FIELD NAME="reportid" TYPE="int" LENGTH="11" NOTNULL="false" SEQUENCE="false"/>
|
||||
|
|
|
@ -86,6 +86,14 @@ class plagiarism_pchkorg_setup_form extends moodleform {
|
|||
array(get_string('no'), get_string('yes'))
|
||||
);
|
||||
|
||||
$mform->addElement(
|
||||
'select',
|
||||
'pchkorg_enabled_by_default',
|
||||
get_string('pchkorg:enabledbydefault', 'plagiarism_pchkorg'),
|
||||
array(get_string('no'), get_string('yes'))
|
||||
);
|
||||
$mform->setDefault('pchkorg_enabled_by_default', '1');
|
||||
|
||||
$this->add_action_buttons(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ $string['pchkorg_debug_status_error'] = 'Some error for this file';
|
|||
$string['pchkorg_debug_student_not_allowed_see_widget'] = 'Students can not see a similarity score';
|
||||
$string['pchkorg_student_can_see_widget'] = 'Students can see a similarity score';
|
||||
$string['pchkorg_student_can_see_report'] = 'Students can access a similarity report';
|
||||
$string['pchkorg_check_ai'] = 'Enable AI Detector';
|
||||
$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>
|
||||
|
@ -96,3 +97,4 @@ $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"';
|
||||
$string['pchkorg:enabledbydefault'] = 'Enable PlagiarismCheck in Activities by default';
|
46
lib.php
46
lib.php
|
@ -97,7 +97,13 @@ function plagiarism_pchkorg_coursemodule_standard_elements($formwrapper, $mform)
|
|||
if (null === $cm) {
|
||||
if (!isset($exportedvalues['pchkorg_module_use'])
|
||||
|| is_null($exportedvalues['pchkorg_module_use'])) {
|
||||
$mform->setDefault('pchkorg_module_use', '1');
|
||||
$enabledbydefault = $pchkorgconfigmodel->get_system_config('pchkorg_enabled_by_default');
|
||||
if ('1' === $enabledbydefault || null === $enabledbydefault) {
|
||||
$mform->setDefault('pchkorg_module_use', '1');
|
||||
}
|
||||
if ('0' === $enabledbydefault) {
|
||||
$mform->setDefault('pchkorg_module_use', '0');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$records = $DB->get_records('plagiarism_pchkorg_config', array(
|
||||
|
@ -173,7 +179,6 @@ function plagiarism_pchkorg_coursemodule_standard_elements($formwrapper, $mform)
|
|||
array(get_string('no'), get_string('yes'))
|
||||
);
|
||||
|
||||
|
||||
$mform->addElement(
|
||||
'select',
|
||||
'pchkorg_student_can_see_widget',
|
||||
|
@ -187,6 +192,14 @@ function plagiarism_pchkorg_coursemodule_standard_elements($formwrapper, $mform)
|
|||
get_string('pchkorg_student_can_see_report', 'plagiarism_pchkorg'),
|
||||
array(get_string('no'), get_string('yes'))
|
||||
);
|
||||
|
||||
$mform->addElement(
|
||||
'select',
|
||||
'pchkorg_check_ai',
|
||||
get_string('pchkorg_check_ai', 'plagiarism_pchkorg'),
|
||||
array(get_string('no'), get_string('yes'))
|
||||
);
|
||||
$mform->setDefault('pchkorg_check_ai', 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,7 +221,8 @@ function plagiarism_pchkorg_coursemodule_edit_post_actions($data, $course)
|
|||
'pchkorg_include_referenced',
|
||||
'pchkorg_exclude_self_plagiarism',
|
||||
'pchkorg_student_can_see_widget',
|
||||
'pchkorg_student_can_see_report'
|
||||
'pchkorg_student_can_see_report',
|
||||
'pchkorg_check_ai'
|
||||
);
|
||||
|
||||
$records = $DB->get_records('plagiarism_pchkorg_config', array(
|
||||
|
@ -276,7 +290,11 @@ class plagiarism_plugin_pchkorg extends plagiarism_plugin {
|
|||
$isdebugenabled = $pchkorgconfigmodel->get_system_config('pchkorg_enable_debug') === '1';
|
||||
$apiprovider = new plagiarism_pchkorg_api_provider($apitoken);
|
||||
|
||||
$cmid = $linkarray['cmid'];
|
||||
$cmid = null;
|
||||
if (array_key_exists('cmid', $linkarray)) {
|
||||
$cmid = $linkarray['cmid'];
|
||||
}
|
||||
|
||||
if (array_key_exists('file', $linkarray)) {
|
||||
$file = $linkarray['file'];
|
||||
} else {
|
||||
|
@ -420,7 +438,9 @@ class plagiarism_plugin_pchkorg extends plagiarism_plugin {
|
|||
$action = $apiprovider->get_report_action($filerecord->textid);
|
||||
$reporttoken = $apiprovider->generate_api_token();
|
||||
$score = $filerecord->score;
|
||||
if (isset($filerecord->scoreai)) {
|
||||
$isaienabled = '1' === $pchkorgconfigmodel->get_filter_for_module($cmid, 'pchkorg_check_ai');
|
||||
|
||||
if (isset($filerecord->scoreai) && $isaienabled) {
|
||||
$title = sprintf(
|
||||
get_string('pchkorg_label_title_ai', 'plagiarism_pchkorg'),
|
||||
$filerecord->textid,
|
||||
|
@ -777,16 +797,12 @@ display: inline-block;"
|
|||
|
||||
// Set the author and submitter.
|
||||
$submitter = $eventdata['userid'];
|
||||
$author = (!empty($eventdata['relateduserid'])) ? $eventdata['relateduserid'] : $eventdata['userid'];
|
||||
|
||||
// Related user ID will be NULL if an instructor submits on behalf of a student who is in a group.
|
||||
// To get around this, we get the group ID, get the group members and set the author as the first student in the group.
|
||||
if ((empty($eventdata['relateduserid'])) && ($eventdata['other']['modulename'] == 'assign')
|
||||
&& has_capability('mod/assign:editothersubmission', $context, $submitter)) {
|
||||
$moodlesubmission = $DB->get_record('assign_submission', array('id' => $eventdata['objectid']), 'id, groupid');
|
||||
if (!empty($moodlesubmission->groupid)) {
|
||||
$author = $this->get_first_group_author($cm->course, $moodlesubmission->groupid);
|
||||
}
|
||||
}
|
||||
|
||||
if ($eventdata['other']['modulename'] === 'forum'
|
||||
|
@ -956,7 +972,7 @@ display: inline-block;"
|
|||
$moodlesubmission = $DB->get_record('assign_submission', array('id' => $eventdata['objectid']), 'id');
|
||||
|
||||
$moodletextsubmission = $DB->get_record('assignsubmission_onlinetext',
|
||||
array('submission' => $moodlesubmission->id), 'onlinetext');
|
||||
array('submission' => $eventdata['objectid']), 'onlinetext');
|
||||
|
||||
if ($moodletextsubmission) {
|
||||
$eventdata['other']['content'] = $moodletextsubmission->onlinetext;
|
||||
|
@ -964,8 +980,8 @@ display: inline-block;"
|
|||
|
||||
$filesconditions = array(
|
||||
'component' => 'assignsubmission_file',
|
||||
'itemid' => $moodlesubmission->id,
|
||||
'userid' => $author
|
||||
'itemid' => $eventdata['objectid'],
|
||||
'userid' => $eventdata['userid']
|
||||
);
|
||||
|
||||
$moodlefiles = $DB->get_records('files', $filesconditions);
|
||||
|
@ -1149,11 +1165,13 @@ display: inline-block;"
|
|||
|
||||
if ($cm->modname === 'quiz') {
|
||||
if ($filedb->fileid === null) {
|
||||
|
||||
$questionanswers = $DB->get_records_sql(
|
||||
"SELECT {question_attempts}.responsesummary "
|
||||
." FROM {question_attempts} "
|
||||
." INNER JOIN {question} on {question}.id = {question_attempts}.questionid "
|
||||
." WHERE {question_attempts}.questionusageid = ? AND {question}.qtype = 'essay' ", array(
|
||||
." INNER JOIN {question} on {question}.id = {question_attempts}.questionid "
|
||||
." INNER JOIN {quiz_attempts} on {quiz_attempts}.uniqueid = {question_attempts}.questionusageid "
|
||||
." WHERE {quiz_attempts}.id= ? AND {question}.qtype = 'essay' ", array(
|
||||
$filedb->itemid
|
||||
)
|
||||
);
|
||||
|
|
|
@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die();
|
|||
if (!isset($plugin)) {
|
||||
$plugin = new stdClass();
|
||||
}
|
||||
$plugin->version = 2023060713;
|
||||
$plugin->version = 2024030512;
|
||||
$plugin->requires = 2020061501; // Requires Moodle 3.9 .
|
||||
$plugin->release = 'v3.14.1';
|
||||
$plugin->release = 'v3.14.7';
|
||||
$plugin->component = 'plagiarism_pchkorg';
|
||||
$plugin->maturity = MATURITY_STABLE;
|
||||
$plugin->dependencies = array(
|
||||
|
|
Loading…
Reference in New Issue