Permalink
Browse files

Merge branch 'MOODLE_20_STABLE' of git://git.moodle.org/integration i…

…nto MOODLE_20_STABLE
  • Loading branch information...
2 parents eb4e049 + f909700 commit 44aba13a35b9de23d91c3ba8cba4747a7287320d @nebgor nebgor committed Oct 31, 2011
View
@@ -955,7 +955,7 @@ function display_submission($offset=-1,$userid =-1, $display=true) {
/// Get all ppl that can submit assignments
$currentgroup = groups_get_activity_group($cm);
- $users = get_enrolled_users($context, 'mod/assignment:view', $currentgroup, 'u.id');
+ $users = get_enrolled_users($context, 'mod/assignment:submit', $currentgroup, 'u.id');
if ($users) {
$users = array_keys($users);
// if groupmembersonly used, remove users who are not in any group
@@ -44,6 +44,7 @@ function view() {
global $USER, $OUTPUT;
require_capability('mod/assignment:view', $this->context);
+ $cansubmit = has_capability('mod/assignment:submit', $this->context);
add_to_log($this->course->id, 'assignment', 'view', "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id);
@@ -67,35 +68,34 @@ function view() {
} else {
$filecount = 0;
}
+ if ($cansubmit or !empty($filecount)) { //if a user has submitted files using a previous role we should still show the files
+ $this->view_feedback();
- $this->view_feedback();
-
- if (!$this->drafts_tracked() or !$this->isopen() or $this->is_finalized($submission)) {
- echo $OUTPUT->heading(get_string('submission', 'assignment'), 3);
- } else {
- echo $OUTPUT->heading(get_string('submissiondraft', 'assignment'), 3);
- }
+ if (!$this->drafts_tracked() or !$this->isopen() or $this->is_finalized($submission)) {
+ echo $OUTPUT->heading(get_string('submission', 'assignment'), 3);
+ } else {
+ echo $OUTPUT->heading(get_string('submissiondraft', 'assignment'), 3);
+ }
- if ($filecount and $submission) {
- echo $OUTPUT->box($this->print_user_files($USER->id, true), 'generalbox boxaligncenter', 'userfiles');
- } else {
- if (!$this->isopen() or $this->is_finalized($submission)) {
- echo $OUTPUT->box(get_string('nofiles', 'assignment'), 'generalbox boxaligncenter nofiles', 'userfiles');
+ if ($filecount and $submission) {
+ echo $OUTPUT->box($this->print_user_files($USER->id, true), 'generalbox boxaligncenter', 'userfiles');
} else {
- echo $OUTPUT->box(get_string('nofilesyet', 'assignment'), 'generalbox boxaligncenter nofiles', 'userfiles');
+ if (!$this->isopen() or $this->is_finalized($submission)) {
+ echo $OUTPUT->box(get_string('nofiles', 'assignment'), 'generalbox boxaligncenter nofiles', 'userfiles');
+ } else {
+ echo $OUTPUT->box(get_string('nofilesyet', 'assignment'), 'generalbox boxaligncenter nofiles', 'userfiles');
+ }
}
- }
- if (has_capability('mod/assignment:submit', $this->context)) {
$this->view_upload_form();
- }
- if ($this->notes_allowed()) {
- echo $OUTPUT->heading(get_string('notes', 'assignment'), 3);
- $this->view_notes();
- }
+ if ($this->notes_allowed()) {
+ echo $OUTPUT->heading(get_string('notes', 'assignment'), 3);
+ $this->view_notes();
+ }
- $this->view_final_submission();
+ $this->view_final_submission();
+ }
}
$this->view_footer();
}
@@ -50,6 +50,12 @@ protected function definition_inner(&$mform) {
$mform->addElement('hidden', 'nodims', $nodims);
$mform->setType('nodims', PARAM_INT);
+ // minimal grade value to select - used by the 'compare' rule below
+ // (just an implementation detail to make the rule work, this element is
+ // not processed by the server)
+ $mform->addElement('hidden', 'minusone', -1);
+ $mform->setType('minusone', PARAM_INT);
+
for ($i = 0; $i < $nodims; $i++) {
// dimension header
$dimtitle = get_string('dimensionnumber', 'workshopform_accumulative', $i+1);
@@ -72,7 +78,9 @@ protected function definition_inner(&$mform) {
// grade for this aspect
$label = get_string('dimensiongrade', 'workshopform_accumulative');
$options = make_grades_menu($fields->{'grade__idx_' . $i});
+ $options = array('-1' => get_string('choosedots')) + $options;
$mform->addElement('select', 'grade__idx_' . $i, $label, $options);
+ $mform->addRule(array('grade__idx_' . $i, 'minusone') , get_string('mustchoosegrade', 'workshopform_accumulative'), 'compare', 'gt');
// comment
$label = get_string('dimensioncomment', 'workshopform_accumulative');
@@ -36,6 +36,7 @@
$string['excellent'] = 'Excellent';
$string['good'] = 'Good';
$string['incorrect'] = 'Incorrect';
+$string['mustchoosegrade'] = 'You have to select a grade for this aspect';
$string['pluginname'] = 'Accumulative grading';
$string['poor'] = 'Poor';
$string['present'] = 'Present';
@@ -71,9 +71,11 @@ protected function definition_inner(&$mform) {
// evaluation of the assertion
$label = get_string('dimensiongrade', 'workshopform_numerrors');
- $mform->addElement('radio', 'grade__idx_' . $i, get_string('yourassessment', 'workshop'), $fields->{'grade0__idx_'.$i}, 0);
- $mform->addElement('radio', 'grade__idx_' . $i, '', $fields->{'grade1__idx_'.$i}, 1);
- $mform->setDefault('grade__idx_' . $i, 0);
+ $mform->addGroup(array(
+ $mform->createElement('radio', 'grade__idx_' . $i, '', $fields->{'grade0__idx_'.$i}, -1),
+ $mform->createElement('radio', 'grade__idx_' . $i, '', $fields->{'grade1__idx_'.$i}, 1),
+ ), 'group_grade__idx_' . $i, get_string('yourassessment', 'workshop'), '<br />', false);
+ $mform->addRule('group_grade__idx_' . $i, get_string('required'), 'required');
// comment
$label = get_string('dimensioncomment', 'workshopform_numerrors');
@@ -252,7 +252,7 @@ public function get_assessment_form(moodle_url $actionurl=null, $mode='preview',
$dimid = $fields->{'dimensionid__idx_'.$i};
if (isset($grades[$dimid])) {
$current->{'gradeid__idx_'.$i} = $grades[$dimid]->id;
- $current->{'grade__idx_'.$i} = $grades[$dimid]->grade;
+ $current->{'grade__idx_'.$i} = ($grades[$dimid]->grade == 0 ? -1 : 1);
$current->{'peercomment__idx_'.$i} = $grades[$dimid]->peercomment;
}
}
@@ -294,7 +294,7 @@ public function save_assessment(stdclass $assessment, stdclass $data) {
$grade->assessmentid = $assessment->id;
$grade->strategy = 'numerrors';
$grade->dimensionid = $data->{'dimensionid__idx_' . $i};
- $grade->grade = $data->{'grade__idx_' . $i};
+ $grade->grade = ($data->{'grade__idx_' . $i} <= 0 ? 0 : 1);
$grade->peercomment = $data->{'peercomment__idx_' . $i};
$grade->peercommentformat = FORMAT_HTML;
if (empty($grade->id)) {

0 comments on commit 44aba13

Please sign in to comment.