コード例 #1
0
 if ($lastcron < time() - 3600 * 0.5) {
     // Check if run in last 30min.
     echo $OUTPUT->box(get_string('cronwarning', 'plagiarism_unplag'), 'generalbox admin warning');
 }
 $warning = '';
 if (!empty($a->countallevents)) {
     $warning = ' warning';
 }
 if ($resetuser == 1 && $id && confirm_sesskey()) {
     if (plagiarism_plugin_unplag::unplag_reset_file($id)) {
         echo $OUTPUT->notification(get_string('fileresubmitted', 'plagiarism_unplag'));
     }
 } else {
     if ($resetuser == 2 && $id && confirm_sesskey()) {
         $plagiarismfile = $DB->get_record('plagiarism_unplag_files', array('id' => $id), '*', MUST_EXIST);
         $file = plagiarism_plugin_unplag::unplag_get_score(plagiarism_plugin_unplag::get_settings(), $plagiarismfile, true);
         // Reset attempts as this was a manual check.
         $file->attempt = $file->attempt - 1;
         $DB->update_record('plagiarism_unplag_files', $file);
         if ($file->statuscode == UNPLAG_STATUSCODE_ACCEPTED) {
             echo $OUTPUT->notification(get_string('scorenotavailableyet', 'plagiarism_unplag'));
         } else {
             if ($file->statuscode == UNPLAG_STATUSCODE_PROCESSED) {
                 echo $OUTPUT->notification(get_string('scoreavailable', 'plagiarism_unplag'));
             } else {
                 echo $OUTPUT->notification(get_string('unknownwarning', 'plagiarism_unplag'));
                 print_object($file);
             }
         }
     }
 }
コード例 #2
0
 function definition()
 {
     $mform =& $this->_form;
     plagiarism_plugin_unplag::unplag_get_form_elements($mform);
     $this->add_action_buttons(true);
 }
