本文整理汇总了PHP中assign::get_group_submission方法的典型用法代码示例。如果您正苦于以下问题:PHP assign::get_group_submission方法的具体用法?PHP assign::get_group_submission怎么用?PHP assign::get_group_submission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assign
的用法示例。
在下文中一共展示了assign::get_group_submission方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* Use a static cache to try and reduce DB calls.
*
* @param int $userid The user id for this submission
* @param int $groupid The groupid (returned)
* @param mixed $submission The stdClass submission or false (returned)
*/
function get_group_and_submission($userid, &$group, &$submission)
{
$group = false;
if (isset($this->submissiongroups[$userid])) {
$group = $this->submissiongroups[$userid];
} else {
$group = $this->assignment->get_submission_group($userid, false);
$this->submissiongroups[$userid] = $group;
}
$groupid = 0;
if ($group) {
$groupid = $group->id;
}
if (isset($this->groupsubmissions[$groupid])) {
$submission = $this->groupsubmissions[$groupid];
} else {
$submission = $this->assignment->get_group_submission($userid, $groupid, false);
$this->groupsubmissions[$groupid] = $submission;
}
}
示例2: get_group_and_submission
/**
* Use a static cache to try and reduce DB calls.
*
* @param int $userid The user id for this submission
* @param int $group The groupid (returned)
* @param stdClass|false $submission The stdClass submission or false (returned)
* @param int $attemptnumber Return a specific attempt number (-1 for latest)
*/
protected function get_group_and_submission($userid, &$group, &$submission, $attemptnumber)
{
$group = false;
if (isset($this->submissiongroups[$userid])) {
$group = $this->submissiongroups[$userid];
} else {
$group = $this->assignment->get_submission_group($userid, false);
$this->submissiongroups[$userid] = $group;
}
$groupid = 0;
if ($group) {
$groupid = $group->id;
}
// Static cache is keyed by groupid and attemptnumber.
// We may need both the latest and previous attempt in the same page.
if (isset($this->groupsubmissions[$groupid . ':' . $attemptnumber])) {
$submission = $this->groupsubmissions[$groupid . ':' . $attemptnumber];
} else {
$submission = $this->assignment->get_group_submission($userid, $groupid, false, $attemptnumber);
$this->groupsubmissions[$groupid . ':' . $attemptnumber] = $submission;
}
}
示例3: 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;
}
}
}
}
}
}
}
}
示例4: assign_get_completion_state
/**
* Obtains the automatic completion state for this module based on any conditions
* in assign settings.
*
* @param object $course Course
* @param object $cm Course-module
* @param int $userid User ID
* @param bool $type Type of comparison (or/and; can be used as return value if no conditions)
* @return bool True if completed, false if not, $type if conditions not set.
*/
function assign_get_completion_state($course, $cm, $userid, $type)
{
global $CFG, $DB;
require_once $CFG->dirroot . '/mod/assign/locallib.php';
$assign = new assign(null, $cm, $course);
// If completion option is enabled, evaluate it and return true/false.
if ($assign->get_instance()->completionsubmit) {
if ($assign->get_instance()->teamsubmission) {
$submission = $assign->get_group_submission($userid, 0, false);
} else {
$submission = $assign->get_user_submission($userid, false);
}
return $submission && $submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED;
} else {
// Completion option is not enabled so just return $type.
return $type;
}
}
示例5: dirname
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once dirname(__FILE__) . '/../../../../config.php';
global $CFG, $DB, $PAGE, $USER;
require_once $CFG->dirroot . '/mod/assign/locallib.php';
require_once $CFG->dirroot . '/mod/assign/submission/pdf/lib.php';
$id = required_param('id', PARAM_INT);
$submissionid = optional_param('submissionid', 0, PARAM_INT);
$pageno = optional_param('pageno', 1, PARAM_INT);
$url = new moodle_url('/mod/assign/feedback/pdf/viewcomment.php', array('submissionid' => $submissionid, 'pageno' => $pageno, 'id' => $id));
$cm = get_coursemodule_from_id('assign', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$PAGE->set_url($url);
require_login($course, false, $cm);
$context = context_module::instance($cm->id);
$assignment = new assign($context, $cm, $course);
$feedbackpdf = new assign_feedback_pdf($assignment, 'feedback_pdf');
// Check the user has the relevant capability to access this assignment submission.
if ($submissionid) {
$submission = $DB->get_record('assign_submission', array('id' => $submissionid), '*', MUST_EXIST);
} else {
if ($assignment->get_instance()->teamsubmission) {
$submission = $assignment->get_group_submission($USER->id, 0, false);
} else {
$submission = $assignment->get_user_submission($USER->id, false);
}
}
if (!$submission) {
print_error('nosubmission', 'assignfeedback_pdf');
}
$feedbackpdf->edit_comment_page($submission->id, $pageno, false);