mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
mod-assignment MDL-23848 Merged to head: students can now view previously submit assignments if they no longer have the submit capability.
This commit is contained in:
parent
c971c34c71
commit
c7bb34b626
4 changed files with 28 additions and 15 deletions
|
@ -199,6 +199,7 @@ $string['uploadnofilefound'] = 'No file was found - are you sure you selected on
|
|||
$string['uploadnotregistered'] = '\'{$a}\' was uploaded OK but submission did not register!';
|
||||
$string['uploadsuccess'] = 'Uploaded \'{$a}\' successfully';
|
||||
$string['usermisconf'] = 'User is misconfigured';
|
||||
$string['usernosubmit'] = 'Sorry, you are not allowed to submit an assignment.';
|
||||
$string['viewfeedback'] = 'View assignment grades and feedback';
|
||||
$string['viewmysubmission'] = 'View my submission';
|
||||
$string['viewsubmissions'] = 'View {$a} submitted assignments';
|
||||
|
|
|
@ -262,7 +262,7 @@ class assignment_base {
|
|||
global $USER, $CFG, $DB, $OUTPUT;
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
|
||||
if (!is_enrolled($this->context, $USER, 'mod/assignment:submit')) {
|
||||
if (!is_enrolled($this->context, $USER, 'mod/assignment:view')) {
|
||||
// can not submit assignments -> no feedback
|
||||
return;
|
||||
}
|
||||
|
@ -270,6 +270,15 @@ class assignment_base {
|
|||
if (!$submission) { /// Get submission for this assignment
|
||||
$submission = $this->get_submission($USER->id);
|
||||
}
|
||||
// Check the user can submit
|
||||
$cansubmit = has_capability('mod/assignment:submit', $this->context, $USER->id, false);
|
||||
// If not then check if ther user still has the view cap and has a previous submission
|
||||
$cansubmit = $cansubmit || (!empty($submission) && has_capability('mod/assignment:view', $this->context, $USER->id, false));
|
||||
|
||||
if (!$cansubmit) {
|
||||
// can not submit assignments -> no feedback
|
||||
return;
|
||||
}
|
||||
|
||||
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, $USER->id);
|
||||
$item = $grading_info->items[0];
|
||||
|
@ -938,16 +947,17 @@ class assignment_base {
|
|||
/// Get all ppl that can submit assignments
|
||||
|
||||
$currentgroup = groups_get_activity_group($cm);
|
||||
if ($users = get_enrolled_users($context, 'mod/assignment:submit', $currentgroup, 'u.id')) {
|
||||
$gradebookroles = explode(",", $CFG->gradebookroles);
|
||||
$users = get_enrolled_users($context, 'mod/assignment:view', $currentgroup, 'u.id');
|
||||
if ($users) {
|
||||
$users = array_keys($users);
|
||||
}
|
||||
|
||||
// if groupmembersonly used, remove users who are not in any group
|
||||
if ($users and !empty($CFG->enablegroupmembersonly) and $cm->groupmembersonly) {
|
||||
if (!empty($CFG->enablegroupmembersonly) and $cm->groupmembersonly) {
|
||||
if ($groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id')) {
|
||||
$users = array_intersect($users, array_keys($groupingusers));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nextid = 0;
|
||||
$where = '';
|
||||
|
@ -1162,7 +1172,7 @@ class assignment_base {
|
|||
groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/assignment/submissions.php?id=' . $this->cm->id);
|
||||
|
||||
/// Get all ppl that are allowed to submit assignments
|
||||
list($esql, $params) = get_enrolled_sql($context, 'mod/assignment:submit', $currentgroup);
|
||||
list($esql, $params) = get_enrolled_sql($context, 'mod/assignment:view', $currentgroup);
|
||||
|
||||
if ($filter == self::FILTER_ALL) {
|
||||
$sql = "SELECT u.id FROM {user} u ".
|
||||
|
@ -3208,7 +3218,7 @@ function assignment_count_real_submissions($cm, $groupid=0) {
|
|||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
// this is all the users with this capability set, in this context or higher
|
||||
if ($users = get_enrolled_users($context, 'mod/assignment:submit', $groupid, 'u.id')) {
|
||||
if ($users = get_enrolled_users($context, 'mod/assignment:view', $groupid, 'u.id')) {
|
||||
$users = array_keys($users);
|
||||
}
|
||||
|
||||
|
@ -3415,7 +3425,7 @@ function assignment_print_overview($courses, &$htmlarray) {
|
|||
|
||||
// count how many people can submit
|
||||
$submissions = 0; // init
|
||||
if ($students = get_enrolled_users($context, 'mod/assignment:submit', 0, 'u.id')) {
|
||||
if ($students = get_enrolled_users($context, 'mod/assignment:view', 0, 'u.id')) {
|
||||
foreach ($students as $student) {
|
||||
if (isset($unmarkedsubmissions[$assignment->id][$student->id])) {
|
||||
$submissions++;
|
||||
|
|
|
@ -79,7 +79,7 @@ class assignment_online extends assignment_base {
|
|||
if ($editmode) {
|
||||
$this->view_header(get_string('editmysubmission', 'assignment'));
|
||||
} else {
|
||||
$this->view_header();
|
||||
$this->view_header(get_string('viewsubmissions', 'assignment'));
|
||||
}
|
||||
|
||||
$this->view_intro();
|
||||
|
@ -90,7 +90,7 @@ class assignment_online extends assignment_base {
|
|||
echo $OUTPUT->notification(get_string('submissionsaved', 'assignment'), 'notifysuccess');
|
||||
}
|
||||
|
||||
if (is_enrolled($this->context, $USER, 'mod/assignment:submit')) {
|
||||
if (is_enrolled($this->context, $USER)) {
|
||||
if ($editmode) {
|
||||
echo $OUTPUT->box_start('generalbox', 'onlineenter');
|
||||
$mform->display();
|
||||
|
|
|
@ -61,7 +61,7 @@ class assignment_upload extends assignment_base {
|
|||
|
||||
$this->view_dates();
|
||||
|
||||
if (is_enrolled($this->context, $USER, 'mod/assignment:submit')) {
|
||||
if (is_enrolled($this->context, $USER)) {
|
||||
if ($submission = $this->get_submission($USER->id)) {
|
||||
$filecount = $this->count_user_files($submission->id);
|
||||
} else {
|
||||
|
@ -86,7 +86,9 @@ class assignment_upload extends assignment_base {
|
|||
}
|
||||
}
|
||||
|
||||
if (has_capability('mod/assignment:submit', $this->context)) {
|
||||
$this->view_upload_form();
|
||||
}
|
||||
|
||||
if ($this->notes_allowed()) {
|
||||
echo $OUTPUT->heading(get_string('notes', 'assignment'), 3);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue