1
0
mirror of https://github.com/moodle/moodle.git synced 2025-03-07 09:21:10 +01:00

Repeated fixes made in stable:

- moved two functions from locallib.php to lib.php
  - include mimetypes.php so mimeinfo works
This commit is contained in:
moodler 2004-09-08 06:43:57 +00:00
parent c58874c6ff
commit 7e6bf1253a
2 changed files with 108 additions and 107 deletions

@ -1019,6 +1019,109 @@ function workshop_get_participants($workshopid) {
return ($st_submissions);
}
//////////////////////////////////////////////////////////////////////////////////////
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 '<table border="0" cellpadding="3" cellspacing="0">';
if ($activity->content->parent) {
$openformat = "<font size=\"2\"><i>";
$closeformat = "</i></font>";
} else {
$openformat = "<b>";
$closeformat = "</b>";
}
echo "<tr><td bgcolor=\"$THEME->cellcontent2\" class=\"workshoppostpicture\" width=\"35\" valign=\"top\">";
print_user_picture($activity->user->userid, $course, $activity->user->picture);
echo "</td><td>$openformat";
if ($detail) {
echo "<img src=\"$CFG->modpixpath/$activity->type/icon.gif\" ".
"height=16 width=16 alt=\"$activity->name\"> ";
}
echo "<a href=\"$CFG->wwwroot/mod/workshop/view.php?"
. "#" . $activity->content->id . "\">".$activity->content->title;
echo "</a>$closeformat";
echo "<br><font size=\"2\">";
echo "<a href=\"$CFG->wwwroot/user/view.php?id=" . $activity->user->userid . "&course=" . "$course\">"
. $activity->user->fullname . "</a>";
echo " - " . userdate($activity->timestamp) . "</font></td></tr>";
echo "</table>";
return;
}
//////////////////////////////////////////////////////////////////////////////////////
// Non-standard workshop functions

@ -2558,8 +2558,9 @@ function workshop_print_submission_title($workshop, $submission) {
if (!$submission->timecreated) { // a "no submission"
return $submission->title;
}
}
require_once("$CFG->dirroot/files/mimetypes.php");
$filearea = workshop_file_area_name($workshop, $submission);
if ($basedir = workshop_file_area($workshop, $submission)) {
if (list($file) = get_directory_list($basedir)) {
@ -2741,118 +2742,15 @@ function workshop_test_user_assessments($workshop, $user) {
// ...the date stamp on the assessment should be in the past
if ($assessment->timecreated < $timenow) {
$n++;
}
}
}
}
if ($n < min($workshop->ntassessments, workshop_count_teacher_submissions($workshop))) {
$result = false;
}
}
}
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 '<table border="0" cellpadding="3" cellspacing="0">';
if ($activity->content->parent) {
$openformat = "<font size=\"2\"><i>";
$closeformat = "</i></font>";
} else {
$openformat = "<b>";
$closeformat = "</b>";
}
echo "<tr><td bgcolor=\"$THEME->cellcontent2\" class=\"workshoppostpicture\" width=\"35\" valign=\"top\">";
print_user_picture($activity->user->userid, $course, $activity->user->picture);
echo "</td><td>$openformat";
if ($detail) {
echo "<img src=\"$CFG->modpixpath/$activity->type/icon.gif\" ".
"height=16 width=16 alt=\"$activity->name\"> ";
}
echo "<a href=\"$CFG->wwwroot/mod/workshop/view.php?"
. "#" . $activity->content->id . "\">".$activity->content->title;
echo "</a>$closeformat";
echo "<br><font size=\"2\">";
echo "<a href=\"$CFG->wwwroot/user/view.php?id=" . $activity->user->userid . "&course=" . "$course\">"
. $activity->user->fullname . "</a>";
echo " - " . userdate($activity->timestamp) . "</font></td></tr>";
echo "</table>";
return;
}
?>