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


PHP assign::can_view_submission方法代码示例

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


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

示例1: get_file_info

 /**
  * Default implementation of file_get_info for plugins.
  * This is used by the filebrowser to browse a plugins file areas.
  *
  * This implementation should work for most plugins but can be overridden if required.
  * @param file_browser $browser
  * @param string $filearea
  * @param int $itemid
  * @param string $filepath
  * @param string $filename
  * @return file_info_stored
  */
 public function get_file_info($browser, $filearea, $itemid, $filepath, $filename)
 {
     global $CFG, $DB, $USER;
     $urlbase = $CFG->wwwroot . '/pluginfile.php';
     // Permission check on the itemid.
     if ($this->get_subtype() == 'assignsubmission') {
         if ($itemid) {
             $record = $DB->get_record('assign_submission', array('id' => $itemid), 'userid', IGNORE_MISSING);
             if (!$record) {
                 return null;
             }
             if (!$this->assignment->can_view_submission($record->userid)) {
                 return null;
             }
         }
     } else {
         // Not supported for feedback plugins.
         return null;
     }
     $fs = get_file_storage();
     $filepath = is_null($filepath) ? '/' : $filepath;
     $filename = is_null($filename) ? '.' : $filename;
     if (!($storedfile = $fs->get_file($this->assignment->get_context()->id, $this->get_subtype() . '_' . $this->get_type(), $filearea, $itemid, $filepath, $filename))) {
         return null;
     }
     return new file_info_stored($browser, $this->assignment->get_context(), $storedfile, $urlbase, $filearea, $itemid, true, true, false);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:39,代码来源:assignmentplugin.php

示例2: assignsubmission_onenote_pluginfile

/**
 * Serves assignment submissions and other files.
 *
 * @param mixed $course course or id of the course
 * @param mixed $cm course module or id of the course module
 * @param context $context
 * @param string $filearea
 * @param array $args
 * @param bool $forcedownload
 * @return bool false if file not found, does not return if found - just send the file
 */
function assignsubmission_onenote_pluginfile($course, $cm, context $context, $filearea, $args, $forcedownload)
{
    global $DB, $CFG;
    if ($context->contextlevel != CONTEXT_MODULE) {
        return false;
    }
    require_login($course, false, $cm);
    $itemid = (int) array_shift($args);
    $record = $DB->get_record('assign_submission', array('id' => $itemid), 'userid, assignment, groupid', MUST_EXIST);
    $userid = $record->userid;
    $groupid = $record->groupid;
    require_once $CFG->dirroot . '/mod/assign/locallib.php';
    $assign = new assign($context, $cm, $course);
    if ($assign->get_instance()->id != $record->assignment) {
        return false;
    }
    if ($assign->get_instance()->teamsubmission && !$assign->can_view_group_submission($groupid)) {
        return false;
    }
    if (!$assign->get_instance()->teamsubmission && !$assign->can_view_submission($userid)) {
        return false;
    }
    $relativepath = implode('/', $args);
    $fullpath = "/{$context->id}/assignsubmission_onenote/{$filearea}/{$itemid}/{$relativepath}";
    $fs = get_file_storage();
    if (!($file = $fs->get_file_by_hash(sha1($fullpath))) || $file->is_directory()) {
        return false;
    }
    // Download MUST be forced - security!
    send_stored_file($file, 0, 0, true);
}
开发者ID:eugeneventer,项目名称:o365-moodle,代码行数:42,代码来源:lib.php

示例3: assignsubmission_comments_comment_permissions

/**
 * Permission control method for submission plugin ---- required method for AJAXmoodle based comment API
 *
 * @param stdClass $options
 * @return array
 */
function assignsubmission_comments_comment_permissions(stdClass $options)
{
    global $USER, $CFG, $DB;
    if ($options->commentarea != 'submission_comments' && $options->commentarea != 'submission_comments_upgrade') {
        throw new comment_exception('invalidcommentarea');
    }
    if (!($submission = $DB->get_record('assign_submission', array('id' => $options->itemid)))) {
        throw new comment_exception('invalidcommentitemid');
    }
    $context = $options->context;
    require_once $CFG->dirroot . '/mod/assign/locallib.php';
    $assignment = new assign($context, null, null);
    if ($assignment->get_instance()->id != $submission->assignment) {
        throw new comment_exception('invalidcontext');
    }
    if ($assignment->get_instance()->teamsubmission && !$assignment->can_view_group_submission($submission->groupid)) {
        return array('post' => false, 'view' => false);
    }
    if (!$assignment->get_instance()->teamsubmission && !$assignment->can_view_submission($submission->userid)) {
        return array('post' => false, 'view' => false);
    }
    return array('post' => true, 'view' => true);
}
开发者ID:pzhu2004,项目名称:moodle,代码行数:29,代码来源:lib.php

示例4:

use assignfeedback_editpdf\page_editor;
use assignfeedback_editpdf\comments_quick_list;
define('AJAX_SCRIPT', true);
require '../../../../config.php';
require_once $CFG->dirroot . '/mod/assign/locallib.php';
require_sesskey();
$action = optional_param('action', '', PARAM_ALPHANUM);
$assignmentid = required_param('assignmentid', PARAM_INT);
$userid = required_param('userid', PARAM_INT);
$attemptnumber = required_param('attemptnumber', PARAM_INT);
$readonly = optional_param('readonly', false, PARAM_BOOL);
$cm = \get_coursemodule_from_instance('assign', $assignmentid, 0, false, MUST_EXIST);
$context = \context_module::instance($cm->id);
$assignment = new \assign($context, null, null);
require_login($assignment->get_course(), false, $cm);
if (!$assignment->can_view_submission($userid)) {
    print_error('nopermission');
}
if ($action == 'loadallpages') {
    $draft = true;
    if (!has_capability('mod/assign:grade', $context)) {
        $draft = false;
        $readonly = true;
        // A student always sees the readonly version.
        require_capability('mod/assign:submit', $context);
    }
    // Whoever is viewing the readonly version should not use the drafts, but the actual annotations.
    if ($readonly) {
        $draft = false;
    }
    $pages = document_services::get_page_images_for_attempt($assignment, $userid, $attemptnumber, $readonly);
开发者ID:janeklb,项目名称:moodle,代码行数:31,代码来源:ajax.php

示例5: get_submission_status

 /**
  * Returns information about an assignment submission status for a given user.
  *
  * @param int $assignid assignment instance id
  * @param int $userid user id (empty for current user)
  * @return array of warnings and grading, status, feedback and previous attempts information
  * @since Moodle 3.1
  * @throws required_capability_exception
  */
 public static function get_submission_status($assignid, $userid = 0)
 {
     global $USER, $DB;
     $warnings = array();
     $params = array('assignid' => $assignid, 'userid' => $userid);
     $params = self::validate_parameters(self::get_submission_status_parameters(), $params);
     // Request and permission validation.
     $assign = $DB->get_record('assign', array('id' => $params['assignid']), 'id', MUST_EXIST);
     list($course, $cm) = get_course_and_cm_from_instance($assign, 'assign');
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     $assign = new assign($context, $cm, $course);
     // Default value for userid.
     if (empty($params['userid'])) {
         $params['userid'] = $USER->id;
     }
     $user = core_user::get_user($params['userid'], '*', MUST_EXIST);
     core_user::require_active_user($user);
     if (!$assign->can_view_submission($user->id)) {
         throw new required_capability_exception($context, 'mod/assign:viewgrades', 'nopermission', '');
     }
     $gradingsummary = $lastattempt = $feedback = $previousattempts = null;
     // Get the renderable since it contais all the info we need.
     if ($assign->can_view_grades()) {
         $gradingsummary = $assign->get_assign_grading_summary_renderable();
     }
     // Retrieve the rest of the renderable objects.
     if (has_capability('mod/assign:submit', $assign->get_context(), $user)) {
         $lastattempt = $assign->get_assign_submission_status_renderable($user, true);
     }
     $feedback = $assign->get_assign_feedback_status_renderable($user);
     $previousattempts = $assign->get_assign_attempt_history_renderable($user);
     // Now, build the result.
     $result = array();
     // First of all, grading summary, this is suitable for teachers/managers.
     if ($gradingsummary) {
         $result['gradingsummary'] = $gradingsummary;
     }
     // Did we submit anything?
     if ($lastattempt) {
         $submissionplugins = $assign->get_submission_plugins();
         if (empty($lastattempt->submission)) {
             unset($lastattempt->submission);
         } else {
             $lastattempt->submission->plugins = self::get_plugins_data($assign, $submissionplugins, $lastattempt->submission);
         }
         if (empty($lastattempt->teamsubmission)) {
             unset($lastattempt->teamsubmission);
         } else {
             $lastattempt->teamsubmission->plugins = self::get_plugins_data($assign, $submissionplugins, $lastattempt->teamsubmission);
         }
         // We need to change the type of some of the structures retrieved from the renderable.
         if (!empty($lastattempt->submissiongroup)) {
             $lastattempt->submissiongroup = $lastattempt->submissiongroup->id;
         } else {
             unset($lastattempt->submissiongroup);
         }
         if (!empty($lastattempt->usergroups)) {
             $lastattempt->usergroups = array_keys($lastattempt->usergroups);
         }
         // We cannot use array_keys here.
         if (!empty($lastattempt->submissiongroupmemberswhoneedtosubmit)) {
             $lastattempt->submissiongroupmemberswhoneedtosubmit = array_map(function ($e) {
                 return $e->id;
             }, $lastattempt->submissiongroupmemberswhoneedtosubmit);
         }
         $result['lastattempt'] = $lastattempt;
     }
     // The feedback for our latest submission.
     if ($feedback) {
         if ($feedback->grade) {
             $feedbackplugins = $assign->get_feedback_plugins();
             $feedback->plugins = self::get_plugins_data($assign, $feedbackplugins, $feedback->grade);
         } else {
             unset($feedback->plugins);
             unset($feedback->grade);
         }
         $result['feedback'] = $feedback;
     }
     // Retrieve only previous attempts.
     if ($previousattempts and count($previousattempts->submissions) > 1) {
         // Don't show the last one because it is the current submission.
         array_pop($previousattempts->submissions);
         // Show newest to oldest.
         $previousattempts->submissions = array_reverse($previousattempts->submissions);
         foreach ($previousattempts->submissions as $i => $submission) {
             $attempt = array();
             $grade = null;
             foreach ($previousattempts->grades as $onegrade) {
                 if ($onegrade->attemptnumber == $submission->attemptnumber) {
                     $grade = $onegrade;
//.........这里部分代码省略.........
开发者ID:jackdaniels79,项目名称:moodle,代码行数:101,代码来源:externallib.php

示例6: grading_popup

 /**
  * Makes the grading interface for the pop up. Robbed from /mod/assign/locallib.php
  * line 1583ish - view_single_grade_page().
  *
  * @param array $params From $_GET
  * @param object $coursemodule The coursemodule object that the user has been authenticated
  * against
  * @param bool $data
  * @throws coding_exception
  * @global $PAGE
  * @global stdClass $CFG
  * @global moodle_database $DB
  * @global $OUTPUT
  * @global stdClass $USER
  * @return string
  */
 public function grading_popup($params, $coursemodule, $data = false)
 {
     global $PAGE, $CFG, $DB;
     $modulecontext = context_module::instance($coursemodule->id);
     $course = $DB->get_record('course', array('id' => $coursemodule->course));
     $coursecontext = context_course::instance($course->id);
     $assign = new assign($modulecontext, $coursemodule, $course);
     /* @var mod_assign_renderer $renderer */
     $renderer = $PAGE->get_renderer('mod_assign');
     $output = '';
     // Include grade form.
     require_once $CFG->dirroot . '/mod/assign/gradeform.php';
     // Need submit permission to submit an assignment.
     require_capability('mod/assign:grade', $modulecontext);
     /* Pinched from private method assign::get_grading_userid_list() */
     $filter = get_user_preferences('assign_filter', '');
     $table = new assign_grading_table($assign, 0, $filter, 0, false);
     $useridlist = $table->get_column_data('userid');
     $userid = $params['userid'];
     $rownum = 0;
     foreach ($useridlist as $key => $useridinlist) {
         if ($useridinlist == $userid) {
             $rownum = $key;
             reset($useridlist);
             // Just in case.
             break;
         }
     }
     $last = false;
     if ($rownum == count($useridlist) - 1) {
         $last = true;
     }
     $user = $DB->get_record('user', array('id' => $userid));
     if ($user) {
         $output .= $renderer->render(new assign_user_summary($user, $course->id, has_capability('moodle/site:viewfullnames', $coursecontext)));
     }
     $submission = $DB->get_record('assign_submission', array('assignment' => $assign->get_instance()->id, 'userid' => $userid));
     // Get the current grade. Pinched from assign::get_user_grade().
     $grade = $DB->get_record('assign_grades', array('assignment' => $assign->get_instance()->id, 'userid' => $userid));
     // Pinched from assign::is_graded().
     $isgraded = !empty($grade) && $grade->grade !== null && $grade->grade >= 0;
     if ($assign->can_view_submission($userid)) {
         $gradelocked = $grade && $grade->locked || $assign->grading_disabled($userid);
         $widget = new assign_submission_status($assign->get_instance()->allowsubmissionsfromdate, $assign->get_instance()->alwaysshowdescription, $submission, $assign->is_any_submission_plugin_enabled(), $gradelocked, $isgraded, $assign->get_instance()->duedate, $assign->get_submission_plugins(), $assign->get_return_action(), $assign->get_return_params(), $assign->get_course_module()->id, assign_submission_status::GRADER_VIEW, false, false);
         $output .= $renderer->render($widget);
     }
     if ($grade) {
         $data = new stdClass();
         if ($grade->grade !== null && $grade->grade >= 0) {
             $data->grade = format_float($grade->grade, 2);
         }
     } else {
         $data = new stdClass();
         $data->grade = '';
     }
     // Now show the grading form.
     $customdata = array('useridlist' => $useridlist, 'rownum' => $rownum, 'last' => $last);
     $mform = new mod_assign_grade_form(block_ajax_marking_form_url($params), array($assign, $data, $customdata), 'post', '', array('class' => 'gradeform'));
     $output .= $renderer->render(new assign_form('gradingform', $mform));
     $assign->add_to_log('view grading form', get_string('viewgradingformforstudent', 'assign', array('id' => $user->id, 'fullname' => fullname($user))));
     return $output;
 }
开发者ID:nadavkav,项目名称:moodle-block_ajax_marking,代码行数:78,代码来源:block_ajax_marking_assign.class.php


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