本文整理汇总了PHP中assign::require_view_grades方法的典型用法代码示例。如果您正苦于以下问题:PHP assign::require_view_grades方法的具体用法?PHP assign::require_view_grades怎么用?PHP assign::require_view_grades使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assign
的用法示例。
在下文中一共展示了assign::require_view_grades方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view_grading_table
/**
* Trigger the grading_table_viewed event.
*
* @param int $assignid the assign instance id
* @return array of warnings and status result
* @since Moodle 3.0
* @throws moodle_exception
*/
public static function view_grading_table($assignid)
{
global $DB, $CFG;
require_once $CFG->dirroot . "/mod/assign/locallib.php";
$params = self::validate_parameters(self::view_grading_table_parameters(), array('assignid' => $assignid));
$warnings = array();
// 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);
require_capability('mod/assign:view', $context);
$assign = new assign($context, null, null);
$assign->require_view_grades();
\mod_assign\event\grading_table_viewed::create_from_assign($assign)->trigger();
$result = array();
$result['status'] = true;
$result['warnings'] = $warnings;
return $result;
}
示例2: get_participant
/**
* Get the user participating in the given assignment. An error with code 'usernotincourse'
* is thrown is the user isn't a participant of the given assignment.
*
* @param int $assignid the assign instance id
* @param int $userid the user id
* @param bool $embeduser return user details (only applicable if not blind marking)
* @return array of warnings and status result
* @since Moodle 3.1
* @throws moodle_exception
*/
public static function get_participant($assignid, $userid, $embeduser)
{
global $DB, $CFG;
require_once $CFG->dirroot . "/mod/assign/locallib.php";
require_once $CFG->dirroot . "/user/lib.php";
$params = self::validate_parameters(self::get_participant_parameters(), array('assignid' => $assignid, 'userid' => $userid, 'embeduser' => $embeduser));
// 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, null, null);
$assign->require_view_grades();
$participant = $assign->get_participant($params['userid']);
if (!$participant) {
// No participant found so we can return early.
throw new moodle_exception('usernotincourse');
}
$return = array('id' => $participant->id, 'fullname' => $participant->fullname, 'submitted' => $participant->submitted, 'requiregrading' => $participant->requiregrading, 'blindmarking' => $assign->is_blind_marking());
if (!empty($participant->groupid)) {
$return['groupid'] = $participant->groupid;
}
if (!empty($participant->groupname)) {
$return['groupname'] = $participant->groupname;
}
// Skip the expensive lookup of user detail if we're blind marking or the caller
// hasn't asked for user details to be embedded.
if (!$assign->is_blind_marking() && $embeduser) {
$return['user'] = user_get_user_details($participant, $course);
}
return $return;
}