コード例 #1
0
ファイル: lib.php プロジェクト: Gavinthisisit/Moodle
/**
 * Print a detailed representation of what a user has done with
 * a given particular instance of this module, for user activity reports.
 *
 * @param stdClass $course The course record.
 * @param stdClass $user The user record.
 * @param cm_info|stdClass $mod The course module info object or record.
 * @param stdClass $teamwork The teamwork instance record.
 * @return string HTML
 */
function teamwork_user_complete($course, $user, $mod, $teamwork)
{
    global $CFG, $DB, $OUTPUT;
    require_once dirname(__FILE__) . '/locallib.php';
    require_once $CFG->libdir . '/gradelib.php';
    $teamwork = new teamwork($teamwork, $mod, $course);
    $grades = grade_get_grades($course->id, 'mod', 'teamwork', $teamwork->id, $user->id);
    if (!empty($grades->items[0]->grades)) {
        $submissiongrade = reset($grades->items[0]->grades);
        $info = get_string('submissiongrade', 'teamwork') . ': ' . $submissiongrade->str_long_grade;
        echo html_writer::tag('li', $info, array('class' => 'submissiongrade'));
    }
    if (!empty($grades->items[1]->grades)) {
        $assessmentgrade = reset($grades->items[1]->grades);
        $info = get_string('gradinggrade', 'teamwork') . ': ' . $assessmentgrade->str_long_grade;
        echo html_writer::tag('li', $info, array('class' => 'gradinggrade'));
    }
    if (has_capability('mod/teamwork:viewallsubmissions', $teamwork->context)) {
        $canviewsubmission = true;
        if (groups_get_activity_groupmode($teamwork->cm) == SEPARATEGROUPS) {
            // user must have accessallgroups or share at least one group with the submission author
            if (!has_capability('moodle/site:accessallgroups', $teamwork->context)) {
                $usersgroups = groups_get_activity_allowed_groups($teamwork->cm);
                $authorsgroups = groups_get_all_groups($teamwork->course->id, $user->id, $teamwork->cm->groupingid, 'g.id');
                $sharedgroups = array_intersect_key($usersgroups, $authorsgroups);
                if (empty($sharedgroups)) {
                    $canviewsubmission = false;
                }
            }
        }
        if ($canviewsubmission and $submission = $teamwork->get_submission_by_author($user->id)) {
            $title = format_string($submission->title);
            $url = $teamwork->submission_url($submission->id);
            $link = html_writer::link($url, $title);
            $info = get_string('submission', 'teamwork') . ': ' . $link;
            echo html_writer::tag('li', $info, array('class' => 'submission'));
        }
    }
    if (has_capability('mod/teamwork:viewallassessments', $teamwork->context)) {
        if ($assessments = $teamwork->get_assessments_by_reviewer($user->id)) {
            foreach ($assessments as $assessment) {
                $a = new stdclass();
                $a->submissionurl = $teamwork->submission_url($assessment->submissionid)->out();
                $a->assessmenturl = $teamwork->assess_url($assessment->id)->out();
                $a->submissiontitle = s($assessment->submissiontitle);
                echo html_writer::tag('li', get_string('assessmentofsubmission', 'teamwork', $a));
            }
        }
    }
}
コード例 #2
0
ファイル: assessment.php プロジェクト: Gavinthisisit/Moodle
 */
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once dirname(__FILE__) . '/locallib.php';
$asid = required_param('asid', PARAM_INT);
// assessment id
$assessment = $DB->get_record('teamwork_assessments', array('id' => $asid), '*', MUST_EXIST);
$submission = $DB->get_record('teamwork_submissions', array('id' => $assessment->submissionid, 'example' => 0), '*', MUST_EXIST);
$teamwork = $DB->get_record('teamwork', array('id' => $submission->teamworkid), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $teamwork->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('teamwork', $teamwork->id, $course->id, false, MUST_EXIST);
require_login($course, false, $cm);
if (isguestuser()) {
    print_error('guestsarenotallowed');
}
$teamwork = new teamwork($teamwork, $cm, $course);
$PAGE->set_url($teamwork->assess_url($assessment->id));
$PAGE->set_title($teamwork->name);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add(get_string('assessingsubmission', 'teamwork'));
$canviewallassessments = has_capability('mod/teamwork:viewallassessments', $teamwork->context);
$canviewallsubmissions = has_capability('mod/teamwork:viewallsubmissions', $teamwork->context);
$cansetassessmentweight = has_capability('mod/teamwork:allocate', $teamwork->context);
$canoverridegrades = has_capability('mod/teamwork:overridegrades', $teamwork->context);
$isreviewer = $USER->id == $assessment->reviewerid;
$isauthor = $USER->id == $submission->authorid;
if ($canviewallsubmissions) {
    // check this flag against the group membership yet
    if (groups_get_activity_groupmode($teamwork->cm) == SEPARATEGROUPS) {
        // user must have accessallgroups or share at least one group with the submission author
        if (!has_capability('moodle/site:accessallgroups', $teamwork->context)) {
            $usersgroups = groups_get_activity_allowed_groups($teamwork->cm);