~ubuntu-branches/ubuntu/trusty/moodle/trusty-proposed

« back to all changes in this revision

Viewing changes to mod/assign/locallib.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2013-09-09 15:22:35 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20130909152235-d9njbvgugzm380an
Tags: 2.5.2-1
* New upstream version: 2.5.2.
  - Incorporates S3 security patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1144
1144
                if ($grade < 0) {
1145
1145
                    $displaygrade = '';
1146
1146
                } else {
1147
 
                    $displaygrade = format_float($grade);
 
1147
                    $displaygrade = format_float($grade, 2);
1148
1148
                }
1149
1149
                $o .= '<label class="accesshide" for="quickgrade_' . $userid . '">' .
1150
1150
                       get_string('usergrade', 'assign') .
3394
3394
                // Only show the grade if it is not hidden in gradebook.
3395
3395
                if (!empty($gradebookgrade->grade) && ($cangrade || !$gradebookgrade->hidden)) {
3396
3396
                    if ($controller = $gradingmanager->get_active_controller()) {
3397
 
                        $controller->set_grade_range(make_grades_menu($this->get_instance()->grade));
 
3397
                        $controller->set_grade_range(make_grades_menu($this->get_instance()->grade), $this->get_instance()->grade > 0);
3398
3398
                        $gradefordisplay = $controller->render_grade($PAGE,
3399
3399
                                                                     $grade->id,
3400
3400
                                                                     $gradingitem,
3491
3491
 
3492
3492
            // Now get the gradefordisplay.
3493
3493
            if ($controller) {
3494
 
                $controller->set_grade_range(make_grades_menu($this->get_instance()->grade));
 
3494
                $controller->set_grade_range(make_grades_menu($this->get_instance()->grade), $this->get_instance()->grade > 0);
3495
3495
                $grade->gradefordisplay = $controller->render_grade($PAGE,
3496
3496
                                                                     $grade->id,
3497
3497
                                                                     $gradingitem,
3660
3660
                $team = groups_get_members($submission->groupid, 'u.id');
3661
3661
 
3662
3662
                foreach ($team as $member) {
3663
 
                    $submission->groupid = 0;
3664
 
                    $submission->userid = $member->id;
3665
 
                    $this->gradebook_item_update($submission, null);
 
3663
                    $membersubmission = clone $submission;
 
3664
                    $membersubmission->groupid = 0;
 
3665
                    $membersubmission->userid = $member->id;
 
3666
                    $this->gradebook_item_update($membersubmission, null);
3666
3667
                }
3667
3668
                return;
3668
3669
            }
3846
3847
            }
3847
3848
        }
3848
3849
 
3849
 
        if ($this->grading_disabled($userid)) {
 
3850
        // See if this user grade is locked in the gradebook.
 
3851
        $gradinginfo = grade_get_grades($this->get_course()->id,
 
3852
                                        'mod',
 
3853
                                        'assign',
 
3854
                                        $this->get_instance()->id,
 
3855
                                        array($userid));
 
3856
        if ($gradinginfo &&
 
3857
                isset($gradinginfo->items[0]->grades[$userid]) &&
 
3858
                $gradinginfo->items[0]->grades[$userid]->locked) {
3850
3859
            return false;
3851
3860
        }
3852
3861
 
4842
4851
 
4843
4852
 
4844
4853
    /**
4845
 
     * Determine if this users grade is locked or overridden.
 
4854
     * Determine if this users grade can be edited.
4846
4855
     *
4847
4856
     * @param int $userid - The student userid
4848
4857
     * @return bool $gradingdisabled
4880
4889
        global $CFG, $USER;
4881
4890
 
4882
4891
        $grademenu = make_grades_menu($this->get_instance()->grade);
 
4892
        $allowgradedecimals = $this->get_instance()->grade > 0;
4883
4893
 
4884
4894
        $advancedgradingwarning = false;
4885
4895
        $gradingmanager = get_grading_manager($this->context, 'mod_assign', 'submissions');
4904
4914
            }
4905
4915
        }
4906
4916
        if ($gradinginstance) {
4907
 
            $gradinginstance->get_controller()->set_grade_range($grademenu);
 
4917
            $gradinginstance->get_controller()->set_grade_range($grademenu, $allowgradedecimals);
4908
4918
        }
4909
4919
        return $gradinginstance;
4910
4920
    }
4968
4978
            // Use simple direct grading.
4969
4979
            if ($this->get_instance()->grade > 0) {
4970
4980
                $name = get_string('gradeoutof', 'assign', $this->get_instance()->grade);
4971
 
                $gradingelement = $mform->addElement('text', 'grade', $name);
4972
 
                $mform->addHelpButton('grade', 'gradeoutofhelp', 'assign');
4973
 
                $mform->setType('grade', PARAM_TEXT);
4974
 
                if ($gradingdisabled) {
4975
 
                    $gradingelement->freeze();
 
4981
                if (!$gradingdisabled) {
 
4982
                    $gradingelement = $mform->addElement('text', 'grade', $name);
 
4983
                    $mform->addHelpButton('grade', 'gradeoutofhelp', 'assign');
 
4984
                    $mform->setType('grade', PARAM_RAW);
 
4985
                } else {
 
4986
                    $mform->addElement('hidden', 'grade', $name);
 
4987
                    $mform->hardFreeze('grade');
 
4988
                    $mform->setType('grade', PARAM_RAW);
 
4989
                    $strgradelocked = get_string('gradelocked', 'assign');
 
4990
                    $mform->addElement('static', 'gradedisabled', $name, $strgradelocked);
 
4991
                    $mform->addHelpButton('gradedisabled', 'gradeoutofhelp', 'assign');
4976
4992
                }
4977
4993
            } else {
4978
4994
                $grademenu = make_grades_menu($this->get_instance()->grade);
5309
5325
 
5310
5326
        // Give each submission plugin a chance to process the locking.
5311
5327
        $plugins = $this->get_submission_plugins();
5312
 
        $submission = $this->get_user_submission($userid, false);
 
5328
        $submission = $this->get_user_submission($userid, true);
5313
5329
        foreach ($plugins as $plugin) {
5314
5330
            if ($plugin->is_enabled() && $plugin->is_visible()) {
5315
5331
                $plugin->lock($submission);
5346
5362
        }
5347
5363
        // Give each submission plugin a chance to process the unlocking.
5348
5364
        $plugins = $this->get_submission_plugins();
5349
 
        $submission = $this->get_user_submission($userid, false);
 
5365
        $submission = $this->get_user_submission($userid, true);
5350
5366
        foreach ($plugins as $plugin) {
5351
5367
            if ($plugin->is_enabled() && $plugin->is_visible()) {
5352
5368
                $plugin->unlock($submission);