コード例 #3
0
 * @author     Dan Marsden <*****@*****.**>
 * @author Mikhail Grinenko <*****@*****.**>
 * @copyright 2014 Dan Marsden <*****@*****.**>
 * @copyright   UKU Group, LTD, https://www.unplag.com 
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once dirname(dirname(__FILE__)) . '/../config.php';
require_once $CFG->dirroot . '/plagiarism/unplag/lib.php';
$cmid = required_param('cmid', PARAM_INT);
// Course Module ID
$pf = required_param('pf', PARAM_INT);
// plagiarism file id.
require_sesskey();
$url = new moodle_url('/plagiarism/unplag/reset.php');
$cm = get_coursemodule_from_id('', $cmid, 0, false, MUST_EXIST);
$PAGE->set_url($url);
require_login($cm->course, true, $cm);
$modulecontext = context_module::instance($cmid);
require_capability('plagiarism/unplag:resetfile', $modulecontext);
plagiarism_plugin_unplag::unplag_reset_file($pf);
if ($cm->modname == 'assignment') {
    $redirect = new moodle_url('/mod/assignment/submissions.php', array('id' => $cmid));
} else {
    if ($cm->modname == 'assign') {
        $redirect = new moodle_url('/mod/assign/view.php', array('id' => $cmid, 'action' => 'grading'));
    } else {
        // TODO: add correct locations for workshop and forum.
        $redirect = $CFG->wwwroot;
    }
}
redirect($redirect, get_string('filereset', 'plagiarism_unplag'));
コード例 #4
0
require_once $CFG->dirroot . '/plagiarism/unplag/lib.php';
require_once 'unplag_form.php';
require_login();
admin_externalpage_setup('plagiarismunplag');
$context = context_system::instance();
$mform = new unplag_defaults_form(null);
$plagiarismdefaults = $DB->get_records_menu('plagiarism_unplag_config', array('cm' => 0), '', 'name, value');
// The cmid(0) is the default list.
if (!empty($plagiarismdefaults)) {
    $mform->set_data($plagiarismdefaults);
}
echo $OUTPUT->header();
$currenttab = 'unplagdefaults';
require_once 'unplag_tabs.php';
if (($data = $mform->get_data()) && confirm_sesskey()) {
    $plagiarismplugin = new plagiarism_plugin_unplag();
    $plagiarismelements = $plagiarismplugin->config_options();
    foreach ($plagiarismelements as $element) {
        if (isset($data->{$element})) {
            $newelement = new Stdclass();
            $newelement->cm = 0;
            $newelement->name = $element;
            $newelement->value = $data->{$element};
            if (isset($plagiarismdefaults[$element])) {
                $newelement->id = $DB->get_field('plagiarism_unplag_config', 'id', array('cm' => 0, 'name' => $element));
                $DB->update_record('plagiarism_unplag_config', $newelement);
            } else {
                $DB->insert_record('plagiarism_unplag_config', $newelement);
            }
        }
    }
コード例 #5
0
 static function unplag_reset_file($id)
 {
     global $DB, $CFG;
     $plagiarismfile = $DB->get_record('plagiarism_unplag_files', array('id' => $id), '*', MUST_EXIST);
     if ($plagiarismfile->statuscode == UNPLAG_STATUSCODE_PROCESSED || $plagiarismfile->statuscode == UNPLAG_STATUSCODE_ACCEPTED) {
         // Sanity Check.
         return true;
     }
     // Set some new values.
     $plagiarismfile->statuscode = 'pending';
     $plagiarismfile->attempt = 0;
     $plagiarismfile->timesubmitted = time();
     $cm = get_coursemodule_from_id('', $plagiarismfile->cm);
     $modulecontext = context_module::instance($plagiarismfile->cm);
     $fs = get_file_storage();
     if ($cm->modname == 'assignment') {
         $submission = $DB->get_record('assignment_submissions', array('assignment' => $cm->instance, 'userid' => $plagiarismfile->userid));
         $files = $fs->get_area_files($modulecontext->id, 'mod_assignment', 'submission', $submission->id);
         foreach ($files as $file) {
             if ($file->get_contenthash() == $plagiarismfile->identifier) {
                 $DB->update_record('plagiarism_unplag_files', $plagiarismfile);
                 // Update before trying to send again.
                 return self::unplag_send_file($plagiarismfile->cm, $plagiarismfile->userid, $file, self::get_settings());
             }
         }
     } else {
         if ($cm->modname == 'assign') {
             require_once $CFG->dirroot . '/mod/assign/locallib.php';
             $assign = new assign($modulecontext, null, null);
             $submissionplugins = $assign->get_submission_plugins();
             $dbparams = array('assignment' => $assign->get_instance()->id, 'userid' => $plagiarismfile->userid);
             $submissions = $DB->get_records('assign_submission', $dbparams);
             foreach ($submissions as $submission) {
                 foreach ($submissionplugins as $submissionplugin) {
                     $component = $submissionplugin->get_subtype() . '_' . $submissionplugin->get_type();
                     $fileareas = $submissionplugin->get_file_areas();
                     foreach ($fileareas as $filearea => $name) {
                         $files = $fs->get_area_files($assign->get_context()->id, $component, $filearea, $submission->id, "timemodified", false);
                         foreach ($files as $file) {
                             if ($file->get_contenthash() == $plagiarismfile->identifier) {
                                 $DB->update_record('plagiarism_unplag_files', $plagiarismfile);
                                 // Update before trying to send again.
                                 return self::unplag_send_file($plagiarismfile->cm, $plagiarismfile->userid, $file, plagiarism_plugin_unplag::get_settings());
                             }
                         }
                     }
                 }
             }
         } else {
             if ($cm->modname == 'workshop') {
                 require_once $CFG->dirroot . '/mod/workshop/locallib.php';
                 $cm = get_coursemodule_from_id('workshop', $plagiarismfile->cm, 0, false, MUST_EXIST);
                 $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
                 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
                 $workshop = new workshop($workshop, $cm, $course);
                 $submissions = $workshop->get_submissions($plagiarismfile->userid);
                 foreach ($submissions as $submission) {
                     $files = $fs->get_area_files($workshop->context->id, 'mod_workshop', 'submission_attachment', $submission->id);
                     foreach ($files as $file) {
                         if ($file->get_contenthash() == $plagiarismfile->identifier) {
                             $DB->update_record('plagiarism_unplag_files', $plagiarismfile);
                             // Update before trying to send again.
                             return self::unplag_send_file($plagiarismfile->cm, $plagiarismfile->userid, $file, plagiarism_plugin_unplag::get_settings());
                         }
                     }
                 }
             } else {
                 if ($cm->modname == 'forum') {
                     require_once $CFG->dirroot . '/mod/forum/lib.php';
                     $cm = get_coursemodule_from_id('forum', $plagiarismfile->cm, 0, false, MUST_EXIST);
                     $posts = forum_get_user_posts($cm->instance, $plagiarismfile->userid);
                     foreach ($posts as $post) {
                         $files = $fs->get_area_files($modulecontext->id, 'mod_forum', 'attachment', $post->id, "timemodified", false);
                         foreach ($files as $file) {
                             if ($file->get_contenthash() == $plagiarismfile->identifier) {
                                 $DB->update_record('plagiarism_unplag_files', $plagiarismfile);
                                 // Update before trying to send again.
                                 return self::unplag_send_file($plagiarismfile->cm, $plagiarismfile->userid, $file, plagiarism_plugin_unplag::get_settings());
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #6
0
// 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/>.
/**
 * checkreceiver.php - Checks to make sure passed receiver address is valid.
 *
 * @since 2.0
 * @package    plagiarism_unplag
 * @subpackage plagiarism
 * @author     Mikhail Grinenko <*****@*****.**>
 * @copyright  UKU Group, LTD, https://www.unplag.com
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
define('AJAX_SCRIPT', true);
require_once dirname(dirname(__FILE__)) . '/../config.php';
require_once $CFG->libdir . '/plagiarismlib.php';
require_once $CFG->dirroot . '/plagiarism/unplag/lib.php';
require_once $CFG->libdir . '/filelib.php';
$cid = required_param('cid', PARAM_INT);
require_login();
require_sesskey();
$unplag = new plagiarism_plugin_unplag();
echo json_encode($unplag->track_progress($cid));