当前位置: 首页>>代码示例>>PHP>>正文


PHP workshop::get_submissions方法代码示例

本文整理汇总了PHP中workshop::get_submissions方法的典型用法代码示例。如果您正苦于以下问题:PHP workshop::get_submissions方法的具体用法?PHP workshop::get_submissions怎么用?PHP workshop::get_submissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在workshop的用法示例。


在下文中一共展示了workshop::get_submissions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: plagiarism_urkund_get_file_object

function plagiarism_urkund_get_file_object($plagiarismfile)
{
    global $CFG, $DB;
    if (strpos($plagiarismfile->identifier, $CFG->tempdir) === true) {
        // This is a stored text file in temp dir.
        $file = new stdclass();
        if (file_exists($plagiarismfile->identifier)) {
            $file->type = "tempurkund";
            $file->filename = basename($plagiarismfile->identifier);
            $file->timestamp = time();
            $file->identifier = sha1(file_get_contents($plagiarismfile->identifier));
            $file->filepath = $plagiarismfile->identifier;
            // Sanity check to see if the Sha1 for this file has already been sent to urkund using a different record.
            if ($DB->record_exists('plagiarism_urkund_files', array('identifier' => $file->identifier, 'cm' => $plagiarismfile->cm, 'userid' => $plagiarismfile->userid))) {
                // This file has already been sent and multiple records for this file were created
                // Delete plagiarism record and file.
                $DB->delete_records('plagiarism_urkund_files', array('id' => $plagiarismfile->id));
                debugging("This file has been duplicated, deleting the duplicate record. Identifier:" . $file->identifier);
                unlink($plagiarismfile->identifier);
                // Delete temp file as we don't need it anymore.
                return false;
            }
            return $file;
        } else {
            debugging("The local version of this file has been deleted, and this file cannot be sent");
            return false;
        }
    } else {
        $cm = get_coursemodule_from_id('', $plagiarismfile->cm);
        $modulecontext = context_module::instance($plagiarismfile->cm);
        $fs = get_file_storage();
        if ($cm->modname == 'assign') {
            require_once $CFG->dirroot . '/mod/assign/locallib.php';
            $assign = new assign($modulecontext, null, null);
            if ($assign->get_instance()->teamsubmission) {
                $submission = $assign->get_group_submission($plagiarismfile->userid, 0, false);
            } else {
                $submission = $assign->get_user_submission($plagiarismfile->userid, false);
            }
            $submissionplugins = $assign->get_submission_plugins();
            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) {
                            return $file;
                        }
                    }
                }
            }
        } 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) {
                            return $file;
                        }
                    }
                }
            } 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) {
                                return $file;
                            }
                        }
                    }
                }
            }
        }
    }
}
开发者ID:henrikthorn,项目名称:moodle-plagiarism_urkund,代码行数:86,代码来源:lib.php

示例2: urkund_reset_file

function urkund_reset_file($id)
{
    global $DB, $CFG;
    $plagiarismfile = $DB->get_record('plagiarism_urkund_files', array('id' => $id), '*', MUST_EXIST);
    if ($plagiarismfile->statuscode == 'Analyzed' || $plagiarismfile->statuscode == URKUND_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_urkund_files', $plagiarismfile);
                // Update before trying to send again.
                return urkund_send_file($plagiarismfile->cm, $plagiarismfile->userid, $file, plagiarism_plugin_urkund::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_urkund_files', $plagiarismfile);
                                // Update before trying to send again.
                                return urkund_send_file($plagiarismfile->cm, $plagiarismfile->userid, $file, plagiarism_plugin_urkund::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_urkund_files', $plagiarismfile);
                            // Update before trying to send again.
                            return urkund_send_file($plagiarismfile->cm, $plagiarismfile->userid, $file, plagiarism_plugin_urkund::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_urkund_files', $plagiarismfile);
                                // Update before trying to send again.
                                return urkund_send_file($plagiarismfile->cm, $plagiarismfile->userid, $file, plagiarism_plugin_urkund::get_settings());
                            }
                        }
                    }
                }
            }
        }
    }
}
开发者ID:edmiranda,项目名称:moodle-plagiarism_urkund,代码行数:86,代码来源:lib.php


注:本文中的workshop::get_submissions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。