Permalink
Browse files

Deleted assignment_print_recent_instance_activity and assignment_get_…

…recent_assignments (used only in course/recent.php)

Added   assignment_get_recent_mod_activity and assignment_print_recent_mod_activity (used for course/recent.php)
  • Loading branch information...
1 parent 740f94d commit f466c9edb6ec5f1d8ded626c84df7a1bd0492ccd selliott committed Feb 15, 2004
Showing with 96 additions and 39 deletions.
  1. +96 −39 mod/assignment/lib.php
View
@@ -550,14 +550,14 @@ function assignment_print_upload_form($assignment) {
echo "</DIV>";
}
-function assignment_get_recent_assignments($sincetime, $assignment="0", $user="") {
-// Returns all submitted assignments since a given time. If assignment is specified then
+function assignment_get_recent_mod_activity(&$activities, &$index, $sincetime, $courseid, $assignment="0", $user="", $groupid="") {
+// Returns all assignments since a given time. If assignment is specified then
// this restricts the results
global $CFG;
if ($assignment) {
- $assignmentselect = " AND asub.assignment = '$assignment'";
+ $assignmentselect = " AND cm.id = '$assignment'";
} else {
$assignmentselect = "";
}
@@ -566,60 +566,117 @@ function assignment_get_recent_assignments($sincetime, $assignment="0", $user=""
} else {
$userselect = "";
}
+ if ($groupid) {
+ $groupselect = " ";
+ } else {
+ $groupselect = "";
+ }
- return get_records_sql("SELECT asub.*, u.firstname, u.lastname, u.picture, a.grade as maxgrade
- FROM {$CFG->prefix}assignment_submissions asub,
- {$CFG->prefix}user u,
- {$CFG->prefix}assignment a
- WHERE asub.timemodified > '$sincetime'
- AND asub.userid = u.id $userselect
- AND a.id = asub.assignment $assignmentselect
- ORDER BY asub.timemodified ASC");
-}
+ $assignments = get_records_sql("SELECT asub.*, u.firstname, u.lastname, u.picture, u.id as userid,
+ a.grade as maxgrade, name, cm.instance
+ FROM {$CFG->prefix}assignment_submissions asub,
+ {$CFG->prefix}user u,
+ {$CFG->prefix}assignment a,
+ {$CFG->prefix}course_modules cm
+ WHERE asub.timemodified > '$sincetime'
+ AND asub.userid = u.id $userselect
+ AND a.id = asub.assignment $assignmentselect
+ AND cm.course = '$courseid'
+ AND cm.instance = a.id
+ ORDER BY asub.timemodified ASC");
+
+ if (empty($assignments))
+ return;
+
+ foreach ($assignments as $assignment) {
+ $tmpactivity->type = "assignment";
+ $tmpactivity->defaultindex = $index;
+ $tmpactivity->instance = $assignment->instance;
+ $tmpactivity->name = $assignment->name;
+ $tmpactivity->content->grade = $assignment->grade;
+ $tmpactivity->content->maxgrade = $assignment->maxgrade;
-function assignment_print_recent_instance_activity($assignment, $timestart, $user="") {
+ $tmpactivity->user->userid = $assignment->userid;
+ $tmpactivity->user->fullname = fullname($assignment);
+ $tmpactivity->user->picture = $assignment->picture;
+ $tmpactivity->timestamp = $assignment->timemodified;
+
+ $activities[] = $tmpactivity;
+
+ $index++;
+ }
+
+ return;
+}
+
+function assignment_print_recent_mod_activity($activity, $course, $detail=false) {
global $CFG, $THEME;
- if (!$assignments = assignment_get_recent_assignments($timestart, $assignment->id, $user)) {
- return false;
- }
+ echo '<table border="0" cellpadding="3" cellspacing="0">';
- foreach ($assignments as $anassignment) {
- echo '<table border="0" cellpadding="3" cellspacing="0" class="sideblock">';
- echo "<tr><td bgcolor=\"$THEME->cellcontent2\" class=\"\" width=\"35\" valign=\"top\">";
- print_user_picture($anassignment->userid, $anassignment->course, $assignment->picture);
- echo "</td>";
+ echo "<tr><td bgcolor=\"$THEME->cellcontent2\" class=\"forumpostpicture\" width=\"35\" valign=\"top\">";
+ print_user_picture($activity->user->userid, $course, $activity->user->picture);
+ echo "</td><td width=\"100%\"><font size=2>";
- echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"\" width=\"100%\">";
- echo "<p>";
- echo "<font size=2>";
+ if ($detail) {
+ echo "<img src=\"$CFG->modpixpath/$activity->type/icon.gif\" ".
+ "height=16 width=16 alt=\"$activity->type\"> ";
+ echo "<a href=\"$CFG->wwwroot/mod/assignment/view.php?id=" . $activity->instance . "\">"
+ . $activity->name . "</a> - ";
+ }
- $fullname = fullname($anassignment);
- echo "<a href=\"$CFG->wwwroot/user/view.php?id=$anassignment->userid&course=$assignment->course\">$fullname</a>";
+ if (isteacher($USER)) {
+ $grades = "(" . $activity->content->grade . " / " . $activity->content->maxgrade . ") ";
- if (isteacher($USER)) {
- $grade = "$anassignment->grade / $anassignment->maxgrade";
- echo " (<a href=\"$CFG->wwwroot/mod/quiz/submissions.php?id=$anassignment->assignment\">$grade</a>)";
+ $assignment->id = $activity->instance;
+ $assignment->course = $course;
+ $user->id = $activity->user->userid;
- // setup temporary objects to use in assignment_print_user_files
- $tmpassignment->course = $assignment->course;
- $tmpassignment->id = $anassignment->assignment;
- $tmpuser->id = $anassignment->userid;
+ $file = assignment_get_user_file($assignment, $user);
- echo " - ";
+ echo "<IMG SRC=\"$CFG->wwwroot/files/pix/$file->icon\" HEIGHT=16 WIDTH=16 BORDER=0 ALT=\"File\">";
+ echo "&nbsp;<A TARGET=\"uploadedfile\" HREF=\"$CFG->wwwroot/$file->url\">$file->name</A>";
+ echo "<BR>";
+ }
+ echo "<a href=\"$CFG->wwwroot/user/view.php?id="
+ . $activity->user->userid . "&course=$course\">"
+ . $activity->user->fullname . "</a> ";
- assignment_print_user_files($tmpassignment, $tmpuser);
+ echo " - " . userdate($activity->timestamp);
- }
+ echo "</font></td></tr>";
+ echo "</table>";
- echo "<br>";
- echo userdate($anassignment->timemodified);
+ return;
+}
- echo "</font></p></td></tr></table>";
+function assignment_get_user_file($assignment, $user) {
+ global $CFG;
+
+ $tmpfile = "";
+
+ $filearea = assignment_file_area_name($assignment, $user);
+
+ if ($basedir = assignment_file_area($assignment, $user)) {
+ if ($files = get_directory_list($basedir)) {
+ foreach ($files as $file) {
+ $icon = mimeinfo("icon", $file);
+ if ($CFG->slasharguments) {
+ $ffurl = "file.php/$filearea/$file";
+ } else {
+ $ffurl = "file.php?file=/$filearea/$file";
+ }
+ $tmpfile->url = $ffurl;
+ $tmpfile->name = $file;
+ $tmpfile->icon = $icon;
+ }
+ }
}
+ return $tmpfile;
}
+
?>

0 comments on commit f466c9e

Please sign in to comment.