Skip to content
Browse files

Assignment module support for my moodle page

  • Loading branch information...
1 parent 33b58d3 commit 84fa8f5fdd31870ecabd210242806b61961ebb31 patrickslee committed Mar 14, 2006
Showing with 72 additions and 0 deletions.
  1. +2 −0 lang/en_utf8/assignment.php
  2. +70 −0 mod/assignment/lib.php
View
2 lang/en_utf8/assignment.php
@@ -42,6 +42,7 @@
$string['feedback'] = 'Feedback';
$string['feedbackfromteacher'] = 'Feedback from the $a';
$string['feedbackupdated'] = 'Submissions feedback updated for $a people';
+$string['graded'] = 'Graded';
$string['guestnoupload'] = 'Sorry, guests are not allowed to upload';
$string['guestnosubmit'] = 'Sorry, guests are not allowed to submit an assignment. You have to log in/ register before you can submit your answer';
$string['helpoffline'] = '<p>This is useful when the assignment is performed outside of Moodle. It could be
@@ -74,6 +75,7 @@
$string['submissionfeedback'] = 'Submission feedback';
$string['submissions'] = 'Submissions';
$string['submissionsaved'] = 'Your changes have been saved';
+$string['submissionsnotgraded'] = '$a submissions not graded';
$string['submitassignment'] = 'Submit your assignment using this form';
$string['submitted'] = 'Submitted';
$string['typeoffline'] = 'Offline activity';
View
70 mod/assignment/lib.php
@@ -2282,4 +2282,74 @@ function assignment_upgrade_submodules() {
}
}
+function assignment_print_overview($courses, &$htmlarray) {
+ global $USER, $CFG;
+
+ if (empty($courses) || !is_array($courses) || count($courses) == 0) {
+ return array();
+ }
+
+ if (!$assignments = get_all_instances_in_courses('assignment',$courses)) {
+ return;
+ }
+
+ // Do assignment_base::isopen() here without loading the whole thing for speed
+ foreach ($assignments as $key => $assignment) {
+ $time = time();
+ if ($assignment->preventlate && $assignment->timedue) {
+ $isopen = ($assignment->timeavailable <= $time && $time <= $assignment->timedue);
+ } else {
+ $isopen = ($assignment->timeavailable <= $time);
+ }
+ if (!$isopen) {
+ unset($assignments[$key]);
+ }
+ }
+
+ $strduedate = get_string('duedate', 'assignment');
+ $strgraded = get_string('graded', 'assignment');
+ $strnotgradedyet = get_string('notgradedyet', 'assignment');
+ $strnotsubmittedyet = get_string('notsubmittedyet', 'assignment');
+ $strsubmitted = get_string('submitted', 'assignment');
+
+ foreach ($assignments as $assignment) {
+ require_once("$CFG->dirroot/mod/assignment/type/$assignment->assignmenttype/assignment.class.php");
+ $assignmentclass = "assignment_$assignment->assignmenttype";
+ $instance = new $assignmentclass($assignment->coursemodule, $assignment);
+
+ $str = '<a title="'.$instance->strassignment.'" href="'.$CFG->wwwroot.'/mod/assignment/view.php?id='.$instance->cm->id.'">'
+ .$instance->strassignment.': '.$instance->assignment->name.'</a><br />';
+ $str .= $strduedate.': '.userdate($instance->assignment->timedue).'<br />';
+ if (isteacher($instance->course->id)) {
+ $submissions = count_records_sql("SELECT COUNT(a.*)
+ FROM {$CFG->prefix}assignment_submissions a,
+ {$CFG->prefix}user_students s,
+ {$CFG->prefix}user u
+ WHERE a.userid = s.userid
+ AND u.id = a.userid
+ AND s.course = '{$instance->course->id}'
+ AND a.assignment = '{$instance->assignment->id}'
+ AND a.teacher = 0
+ AND a.timemarked = 0");
+ if ($submissions) {
+ $str .= get_string('submissionsnotgraded', 'assignment', $submissions);
+ }
+ } else {
+ $sql = "SELECT *
+ FROM {$CFG->prefix}assignment_submissions
+ WHERE userid = '$USER->id'";
+ if ($submission = get_record_sql($sql)) {
+ if ($submission->teacher == 0 && $submission->timemarked == 0) {
+ $str .= $strsubmitted . ', ' . $strnotgradedyet;
+ } else {
+ $str .= $strsubmitted . ', ' . $strgraded;
+ }
+ } else {
+ $str .= $strnotsubmittedyet . ' ' . $instance->display_lateness(time());
+ }
+ }
+ $htmlarray[$instance->course->id]['assignment'] .= $str;
+ }
+}
+
?>

0 comments on commit 84fa8f5

Please sign in to comment.
Something went wrong with that request. Please try again.