MDL-27161: fixed optional setting for 'require grading' to prevent page lock out
This commit is contained in:
@@ -150,6 +150,8 @@ $string['notes'] = 'Notes';
|
||||
$string['notesempty'] = 'No entry';
|
||||
$string['notesupdateerror'] = 'Error when updating notes';
|
||||
$string['notgradedyet'] = 'Not graded yet';
|
||||
$string['norequiregrading'] = 'There are no assignments required grading';
|
||||
$string['nosubmisson'] = 'There are no assignments has been submitted';
|
||||
$string['notsubmittedyet'] = 'Not submitted yet';
|
||||
$string['onceassignmentsent'] = 'Once the assignment is sent for marking, you will no longer be able to delete or attach file(s). Do you want to continue?';
|
||||
$string['operation'] = 'Operation';
|
||||
|
||||
+145
-141
@@ -1128,6 +1128,7 @@ class assignment_base {
|
||||
$course = $this->course;
|
||||
$assignment = $this->assignment;
|
||||
$cm = $this->cm;
|
||||
$hassubmission = false;
|
||||
|
||||
$tabindex = 1; //tabindex for quick grading tabbing; Not working for dropdowns yet
|
||||
add_to_log($course->id, 'assignment', 'view submission', 'submissions.php?id='.$this->cm->id, $this->assignment->id, $this->cm->id);
|
||||
@@ -1264,16 +1265,7 @@ class assignment_base {
|
||||
// Start working -- this is necessary as soon as the niceties are over
|
||||
$table->setup();
|
||||
|
||||
if (empty($users)) {
|
||||
echo $OUTPUT->heading(get_string('nosubmitusers','assignment'));
|
||||
echo '</div>';
|
||||
return true;
|
||||
}
|
||||
if ($this->assignment->assignmenttype=='upload' || $this->assignment->assignmenttype=='online' || $this->assignment->assignmenttype=='uploadsingle') { //TODO: this is an ugly hack, where is the plugin spirit? (skodak)
|
||||
echo '<div style="text-align:right"><a href="submissions.php?id='.$this->cm->id.'&download=zip">'.get_string('downloadall', 'assignment').'</a></div>';
|
||||
}
|
||||
/// Construct the SQL
|
||||
|
||||
list($where, $params) = $table->get_sql_where();
|
||||
if ($where) {
|
||||
$where .= ' AND ';
|
||||
@@ -1290,179 +1282,191 @@ class assignment_base {
|
||||
}
|
||||
|
||||
$ufields = user_picture::fields('u');
|
||||
if (!empty($users)) {
|
||||
$select = "SELECT $ufields,
|
||||
s.id AS submissionid, s.grade, s.submissioncomment,
|
||||
s.timemodified, s.timemarked,
|
||||
COALESCE(SIGN(SIGN(s.timemarked) + SIGN(s.timemarked - s.timemodified)), 0) AS status ";
|
||||
$sql = 'FROM {user} u '.
|
||||
'LEFT JOIN {assignment_submissions} s ON u.id = s.userid
|
||||
AND s.assignment = '.$this->assignment->id.' '.
|
||||
'WHERE '.$where.'u.id IN ('.implode(',',$users).') ';
|
||||
|
||||
$select = "SELECT $ufields,
|
||||
s.id AS submissionid, s.grade, s.submissioncomment,
|
||||
s.timemodified, s.timemarked,
|
||||
COALESCE(SIGN(SIGN(s.timemarked) + SIGN(s.timemarked - s.timemodified)), 0) AS status ";
|
||||
$sql = 'FROM {user} u '.
|
||||
'LEFT JOIN {assignment_submissions} s ON u.id = s.userid
|
||||
AND s.assignment = '.$this->assignment->id.' '.
|
||||
'WHERE '.$where.'u.id IN ('.implode(',',$users).') ';
|
||||
$ausers = $DB->get_records_sql($select.$sql.$sort, $params, $table->get_page_start(), $table->get_page_size());
|
||||
|
||||
$ausers = $DB->get_records_sql($select.$sql.$sort, $params, $table->get_page_start(), $table->get_page_size());
|
||||
$table->pagesize($perpage, count($users));
|
||||
|
||||
$table->pagesize($perpage, count($users));
|
||||
///offset used to calculate index of student in that particular query, needed for the pop up to know who's next
|
||||
$offset = $page * $perpage;
|
||||
$strupdate = get_string('update');
|
||||
$strgrade = get_string('grade');
|
||||
$grademenu = make_grades_menu($this->assignment->grade);
|
||||
|
||||
///offset used to calculate index of student in that particular query, needed for the pop up to know who's next
|
||||
$offset = $page * $perpage;
|
||||
$strupdate = get_string('update');
|
||||
$strgrade = get_string('grade');
|
||||
$grademenu = make_grades_menu($this->assignment->grade);
|
||||
if ($ausers !== false) {
|
||||
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array_keys($ausers));
|
||||
$endposition = $offset + $perpage;
|
||||
$currentposition = 0;
|
||||
foreach ($ausers as $auser) {
|
||||
if ($currentposition == $offset && $offset < $endposition) {
|
||||
$final_grade = $grading_info->items[0]->grades[$auser->id];
|
||||
$grademax = $grading_info->items[0]->grademax;
|
||||
$final_grade->formatted_grade = round($final_grade->grade,2) .' / ' . round($grademax,2);
|
||||
$locked_overridden = 'locked';
|
||||
if ($final_grade->overridden) {
|
||||
$locked_overridden = 'overridden';
|
||||
}
|
||||
|
||||
if ($ausers !== false) {
|
||||
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array_keys($ausers));
|
||||
$endposition = $offset + $perpage;
|
||||
$currentposition = 0;
|
||||
foreach ($ausers as $auser) {
|
||||
if ($currentposition == $offset && $offset < $endposition) {
|
||||
$final_grade = $grading_info->items[0]->grades[$auser->id];
|
||||
$grademax = $grading_info->items[0]->grademax;
|
||||
$final_grade->formatted_grade = round($final_grade->grade,2) .' / ' . round($grademax,2);
|
||||
$locked_overridden = 'locked';
|
||||
if ($final_grade->overridden) {
|
||||
$locked_overridden = 'overridden';
|
||||
}
|
||||
/// Calculate user status
|
||||
$auser->status = ($auser->timemarked > 0) && ($auser->timemarked >= $auser->timemodified);
|
||||
$picture = $OUTPUT->user_picture($auser);
|
||||
|
||||
/// Calculate user status
|
||||
$auser->status = ($auser->timemarked > 0) && ($auser->timemarked >= $auser->timemodified);
|
||||
$picture = $OUTPUT->user_picture($auser);
|
||||
if (empty($auser->submissionid)) {
|
||||
$auser->grade = -1; //no submission yet
|
||||
}
|
||||
|
||||
if (empty($auser->submissionid)) {
|
||||
$auser->grade = -1; //no submission yet
|
||||
}
|
||||
if (!empty($auser->submissionid)) {
|
||||
$hassubmission = true;
|
||||
///Prints student answer and student modified date
|
||||
///attach file or print link to student answer, depending on the type of the assignment.
|
||||
///Refer to print_student_answer in inherited classes.
|
||||
if ($auser->timemodified > 0) {
|
||||
$studentmodified = '<div id="ts'.$auser->id.'">'.$this->print_student_answer($auser->id)
|
||||
. userdate($auser->timemodified).'</div>';
|
||||
} else {
|
||||
$studentmodified = '<div id="ts'.$auser->id.'"> </div>';
|
||||
}
|
||||
///Print grade, dropdown or text
|
||||
if ($auser->timemarked > 0) {
|
||||
$teachermodified = '<div id="tt'.$auser->id.'">'.userdate($auser->timemarked).'</div>';
|
||||
|
||||
if (!empty($auser->submissionid)) {
|
||||
///Prints student answer and student modified date
|
||||
///attach file or print link to student answer, depending on the type of the assignment.
|
||||
///Refer to print_student_answer in inherited classes.
|
||||
if ($auser->timemodified > 0) {
|
||||
$studentmodified = '<div id="ts'.$auser->id.'">'.$this->print_student_answer($auser->id)
|
||||
. userdate($auser->timemodified).'</div>';
|
||||
if ($final_grade->locked or $final_grade->overridden) {
|
||||
$grade = '<div id="g'.$auser->id.'" class="'. $locked_overridden .'">'.$final_grade->formatted_grade.'</div>';
|
||||
} else if ($quickgrade) {
|
||||
$attributes = array();
|
||||
$attributes['tabindex'] = $tabindex++;
|
||||
$menu = html_writer::select(make_grades_menu($this->assignment->grade), 'menu['.$auser->id.']', $auser->grade, array(-1=>get_string('nograde')), $attributes);
|
||||
$grade = '<div id="g'.$auser->id.'">'. $menu .'</div>';
|
||||
} else {
|
||||
$grade = '<div id="g'.$auser->id.'">'.$this->display_grade($auser->grade).'</div>';
|
||||
}
|
||||
|
||||
} else {
|
||||
$teachermodified = '<div id="tt'.$auser->id.'"> </div>';
|
||||
if ($final_grade->locked or $final_grade->overridden) {
|
||||
$grade = '<div id="g'.$auser->id.'" class="'. $locked_overridden .'">'.$final_grade->formatted_grade.'</div>';
|
||||
} else if ($quickgrade) {
|
||||
$attributes = array();
|
||||
$attributes['tabindex'] = $tabindex++;
|
||||
$menu = html_writer::select(make_grades_menu($this->assignment->grade), 'menu['.$auser->id.']', $auser->grade, array(-1=>get_string('nograde')), $attributes);
|
||||
$grade = '<div id="g'.$auser->id.'">'.$menu.'</div>';
|
||||
} else {
|
||||
$grade = '<div id="g'.$auser->id.'">'.$this->display_grade($auser->grade).'</div>';
|
||||
}
|
||||
}
|
||||
///Print Comment
|
||||
if ($final_grade->locked or $final_grade->overridden) {
|
||||
$comment = '<div id="com'.$auser->id.'">'.shorten_text(strip_tags($final_grade->str_feedback),15).'</div>';
|
||||
|
||||
} else if ($quickgrade) {
|
||||
$comment = '<div id="com'.$auser->id.'">'
|
||||
. '<textarea tabindex="'.$tabindex++.'" name="submissioncomment['.$auser->id.']" id="submissioncomment'
|
||||
. $auser->id.'" rows="2" cols="20">'.($auser->submissioncomment).'</textarea></div>';
|
||||
} else {
|
||||
$comment = '<div id="com'.$auser->id.'">'.shorten_text(strip_tags($auser->submissioncomment),15).'</div>';
|
||||
}
|
||||
} else {
|
||||
$studentmodified = '<div id="ts'.$auser->id.'"> </div>';
|
||||
}
|
||||
///Print grade, dropdown or text
|
||||
if ($auser->timemarked > 0) {
|
||||
$teachermodified = '<div id="tt'.$auser->id.'">'.userdate($auser->timemarked).'</div>';
|
||||
|
||||
if ($final_grade->locked or $final_grade->overridden) {
|
||||
$grade = '<div id="g'.$auser->id.'" class="'. $locked_overridden .'">'.$final_grade->formatted_grade.'</div>';
|
||||
} else if ($quickgrade) {
|
||||
$attributes = array();
|
||||
$attributes['tabindex'] = $tabindex++;
|
||||
$menu = html_writer::select(make_grades_menu($this->assignment->grade), 'menu['.$auser->id.']', $auser->grade, array(-1=>get_string('nograde')), $attributes);
|
||||
$grade = '<div id="g'.$auser->id.'">'. $menu .'</div>';
|
||||
} else {
|
||||
$grade = '<div id="g'.$auser->id.'">'.$this->display_grade($auser->grade).'</div>';
|
||||
}
|
||||
|
||||
} else {
|
||||
$teachermodified = '<div id="tt'.$auser->id.'"> </div>';
|
||||
$status = '<div id="st'.$auser->id.'"> </div>';
|
||||
|
||||
if ($final_grade->locked or $final_grade->overridden) {
|
||||
$grade = '<div id="g'.$auser->id.'" class="'. $locked_overridden .'">'.$final_grade->formatted_grade.'</div>';
|
||||
} else if ($quickgrade) {
|
||||
$grade = '<div id="g'.$auser->id.'">'.$final_grade->formatted_grade . '</div>';
|
||||
$hassubmission = true;
|
||||
} else if ($quickgrade) { // allow editing
|
||||
$attributes = array();
|
||||
$attributes['tabindex'] = $tabindex++;
|
||||
$menu = html_writer::select(make_grades_menu($this->assignment->grade), 'menu['.$auser->id.']', $auser->grade, array(-1=>get_string('nograde')), $attributes);
|
||||
$grade = '<div id="g'.$auser->id.'">'.$menu.'</div>';
|
||||
$hassubmission = true;
|
||||
} else {
|
||||
$grade = '<div id="g'.$auser->id.'">'.$this->display_grade($auser->grade).'</div>';
|
||||
$grade = '<div id="g'.$auser->id.'">-</div>';
|
||||
}
|
||||
|
||||
if ($final_grade->locked or $final_grade->overridden) {
|
||||
$comment = '<div id="com'.$auser->id.'">'.$final_grade->str_feedback.'</div>';
|
||||
} else if ($quickgrade) {
|
||||
$comment = '<div id="com'.$auser->id.'">'
|
||||
. '<textarea tabindex="'.$tabindex++.'" name="submissioncomment['.$auser->id.']" id="submissioncomment'
|
||||
. $auser->id.'" rows="2" cols="20">'.($auser->submissioncomment).'</textarea></div>';
|
||||
} else {
|
||||
$comment = '<div id="com'.$auser->id.'"> </div>';
|
||||
}
|
||||
}
|
||||
///Print Comment
|
||||
if ($final_grade->locked or $final_grade->overridden) {
|
||||
$comment = '<div id="com'.$auser->id.'">'.shorten_text(strip_tags($final_grade->str_feedback),15).'</div>';
|
||||
|
||||
} else if ($quickgrade) {
|
||||
$comment = '<div id="com'.$auser->id.'">'
|
||||
. '<textarea tabindex="'.$tabindex++.'" name="submissioncomment['.$auser->id.']" id="submissioncomment'
|
||||
. $auser->id.'" rows="2" cols="20">'.($auser->submissioncomment).'</textarea></div>';
|
||||
if (empty($auser->status)) { /// Confirm we have exclusively 0 or 1
|
||||
$auser->status = 0;
|
||||
} else {
|
||||
$comment = '<div id="com'.$auser->id.'">'.shorten_text(strip_tags($auser->submissioncomment),15).'</div>';
|
||||
}
|
||||
} else {
|
||||
$studentmodified = '<div id="ts'.$auser->id.'"> </div>';
|
||||
$teachermodified = '<div id="tt'.$auser->id.'"> </div>';
|
||||
$status = '<div id="st'.$auser->id.'"> </div>';
|
||||
|
||||
if ($final_grade->locked or $final_grade->overridden) {
|
||||
$grade = '<div id="g'.$auser->id.'">'.$final_grade->formatted_grade . '</div>';
|
||||
} else if ($quickgrade) { // allow editing
|
||||
$attributes = array();
|
||||
$attributes['tabindex'] = $tabindex++;
|
||||
$menu = html_writer::select(make_grades_menu($this->assignment->grade), 'menu['.$auser->id.']', $auser->grade, array(-1=>get_string('nograde')), $attributes);
|
||||
$grade = '<div id="g'.$auser->id.'">'.$menu.'</div>';
|
||||
} else {
|
||||
$grade = '<div id="g'.$auser->id.'">-</div>';
|
||||
$auser->status = 1;
|
||||
}
|
||||
|
||||
if ($final_grade->locked or $final_grade->overridden) {
|
||||
$comment = '<div id="com'.$auser->id.'">'.$final_grade->str_feedback.'</div>';
|
||||
} else if ($quickgrade) {
|
||||
$comment = '<div id="com'.$auser->id.'">'
|
||||
. '<textarea tabindex="'.$tabindex++.'" name="submissioncomment['.$auser->id.']" id="submissioncomment'
|
||||
. $auser->id.'" rows="2" cols="20">'.($auser->submissioncomment).'</textarea></div>';
|
||||
} else {
|
||||
$comment = '<div id="com'.$auser->id.'"> </div>';
|
||||
}
|
||||
}
|
||||
$buttontext = ($auser->status == 1) ? $strupdate : $strgrade;
|
||||
|
||||
if (empty($auser->status)) { /// Confirm we have exclusively 0 or 1
|
||||
$auser->status = 0;
|
||||
} else {
|
||||
$auser->status = 1;
|
||||
}
|
||||
///No more buttons, we use popups ;-).
|
||||
$popup_url = '/mod/assignment/submissions.php?id='.$this->cm->id
|
||||
. '&userid='.$auser->id.'&mode=single'.'&filter='.$filter.'&offset='.$offset++;
|
||||
|
||||
$buttontext = ($auser->status == 1) ? $strupdate : $strgrade;
|
||||
$button = $OUTPUT->action_link($popup_url, $buttontext);
|
||||
|
||||
///No more buttons, we use popups ;-).
|
||||
$popup_url = '/mod/assignment/submissions.php?id='.$this->cm->id
|
||||
. '&userid='.$auser->id.'&mode=single'.'&filter='.$filter.'&offset='.$offset++;
|
||||
$status = '<div id="up'.$auser->id.'" class="s'.$auser->status.'">'.$button.'</div>';
|
||||
|
||||
$button = $OUTPUT->action_link($popup_url, $buttontext);
|
||||
$finalgrade = '<span id="finalgrade_'.$auser->id.'">'.$final_grade->str_grade.'</span>';
|
||||
|
||||
$status = '<div id="up'.$auser->id.'" class="s'.$auser->status.'">'.$button.'</div>';
|
||||
$outcomes = '';
|
||||
|
||||
$finalgrade = '<span id="finalgrade_'.$auser->id.'">'.$final_grade->str_grade.'</span>';
|
||||
if ($uses_outcomes) {
|
||||
|
||||
$outcomes = '';
|
||||
foreach($grading_info->outcomes as $n=>$outcome) {
|
||||
$outcomes .= '<div class="outcome"><label>'.$outcome->name.'</label>';
|
||||
$options = make_grades_menu(-$outcome->scaleid);
|
||||
|
||||
if ($uses_outcomes) {
|
||||
|
||||
foreach($grading_info->outcomes as $n=>$outcome) {
|
||||
$outcomes .= '<div class="outcome"><label>'.$outcome->name.'</label>';
|
||||
$options = make_grades_menu(-$outcome->scaleid);
|
||||
|
||||
if ($outcome->grades[$auser->id]->locked or !$quickgrade) {
|
||||
$options[0] = get_string('nooutcome', 'grades');
|
||||
$outcomes .= ': <span id="outcome_'.$n.'_'.$auser->id.'">'.$options[$outcome->grades[$auser->id]->grade].'</span>';
|
||||
} else {
|
||||
$attributes = array();
|
||||
$attributes['tabindex'] = $tabindex++;
|
||||
$attributes['id'] = 'outcome_'.$n.'_'.$auser->id;
|
||||
$outcomes .= ' '.html_writer::select($options, 'outcome_'.$n.'['.$auser->id.']', $outcome->grades[$auser->id]->grade, array(0=>get_string('nooutcome', 'grades')), $attributes);
|
||||
if ($outcome->grades[$auser->id]->locked or !$quickgrade) {
|
||||
$options[0] = get_string('nooutcome', 'grades');
|
||||
$outcomes .= ': <span id="outcome_'.$n.'_'.$auser->id.'">'.$options[$outcome->grades[$auser->id]->grade].'</span>';
|
||||
} else {
|
||||
$attributes = array();
|
||||
$attributes['tabindex'] = $tabindex++;
|
||||
$attributes['id'] = 'outcome_'.$n.'_'.$auser->id;
|
||||
$outcomes .= ' '.html_writer::select($options, 'outcome_'.$n.'['.$auser->id.']', $outcome->grades[$auser->id]->grade, array(0=>get_string('nooutcome', 'grades')), $attributes);
|
||||
}
|
||||
$outcomes .= '</div>';
|
||||
}
|
||||
$outcomes .= '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
$userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&course=' . $course->id . '">' . fullname($auser, has_capability('moodle/site:viewfullnames', $this->context)) . '</a>';
|
||||
$row = array($picture, $userlink, $grade, $comment, $studentmodified, $teachermodified, $status, $finalgrade);
|
||||
if ($uses_outcomes) {
|
||||
$row[] = $outcomes;
|
||||
$userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&course=' . $course->id . '">' . fullname($auser, has_capability('moodle/site:viewfullnames', $this->context)) . '</a>';
|
||||
$row = array($picture, $userlink, $grade, $comment, $studentmodified, $teachermodified, $status, $finalgrade);
|
||||
if ($uses_outcomes) {
|
||||
$row[] = $outcomes;
|
||||
}
|
||||
$table->add_data($row);
|
||||
}
|
||||
|
||||
$table->add_data($row);
|
||||
$currentposition++;
|
||||
}
|
||||
$currentposition++;
|
||||
}
|
||||
if ($hassubmission && ($this->assignment->assignmenttype=='upload' || $this->assignment->assignmenttype=='online' || $this->assignment->assignmenttype=='uploadsingle')) { //TODO: this is an ugly hack, where is the plugin spirit? (skodak)
|
||||
echo '<div style="text-align:right"><a href="submissions.php?id='.$this->cm->id.'&download=zip">'.get_string('downloadall', 'assignment').'</a></div>';
|
||||
}
|
||||
$table->print_html(); /// Print the whole table
|
||||
} else {
|
||||
if($filter == self::FILTER_SUBMITTED) {
|
||||
echo html_writer::tag('div', get_string('nosubmisson', 'assignment'), array('class'=>'nosubmisson'));
|
||||
} else if($filter == self::FILTER_REQUIRE_GRADING) {
|
||||
echo html_writer::tag('div', get_string('norequiregrading', 'assignment'), array('class'=>'norequiregrading'));
|
||||
}
|
||||
}
|
||||
|
||||
$table->print_html(); /// Print the whole table
|
||||
|
||||
/// Print quickgrade form around the table
|
||||
if ($quickgrade && $table->started_output){
|
||||
if ($quickgrade && $table->started_output && !empty($users)){
|
||||
$mailinfopref = false;
|
||||
if (get_user_preferences('assignment_mailinfo', 1)) {
|
||||
$mailinfopref = true;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#page-mod-assignment-submissions .submissions .grade,
|
||||
#page-mod-assignment-submissions .submissions .outcome,
|
||||
#page-mod-assignment-submissions .submissions .finalgrade {text-align: right;}
|
||||
#page-mod-assignment-submissions .submissions .header.noheader {display:none;}
|
||||
#page-mod-assignment-submissions .qgprefs #optiontable {text-align:right;margin-left:auto;}
|
||||
|
||||
/** Styles for view.php **/
|
||||
|
||||
Reference in New Issue
Block a user