本文整理汇总了PHP中assign::get_user_submission方法的典型用法代码示例。如果您正苦于以下问题:PHP assign::get_user_submission方法的具体用法?PHP assign::get_user_submission怎么用?PHP assign::get_user_submission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assign
的用法示例。
在下文中一共展示了assign::get_user_submission方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: other_cols
/**
* Format the submission and feedback columns.
*
* @param string $colname The column name
* @param stdClass $row The submission row
* @return mixed string or NULL
*/
public function other_cols($colname, $row)
{
// For extra user fields the result is already in $row.
if (empty($this->plugincache[$colname])) {
return $row->{$colname};
}
// This must be a plugin field.
$plugincache = $this->plugincache[$colname];
$plugin = $plugincache[0];
$field = null;
if (isset($plugincache[1])) {
$field = $plugincache[1];
}
if ($plugin->is_visible() && $plugin->is_enabled()) {
if ($plugin->get_subtype() == 'assignsubmission') {
if ($this->assignment->get_instance()->teamsubmission) {
$group = false;
$submission = false;
$this->get_group_and_submission($row->id, $group, $submission, -1);
if ($submission) {
if ($submission->status == ASSIGN_SUBMISSION_STATUS_REOPENED) {
// For a newly reopened submission - we want to show the previous submission in the table.
$this->get_group_and_submission($row->id, $group, $submission, $submission->attemptnumber - 1);
}
if (isset($field)) {
return $plugin->get_editor_text($field, $submission->id);
}
return $this->format_plugin_summary_with_link($plugin, $submission, 'grading', array());
}
} else {
if ($row->submissionid) {
if ($row->status == ASSIGN_SUBMISSION_STATUS_REOPENED) {
// For a newly reopened submission - we want to show the previous submission in the table.
$submission = $this->assignment->get_user_submission($row->userid, false, $row->attemptnumber - 1);
} else {
$submission = new stdClass();
$submission->id = $row->submissionid;
$submission->timecreated = $row->firstsubmission;
$submission->timemodified = $row->timesubmitted;
$submission->assignment = $this->assignment->get_instance()->id;
$submission->userid = $row->userid;
$submission->attemptnumber = $row->attemptnumber;
}
// Field is used for only for import/export and refers the the fieldname for the text editor.
if (isset($field)) {
return $plugin->get_editor_text($field, $submission->id);
}
return $this->format_plugin_summary_with_link($plugin, $submission, 'grading', array());
}
}
} else {
$grade = null;
if (isset($field)) {
return $plugin->get_editor_text($field, $row->gradeid);
}
if ($row->gradeid) {
$grade = new stdClass();
$grade->id = $row->gradeid;
$grade->timecreated = $row->firstmarked;
$grade->timemodified = $row->timemarked;
$grade->assignment = $this->assignment->get_instance()->id;
$grade->userid = $row->userid;
$grade->grade = $row->grade;
$grade->mailed = $row->mailed;
$grade->attemptnumber = $row->attemptnumber;
}
if ($this->quickgrading && $plugin->supports_quickgrading()) {
return $plugin->get_quickgrading_html($row->userid, $grade);
} else {
if ($grade) {
return $this->format_plugin_summary_with_link($plugin, $grade, 'grading', array());
}
}
}
}
return '';
}
示例2: 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;
}
}
示例3: view_course_index
/**
* View a summary listing of all assignments in the current course.
*
* @return string
*/
private function view_course_index()
{
global $USER;
$o = '';
$course = $this->get_course();
$strplural = get_string('modulenameplural', 'assign');
if (!($cms = get_coursemodules_in_course('assign', $course->id, 'm.duedate'))) {
$o .= $this->get_renderer()->notification(get_string('thereareno', 'moodle', $strplural));
$o .= $this->get_renderer()->continue_button(new moodle_url('/course/view.php', array('id' => $course->id)));
return $o;
}
$strsectionname = '';
$usesections = course_format_uses_sections($course->format);
$modinfo = get_fast_modinfo($course);
if ($usesections) {
$strsectionname = get_string('sectionname', 'format_' . $course->format);
$sections = $modinfo->get_section_info_all();
}
$courseindexsummary = new assign_course_index_summary($usesections, $strsectionname);
$timenow = time();
$currentsection = '';
foreach ($modinfo->instances['assign'] as $cm) {
if (!$cm->uservisible) {
continue;
}
$timedue = $cms[$cm->id]->duedate;
$sectionname = '';
if ($usesections && $cm->sectionnum) {
$sectionname = get_section_name($course, $sections[$cm->sectionnum]);
}
$submitted = '';
$context = context_module::instance($cm->id);
$assignment = new assign($context, $cm, $course);
if (has_capability('mod/assign:grade', $context)) {
$submitted = $assignment->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED);
} else {
if (has_capability('mod/assign:submit', $context)) {
$usersubmission = $assignment->get_user_submission($USER->id, false);
if (!empty($usersubmission->status)) {
$submitted = get_string('submissionstatus_' . $usersubmission->status, 'assign');
} else {
$submitted = get_string('submissionstatus_', 'assign');
}
}
}
$gradinginfo = grade_get_grades($course->id, 'mod', 'assign', $cm->instance, $USER->id);
if (isset($gradinginfo->items[0]->grades[$USER->id]) && !$gradinginfo->items[0]->grades[$USER->id]->hidden) {
$grade = $gradinginfo->items[0]->grades[$USER->id]->str_grade;
} else {
$grade = '-';
}
$courseindexsummary->add_assign_info($cm->id, $cm->name, $sectionname, $timedue, $submitted, $grade);
}
$o .= $this->get_renderer()->render($courseindexsummary);
$o .= $this->view_footer();
return $o;
}
示例4: test_submit_for_grading
/**
* Test submit_for_grading
*/
public function test_submit_for_grading()
{
global $DB, $USER;
$this->resetAfterTest(true);
// Create a course and assignment and users.
$course = self::getDataGenerator()->create_course();
set_config('submissionreceipts', 0, 'assign');
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
$params['course'] = $course->id;
$params['assignsubmission_onlinetext_enabled'] = 1;
$params['submissiondrafts'] = 1;
$params['sendnotifications'] = 0;
$params['requiresubmissionstatement'] = 1;
$instance = $generator->create_instance($params);
$cm = get_coursemodule_from_instance('assign', $instance->id);
$context = context_module::instance($cm->id);
$assign = new assign($context, $cm, $course);
$student1 = self::getDataGenerator()->create_user();
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
// Create a student1 with an online text submission.
// Simulate a submission.
$this->setUser($student1);
$submission = $assign->get_user_submission($student1->id, true);
$data = new stdClass();
$data->onlinetext_editor = array('itemid' => file_get_unused_draft_itemid(), 'text' => 'Submission text', 'format' => FORMAT_MOODLE);
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
$plugin->save($submission, $data);
$result = mod_assign_external::submit_for_grading($instance->id, false);
$result = external_api::clean_returnvalue(mod_assign_external::submit_for_grading_returns(), $result);
// Should be 1 fail because the submission statement was not aceptted.
$this->assertEquals(1, count($result));
$result = mod_assign_external::submit_for_grading($instance->id, true);
$result = external_api::clean_returnvalue(mod_assign_external::submit_for_grading_returns(), $result);
// Check for 0 warnings.
$this->assertEquals(0, count($result));
$submission = $assign->get_user_submission($student1->id, false);
$this->assertEquals(ASSIGN_SUBMISSION_STATUS_SUBMITTED, $submission->status);
}
示例5: is_file_modified
/**
* Does this file exist in any of the current files supported by this plugin for this user?
*
* @param assign $assignment - The assignment instance
* @param stdClass $user The user matching this uploaded file
* @param assign_plugin $plugin The matching plugin from the filename
* @param string $filename The parsed filename from the zip
* @param stored_file $fileinfo The info about the extracted file from the zip
* @return bool - True if the file has been modified or is new
*/
public function is_file_modified($assignment, $user, $plugin, $filename, $fileinfo) {
$sg = null;
if ($plugin->get_subtype() == 'assignsubmission') {
$sg = $assignment->get_user_submission($user->id, false);
} else if ($plugin->get_subtype() == 'assignfeedback') {
$sg = $assignment->get_user_grade($user->id, false);
} else {
return false;
}
if (!$sg) {
return true;
}
foreach ($plugin->get_files($sg, $user) as $pluginfilename => $file) {
if ($pluginfilename == $filename) {
// Extract the file and compare hashes.
$contenthash = '';
if (is_array($file)) {
$content = reset($file);
$contenthash = sha1($content);
} else {
$contenthash = $file->get_contenthash();
}
if ($contenthash != $fileinfo->get_contenthash()) {
return true;
} else {
return false;
}
}
}
return true;
}
示例6: catch
$courseinfo = get_fast_modinfo($logrecord->course);
} catch (Exception $e) {
$log->warning("MISSING: Unable to get modinfo for course {$logrecord->course}");
continue;
}
try {
$mod = $courseinfo->get_cm($logrecord->cmid);
} catch (Exception $e) {
$log->warning("MISSING: Unable to get cm {$logrecord->cmid}");
continue;
}
$course = $courseinfo->get_course();
// We don't have enough info to determine the actual submission
// so always get the latest for that assignment
$assign = new assign($mod->context, $mod, $course);
$submission = $assign->get_user_submission($logrecord->userid, false);
$event['objectid'] = $submission->id;
$event['objecttable'] = 'assign_submission';
if ($statement = $gen->generateStatement($event)) {
$statements[] = $statement;
}
}
$log->info("Sending statements {$start} to " . ($start + count($batch) - 1));
$log->info("Statement count: " . count($statements));
// Send statements as a batch
$result = $lrs->saveStatements($statements);
$start += count($batch);
}
// AssignmentGraded recipe
$log->info("Processing AssignmentGraded events");
$start = 0;
示例7: 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;
}
}
}
}
}
}
}
}
示例8: 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);