MDL-13899 assignments should be now sending proper submissions and grading dates into gradebook; merged from MOODLE_19_STABLE
This commit is contained in:
+10
-8
@@ -231,10 +231,12 @@ class assignment_base {
|
||||
}
|
||||
|
||||
$graded_date = $grade->dategraded;
|
||||
$graded_by = $grade->usermodified;
|
||||
$graded_by = $grade->usermodified;
|
||||
|
||||
/// We need the teacher info
|
||||
$teacher = get_record('user', 'id', $graded_by);
|
||||
if (!$teacher = get_record('user', 'id', $graded_by)) {
|
||||
error('Could not find the teacher');
|
||||
}
|
||||
|
||||
/// Print the feedback
|
||||
print_heading(get_string('feedbackfromteacher', 'assignment', $this->course->teacher)); // TODO: fix teacher string
|
||||
@@ -1043,10 +1045,10 @@ class assignment_base {
|
||||
$navigation = build_navigation($this->strsubmissions, $this->cm);
|
||||
print_header_simple(format_string($this->assignment->name,true), "", $navigation,
|
||||
'', '', true, update_module_button($cm->id, $course->id, $this->strassignment), navmenu($course, $cm));
|
||||
|
||||
|
||||
$course_context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
|
||||
echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">'
|
||||
echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">'
|
||||
. get_string('seeallcoursegrades', 'grades') . '</a></div>';
|
||||
}
|
||||
|
||||
@@ -1081,7 +1083,7 @@ class assignment_base {
|
||||
}
|
||||
|
||||
$tableheaders = array('',
|
||||
get_string('fullnameuser'),
|
||||
get_string('fullname'),
|
||||
get_string('grade'),
|
||||
get_string('comment', 'assignment'),
|
||||
get_string('lastmodified').' ('.$course->student.')',
|
||||
@@ -1236,7 +1238,7 @@ class assignment_base {
|
||||
$teachermodified = '<div id="tt'.$auser->id.'"> </div>';
|
||||
$status = '<div id="st'.$auser->id.'"> </div>';
|
||||
|
||||
if ($final_grade->locked or $final_grade->overridden) {
|
||||
if ($final_grade->locked or $final_grade->overridden) {
|
||||
$grade = '<div id="g'.$auser->id.'">'.$final_grade->formatted_grade . '</div>';
|
||||
} else if ($quickgrade) { // allow editing
|
||||
$menu = choose_from_menu(make_grades_menu($this->assignment->grade),
|
||||
@@ -2795,13 +2797,13 @@ function assignment_get_coursemodule_info($coursemodule) {
|
||||
require_once($libfile);
|
||||
$assignmentclass = "assignment_$assignment->assignmenttype";
|
||||
$ass = new $assignmentclass('staticonly');
|
||||
if ($result = $ass->get_coursemodule_info($coursemodule)) {
|
||||
if ($result = $ass->get_coursemodule_info($coursemodule)) {
|
||||
return $result;
|
||||
} else {
|
||||
$info = new object();
|
||||
$info->name = $assignment->name;
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
debugging('Incorrect assignment type: '.$assignment->assignmenttype);
|
||||
|
||||
@@ -107,12 +107,12 @@ class assignment_online extends assignment_base {
|
||||
}
|
||||
}
|
||||
print_simple_box_end();
|
||||
if (!$editmode && $editable) {
|
||||
echo "<div style='text-align:center'>";
|
||||
print_single_button('view.php', array('id'=>$this->cm->id,'edit'=>'1'),
|
||||
get_string('editmysubmission', 'assignment'));
|
||||
echo "</div>";
|
||||
}
|
||||
if (!$editmode && $editable) {
|
||||
echo "<div style='text-align:center'>";
|
||||
print_single_button('view.php', array('id'=>$this->cm->id,'edit'=>'1'),
|
||||
get_string('editmysubmission', 'assignment'));
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -167,7 +167,13 @@ class assignment_online extends assignment_base {
|
||||
$update->data2 = $data->format;
|
||||
$update->timemodified = time();
|
||||
|
||||
return update_record('assignment_submissions', $update);
|
||||
if (!update_record('assignment_submissions', $update)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$submission = $this->get_submission($USER->id);
|
||||
$this->update_grade($submission);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -72,7 +72,8 @@ class assignment_upload extends assignment_base {
|
||||
|
||||
|
||||
function view_feedback($submission=NULL) {
|
||||
global $USER;
|
||||
global $USER, $CFG;
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
|
||||
if (!$submission) { /// Get submission for this assignment
|
||||
$submission = $this->get_submission($USER->id);
|
||||
@@ -87,8 +88,23 @@ class assignment_upload extends assignment_base {
|
||||
return;
|
||||
}
|
||||
|
||||
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, $USER->id);
|
||||
$item = $grading_info->items[0];
|
||||
$grade = $item->grades[$USER->id];
|
||||
|
||||
if ($grade->hidden or $grade->grade === false) { // hidden or error
|
||||
return;
|
||||
}
|
||||
|
||||
if ($grade->grade === null and empty($grade->str_feedback)) { /// Nothing to show yet
|
||||
return;
|
||||
}
|
||||
|
||||
$graded_date = $grade->dategraded;
|
||||
$graded_by = $grade->usermodified;
|
||||
|
||||
/// We need the teacher info
|
||||
if (! $teacher = get_record('user', 'id', $submission->teacher)) {
|
||||
if (!$teacher = get_record('user', 'id', $graded_by)) {
|
||||
error('Could not find the teacher');
|
||||
}
|
||||
|
||||
@@ -104,7 +120,7 @@ class assignment_upload extends assignment_base {
|
||||
echo '<td class="topic">';
|
||||
echo '<div class="from">';
|
||||
echo '<div class="fullname">'.fullname($teacher).'</div>';
|
||||
echo '<div class="time">'.userdate($submission->timemarked).'</div>';
|
||||
echo '<div class="time">'.userdate($graded_date).'</div>';
|
||||
echo '</div>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
@@ -114,13 +130,13 @@ class assignment_upload extends assignment_base {
|
||||
echo '<td class="content">';
|
||||
if ($this->assignment->grade) {
|
||||
echo '<div class="grade">';
|
||||
echo get_string("grade").': '.$this->display_grade($submission->grade);
|
||||
echo get_string("grade").': '.$grade->str_long_grade;
|
||||
echo '</div>';
|
||||
echo '<div class="clearer"></div>';
|
||||
}
|
||||
|
||||
echo '<div class="comment">';
|
||||
echo format_text($submission->submissioncomment, $submission->format);
|
||||
echo $grade->str_feedback;
|
||||
echo '</div>';
|
||||
echo '</tr>';
|
||||
|
||||
@@ -140,7 +156,7 @@ class assignment_upload extends assignment_base {
|
||||
$submission = $this->get_submission($USER->id);
|
||||
|
||||
$struploadafile = get_string('uploadafile');
|
||||
$maxbytes = $this->assignment->maxbytes == 0 ? $this->course->maxbytes : $this->assignment->maxbytes;
|
||||
$maxbytes = $this->assignment->maxbytes == 0 ? $this->course->maxbytes : $this->assignment->maxbytes;
|
||||
$strmaxsize = get_string('maxsize', '', display_size($maxbytes));
|
||||
|
||||
if ($this->is_finalized($submission)) {
|
||||
@@ -498,6 +514,9 @@ class assignment_upload extends assignment_base {
|
||||
if (update_record('assignment_submissions', $updated)) {
|
||||
add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id);
|
||||
redirect($returnurl);
|
||||
$submission = $this->get_submission($USER->id);
|
||||
$this->update_grade($submission);
|
||||
|
||||
} else {
|
||||
$this->view_header(get_string('notes', 'assignment'));
|
||||
notify(get_string('notesupdateerror', 'assignment'));
|
||||
@@ -580,6 +599,9 @@ class assignment_upload extends assignment_base {
|
||||
if (update_record('assignment_submissions', $updated)) {
|
||||
add_to_log($this->course->id, 'assignment', 'upload',
|
||||
'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id);
|
||||
$submission = $this->get_submission($USER->id);
|
||||
$this->update_grade($submission);
|
||||
|
||||
} else {
|
||||
$new_filename = $um->get_new_filename();
|
||||
$this->view_header(get_string('upload'));
|
||||
@@ -601,7 +623,6 @@ class assignment_upload extends assignment_base {
|
||||
function finalize() {
|
||||
global $USER;
|
||||
|
||||
$userid = optional_param('userid', 0, PARAM_INT);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$returnurl = 'view.php?id='.$this->cm->id;
|
||||
$submission = $this->get_submission($USER->id);
|
||||
@@ -628,6 +649,8 @@ class assignment_upload extends assignment_base {
|
||||
if (update_record('assignment_submissions', $updated)) {
|
||||
add_to_log($this->course->id, 'assignment', 'upload', //TODO: add finalize action to log
|
||||
'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id);
|
||||
$submission = $this->get_submission($USER->id);
|
||||
$this->update_grade($submission);
|
||||
$this->email_teachers($submission);
|
||||
} else {
|
||||
$this->view_header(get_string('submitformarking', 'assignment'));
|
||||
@@ -645,7 +668,7 @@ class assignment_upload extends assignment_base {
|
||||
$offset = required_param('offset', PARAM_INT);
|
||||
$returnurl = "submissions.php?id={$this->cm->id}&userid=$userid&mode=$mode&offset=$offset&forcerefresh=1";
|
||||
|
||||
// create but do not add student submission date
|
||||
// create but do not add student submission date
|
||||
$submission = $this->get_submission($userid, true, true);
|
||||
|
||||
if (!data_submitted() or !$this->can_finalize($submission)) {
|
||||
@@ -659,6 +682,8 @@ class assignment_upload extends assignment_base {
|
||||
if (update_record('assignment_submissions', $updated)) {
|
||||
add_to_log($this->course->id, 'assignment', 'upload', //TODO: add finalize action to log
|
||||
'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id);
|
||||
$submission = $this->get_submission($userid, false, true);
|
||||
$this->update_grade($submission);
|
||||
}
|
||||
redirect($returnurl);
|
||||
}
|
||||
@@ -681,6 +706,8 @@ class assignment_upload extends assignment_base {
|
||||
if (update_record('assignment_submissions', $updated)) {
|
||||
//TODO: add unfinalize action to log
|
||||
add_to_log($this->course->id, 'assignment', 'view submission', 'submissions.php?id='.$this->assignment->id, $this->assignment->id, $this->cm->id);
|
||||
$submission = $this->get_submission($userid);
|
||||
$this->update_grade($submission);
|
||||
} else {
|
||||
$this->view_header(get_string('submitformarking', 'assignment'));
|
||||
notify(get_string('unfinalizeerror', 'assignment'));
|
||||
@@ -809,6 +836,8 @@ class assignment_upload extends assignment_base {
|
||||
if (update_record('assignment_submissions', $updated)) {
|
||||
add_to_log($this->course->id, 'assignment', 'upload', //TODO: add delete action to log
|
||||
'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id);
|
||||
$submission = $this->get_submission($userid);
|
||||
$this->update_grade($submission);
|
||||
}
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
@@ -5,30 +5,30 @@
|
||||
*
|
||||
*/
|
||||
class assignment_uploadsingle extends assignment_base {
|
||||
|
||||
|
||||
|
||||
function print_student_answer($userid, $return=false){
|
||||
global $CFG, $USER;
|
||||
|
||||
|
||||
$filearea = $this->file_area_name($userid);
|
||||
|
||||
$output = '';
|
||||
|
||||
|
||||
if ($basedir = $this->file_area($userid)) {
|
||||
if ($files = get_directory_list($basedir)) {
|
||||
|
||||
|
||||
foreach ($files as $key => $file) {
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
|
||||
$icon = mimeinfo('icon', $file);
|
||||
|
||||
|
||||
if ($CFG->slasharguments) {
|
||||
$ffurl = "$CFG->wwwroot/file.php/$filearea/$file";
|
||||
} else {
|
||||
$ffurl = "$CFG->wwwroot/file.php?file=/$filearea/$file";
|
||||
}
|
||||
//died right here
|
||||
//require_once($ffurl);
|
||||
//require_once($ffurl);
|
||||
$output = '<img src="'.$CFG->pixpath.'/f/'.$icon.'" class="icon" alt="'.$icon.'" />'.
|
||||
'<a href="'.$ffurl.'" >'.$file.'</a><br />';
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class assignment_uploadsingle extends assignment_base {
|
||||
}
|
||||
|
||||
$output = '<div class="files">'.$output.'</div>';
|
||||
return $output;
|
||||
return $output;
|
||||
}
|
||||
|
||||
function assignment_uploadsingle($cmid='staticonly', $assignment=NULL, $cm=NULL, $course=NULL) {
|
||||
@@ -45,12 +45,12 @@ class assignment_uploadsingle extends assignment_base {
|
||||
}
|
||||
|
||||
function view() {
|
||||
|
||||
|
||||
global $USER;
|
||||
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE,$this->cm->id);
|
||||
require_capability('mod/assignment:view', $context);
|
||||
|
||||
|
||||
add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id);
|
||||
|
||||
$this->view_header();
|
||||
@@ -82,7 +82,7 @@ class assignment_uploadsingle extends assignment_base {
|
||||
global $CFG;
|
||||
$struploadafile = get_string("uploadafile");
|
||||
|
||||
$maxbytes = $this->assignment->maxbytes == 0 ? $this->course->maxbytes : $this->assignment->maxbytes;
|
||||
$maxbytes = $this->assignment->maxbytes == 0 ? $this->course->maxbytes : $this->assignment->maxbytes;
|
||||
$strmaxsize = get_string('maxsize', '', display_size($maxbytes));
|
||||
|
||||
echo '<div style="text-align:center">';
|
||||
@@ -101,9 +101,9 @@ class assignment_uploadsingle extends assignment_base {
|
||||
|
||||
|
||||
function upload() {
|
||||
|
||||
|
||||
global $CFG, $USER;
|
||||
|
||||
|
||||
require_capability('mod/assignment:submit', get_context_instance(CONTEXT_MODULE, $this->cm->id));
|
||||
|
||||
$this->view_header(get_string('upload'));
|
||||
@@ -131,8 +131,10 @@ class assignment_uploadsingle extends assignment_base {
|
||||
unset($submission->data1); // Don't need to update this.
|
||||
unset($submission->data2); // Don't need to update this.
|
||||
if (update_record("assignment_submissions", $submission)) {
|
||||
add_to_log($this->course->id, 'assignment', 'upload',
|
||||
add_to_log($this->course->id, 'assignment', 'upload',
|
||||
'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id);
|
||||
$submission = $this->get_submission($USER->id);
|
||||
$this->update_grade($submission);
|
||||
$this->email_teachers($submission);
|
||||
print_heading(get_string('uploadedfile'));
|
||||
} else {
|
||||
@@ -143,8 +145,10 @@ class assignment_uploadsingle extends assignment_base {
|
||||
$newsubmission->timemodified = time();
|
||||
$newsubmission->numfiles = 1;
|
||||
if (insert_record('assignment_submissions', $newsubmission)) {
|
||||
add_to_log($this->course->id, 'assignment', 'upload',
|
||||
add_to_log($this->course->id, 'assignment', 'upload',
|
||||
'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id);
|
||||
$submission = $this->get_submission($USER->id);
|
||||
$this->update_grade($submission);
|
||||
$this->email_teachers($newsubmission);
|
||||
print_heading(get_string('uploadedfile'));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user