diff --git a/mod/assignment/lang/en/assignment.php b/mod/assignment/lang/en/assignment.php index c1d7cbb8024..052c243c65d 100644 --- a/mod/assignment/lang/en/assignment.php +++ b/mod/assignment/lang/en/assignment.php @@ -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'; diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index c27ca95d50b..436f4eda114 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -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 ''; - 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 '
'.get_string('downloadall', 'assignment').'
'; - } /// 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 = '
'.$this->print_student_answer($auser->id) + . userdate($auser->timemodified).'
'; + } else { + $studentmodified = '
 
'; + } + ///Print grade, dropdown or text + if ($auser->timemarked > 0) { + $teachermodified = '
'.userdate($auser->timemarked).'
'; - 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 = '
'.$this->print_student_answer($auser->id) - . userdate($auser->timemodified).'
'; + if ($final_grade->locked or $final_grade->overridden) { + $grade = '
'.$final_grade->formatted_grade.'
'; + } 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 = '
'. $menu .'
'; + } else { + $grade = '
'.$this->display_grade($auser->grade).'
'; + } + + } else { + $teachermodified = '
 
'; + if ($final_grade->locked or $final_grade->overridden) { + $grade = '
'.$final_grade->formatted_grade.'
'; + } 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 = '
'.$menu.'
'; + } else { + $grade = '
'.$this->display_grade($auser->grade).'
'; + } + } + ///Print Comment + if ($final_grade->locked or $final_grade->overridden) { + $comment = '
'.shorten_text(strip_tags($final_grade->str_feedback),15).'
'; + + } else if ($quickgrade) { + $comment = '
' + . '
'; + } else { + $comment = '
'.shorten_text(strip_tags($auser->submissioncomment),15).'
'; + } } else { $studentmodified = '
 
'; - } - ///Print grade, dropdown or text - if ($auser->timemarked > 0) { - $teachermodified = '
'.userdate($auser->timemarked).'
'; - - if ($final_grade->locked or $final_grade->overridden) { - $grade = '
'.$final_grade->formatted_grade.'
'; - } 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 = '
'. $menu .'
'; - } else { - $grade = '
'.$this->display_grade($auser->grade).'
'; - } - - } else { $teachermodified = '
 
'; + $status = '
 
'; + if ($final_grade->locked or $final_grade->overridden) { - $grade = '
'.$final_grade->formatted_grade.'
'; - } else if ($quickgrade) { + $grade = '
'.$final_grade->formatted_grade . '
'; + $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 = '
'.$menu.'
'; + $hassubmission = true; } else { - $grade = '
'.$this->display_grade($auser->grade).'
'; + $grade = '
-
'; + } + + if ($final_grade->locked or $final_grade->overridden) { + $comment = '
'.$final_grade->str_feedback.'
'; + } else if ($quickgrade) { + $comment = '
' + . '
'; + } else { + $comment = '
 
'; } } - ///Print Comment - if ($final_grade->locked or $final_grade->overridden) { - $comment = '
'.shorten_text(strip_tags($final_grade->str_feedback),15).'
'; - } else if ($quickgrade) { - $comment = '
' - . '
'; + if (empty($auser->status)) { /// Confirm we have exclusively 0 or 1 + $auser->status = 0; } else { - $comment = '
'.shorten_text(strip_tags($auser->submissioncomment),15).'
'; - } - } else { - $studentmodified = '
 
'; - $teachermodified = '
 
'; - $status = '
 
'; - - if ($final_grade->locked or $final_grade->overridden) { - $grade = '
'.$final_grade->formatted_grade . '
'; - } 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 = '
'.$menu.'
'; - } else { - $grade = '
-
'; + $auser->status = 1; } - if ($final_grade->locked or $final_grade->overridden) { - $comment = '
'.$final_grade->str_feedback.'
'; - } else if ($quickgrade) { - $comment = '
' - . '
'; - } else { - $comment = '
 
'; - } - } + $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 = '
'.$button.'
'; - $button = $OUTPUT->action_link($popup_url, $buttontext); + $finalgrade = ''.$final_grade->str_grade.''; - $status = '
'.$button.'
'; + $outcomes = ''; - $finalgrade = ''.$final_grade->str_grade.''; + if ($uses_outcomes) { - $outcomes = ''; + foreach($grading_info->outcomes as $n=>$outcome) { + $outcomes .= '
'; + $options = make_grades_menu(-$outcome->scaleid); - if ($uses_outcomes) { - - foreach($grading_info->outcomes as $n=>$outcome) { - $outcomes .= '
'; - $options = make_grades_menu(-$outcome->scaleid); - - if ($outcome->grades[$auser->id]->locked or !$quickgrade) { - $options[0] = get_string('nooutcome', 'grades'); - $outcomes .= ': '.$options[$outcome->grades[$auser->id]->grade].''; - } 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 .= ': '.$options[$outcome->grades[$auser->id]->grade].''; + } 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 .= '
'; } - $outcomes .= '
'; } - } - $userlink = '' . fullname($auser, has_capability('moodle/site:viewfullnames', $this->context)) . ''; - $row = array($picture, $userlink, $grade, $comment, $studentmodified, $teachermodified, $status, $finalgrade); - if ($uses_outcomes) { - $row[] = $outcomes; + $userlink = '' . fullname($auser, has_capability('moodle/site:viewfullnames', $this->context)) . ''; + $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 '
'.get_string('downloadall', 'assignment').'
'; + } + $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; diff --git a/mod/assignment/styles.css b/mod/assignment/styles.css index 62a660e5183..d8aae04bcfd 100644 --- a/mod/assignment/styles.css +++ b/mod/assignment/styles.css @@ -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 **/