From bbb56db78a6b173395d1b246223bc8fef0d32ad1 Mon Sep 17 00:00:00 2001 From: moodler Date: Sat, 24 Apr 2004 12:47:52 +0000 Subject: [PATCH] New functions by Jenny Watt, to make workshops show up on Recent Activity workshop_get_recent_mod_activity() workshop_print_recent_mod_activity() Thanks, Jenny! --- mod/workshop/lib.php | 144 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 134 insertions(+), 10 deletions(-) diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index feac553d58..eea98f8583 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -586,6 +586,29 @@ global $CFG; return $return; } +function workshop_is_recent_activity($course, $isteacher, $timestart) {//jlw1 added for adding mark to courses with activity in My Moodle + global $CFG; + + // have a look for agreed assessments for this user (agree) + $agreecontent = false; + if (!$isteacher) { // teachers only need to see submissions + if ($logs = workshop_get_agree_logs($course, $timestart)) { + // got some, see if any belong to a visible module + foreach ($logs as $log) { + // Create a temp valid module structure (only need courseid, moduleid) + $tempmod->course = $course->id; + $tempmod->id = $log->workshopid; + //Obtain the visible property from the instance + if (instance_is_visible("workshop",$tempmod)) { + $agreecontent = true; + break; + } + } + } + } + return false; +} + /////////////////////////////////////////////////////////////////////////////// function workshop_print_recent_activity($course, $isteacher, $timestart) { @@ -2788,17 +2811,17 @@ function workshop_print_assessment($workshop, $assessment = false, $allowchanges // FORM is needed for Mozilla browsers, else radio bttons are not checked ?>
- - + + - -
- - \n"; - echo " \n"; - echo "\n"; + +
+
cellheading2\">
".get_string("assessment", "workshop"). - "
+ \n"; + echo " \n"; + echo "\n"; // get the assignment elements... if (!$elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC")) { @@ -3671,6 +3694,107 @@ function workshop_test_user_assessments($workshop, $user) { } return $result; } + +function workshop_get_recent_mod_activity(&$activities, &$index, $sincetime, $courseid, + $workshop="0", $user="", $groupid="") { + // Returns all workshop posts since a given time. If workshop is specified then + // this restricts the results + + global $CFG; + + if ($workshop) { + $workshopselect = " AND cm.id = '$workshop'"; + } else { + $workshopselect = ""; + } + + if ($user) { + $userselect = " AND u.id = '$user'"; + } else { + $userselect = ""; + } + + $posts = get_records_sql("SELECT s.*, u.firstname, u.lastname, + u.picture, cm.instance, w.name, cm.section + FROM {$CFG->prefix}workshop_submissions s, + {$CFG->prefix}user u, + {$CFG->prefix}course_modules cm, + {$CFG->prefix}workshop w + WHERE s.timecreated > '$sincetime' $workshopselect + AND s.userid = u.id $userselect + AND w.course = '$courseid' $groupselect + AND cm.instance = w.id + AND cm.course = w.course + AND s.workshopid = w.id + ORDER BY s.id"); + + + if (empty($posts)) { + return; + } + + foreach ($posts as $post) { + + if (empty($groupid) || ismember($groupid, $post->userid)) { + $tmpactivity->type = "workshop"; + $tmpactivity->defaultindex = $index; + $tmpactivity->instance = $post->instance; + $tmpactivity->name = $post->name; + $tmpactivity->section = $post->section; + + $tmpactivity->content->id = $post->id; + $tmpactivity->content->title = $post->title; + + $tmpactivity->user->userid = $post->userid; + $tmpactivity->user->fullname = fullname($post); + $tmpactivity->user->picture = $post->picture; + + $tmpactivity->timestamp = $post->timecreated; + $activities[] = $tmpactivity; + + $index++; + } + } + + return; +} + +function workshop_print_recent_mod_activity($activity, $course, $detail=false) { + + global $CFG; + + echo '
cellheading2\">
".get_string("assessment", "workshop"). + "
'; + + if ($activity->content->parent) { + $openformat = ""; + $closeformat = ""; + } else { + $openformat = ""; + $closeformat = ""; + } + + echo ""; + echo "
cellcontent2\" class=\"workshoppostpicture\" width=\"35\" valign=\"top\">"; + print_user_picture($activity->user->userid, $course, $activity->user->picture); + echo "$openformat"; + + if ($detail) { + echo "modpixpath/$activity->type/icon.gif\" ". + "height=16 width=16 alt=\"$activity->name\"> "; + } + echo "wwwroot/mod/workshop/view.php?" + . "#" . $activity->content->id . "\">".$activity->content->title; + + echo "$closeformat"; + + echo "
"; + echo "wwwroot/user/view.php?id=" . $activity->user->userid . "&course=" . "$course\">" + . $activity->user->fullname . ""; + echo " - " . userdate($activity->timestamp) . "
"; + + return; + +} -- 2.39.5