Permalink
Browse files

MDL-29689 Assignment 2.2: A student can see feedback for assignments …

…with no-grades
  • Loading branch information...
Rajesh Taneja
Rajesh Taneja committed Oct 3, 2012
1 parent 7f40888 commit deba4dc328d478cbc6d0be2c1de0e3f77ef63c91
View
@@ -269,7 +269,7 @@ function view_footer() {
* @global object
* @global object
* @param object $submission The submission object or NULL in which case it will be loaded
- * @return boolean
+ * @return bool
*/
function view_feedback($submission=NULL) {
global $USER, $CFG, $DB, $OUTPUT, $PAGE;
@@ -298,36 +298,40 @@ function view_feedback($submission=NULL) {
$item = $grading_info->items[0];
$grade = $item->grades[$userid];
- $fs = get_file_storage();
- $noresponsefiles = $fs->is_area_empty($this->context->id, 'mod_assignment', 'response', $submission->id);
+ if ($grade->hidden or $grade->grade === false) { // hidden or error
+ return false;
+ }
+
+ if ($grade->grade === null and empty($grade->str_feedback)) { // No grade to show yet
+ // If sumbission then check if feedback is avaiable to show else return.
+ if (!$submission) {
+ return false;
+ }
- if ($grade->grade === null ) { // No grade to show yet
+ $fs = get_file_storage();
+ $noresponsefiles = $fs->is_area_empty($this->context->id, 'mod_assignment', 'response', $submission->id);
if (empty($submission->submissioncomment) && $noresponsefiles) { // Nothing to show yet
return false;
}
-
+
// We need the teacher info
if (!$teacher = $DB->get_record('user', array('id'=>$submission->teacher))) {
print_error('cannotfindteacher');
}
- $feedback_date = $submission->timemarked;
- $feedback = $submission->submissioncomment;
- $str_long_grade = '-';
+ $feedbackdate = $submission->timemarked;
+ $feedback = format_text($submission->submissioncomment, $submission->format);
+ $strlonggrade = '-';
}
else {
- if ($grade->hidden or $grade->grade === false) { // hidden or error
- return false;
- }
-
// We need the teacher info
if (!$teacher = $DB->get_record('user', array('id'=>$grade->usermodified))) {
print_error('cannotfindteacher');
}
- $feedback_date = $grade->dategraded;
+ $feedbackdate = $grade->dategraded;
$feedback = $grade->str_feedback;
- $str_long_grade = $grade->str_long_grade;
+ $strlonggrade = $grade->str_long_grade;
}
// Print the feedback
@@ -346,7 +350,7 @@ function view_feedback($submission=NULL) {
if ($teacher) {
echo '<div class="fullname">'.fullname($teacher).'</div>';
}
- echo '<div class="time">'.userdate($feedback_date).'</div>';
+ echo '<div class="time">'.userdate($feedbackdate).'</div>';
echo '</div>';
echo '</td>';
echo '</tr>';
@@ -356,7 +360,7 @@ function view_feedback($submission=NULL) {
echo '<td class="content">';
if ($this->assignment->grade) {
- $gradestr = '<div class="grade">'. get_string("grade").': '.$str_long_grade. '</div>';
+ $gradestr = '<div class="grade">'. get_string("grade").': '.$strlonggrade. '</div>';
if (!empty($submission) && $controller = get_grading_manager($this->context, 'mod_assignment', 'submission')->get_active_controller()) {
$controller->set_grade_range(make_grades_menu($this->assignment->grade));
echo $controller->render_grade($PAGE, $submission->id, $item, $gradestr, has_capability('mod/assignment:grade', $this->context));
@@ -370,7 +374,9 @@ function view_feedback($submission=NULL) {
echo $feedback;
echo '</div>';
echo '</tr>';
-
+ if (method_exists($this, 'view_responsefile')) {
+ $this->view_responsefile($submission);
+ }
echo '</table>';
return true;
@@ -65,9 +65,7 @@ function view() {
if (is_enrolled($this->context, $USER)) {
if ($submission = $this->get_submission($USER->id)) {
if ($submission->timemarked) {
- if($this->view_feedback($submission)) {
- $this->view_responsefile($submission);
- }
+ $this->view_feedback($submission);
}
$filecount = $this->count_user_files($submission->id);
@@ -113,15 +111,14 @@ function view() {
* @param object $submission The submission object
*/
function view_responsefile($submission) {
- $responsefiles = $this->print_responsefiles($submission->userid, true);
- if (!empty($responsefiles)) {
- echo '<table cellspacing="0" class="feedback">';
+ $fs = get_file_storage();
+ $noresponsefiles = $fs->is_area_empty($this->context->id, 'mod_assignment', 'response', $submission->id);
+ if (!$noresponsefiles) {
echo '<tr>';
echo '<td class="left side">&nbsp;</td>';
echo '<td class="content">';
- echo $responsefiles;
- echo '</tr>';
- echo '</table>';
+ echo $this->print_responsefiles($submission->userid);
+ echo '</td></tr>';
}
}
@@ -78,9 +78,7 @@ function view() {
if ($submission = $this->get_submission($USER->id)) {
$filecount = $this->count_user_files($submission->id);
if ($submission->timemarked) {
- if($this->view_feedback($submission)) {
- $this->view_responsefile($submission);
- }
+ $this->view_feedback($submission);
}
if ($filecount) {
echo $OUTPUT->box($this->print_user_files($USER->id, true), 'generalbox boxaligncenter');
@@ -102,15 +100,14 @@ function view() {
* @param object $submission The submission object
*/
function view_responsefile($submission) {
- $responsefiles = $this->print_responsefiles($submission->userid, true);
- if (!empty($responsefiles)) {
- echo '<table cellspacing="0" class="feedback">';
+ $fs = get_file_storage();
+ $noresponsefiles = $fs->is_area_empty($this->context->id, 'mod_assignment', 'response', $submission->id);
+ if (!$noresponsefiles) {
echo '<tr>';
echo '<td class="left side">&nbsp;</td>';
echo '<td class="content">';
- echo $responsefiles;
- echo '</tr>';
- echo '</table>';
+ echo $this->print_responsefiles($submission->userid);
+ echo '</td></tr>';
}
}

0 comments on commit deba4dc

Please sign in to comment.