Browse files

Deleted quiz_print_recent_instance_activity and quiz_get_recent_quizz…

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

Added quiz_print_recent_mod_activity and quiz_get_recent_mod_activity (for course/recent.php)
  • Loading branch information...
1 parent a57a779 commit 740f94d8e74f2c95061dc3ddc164c0c1da05bba5 selliott committed Feb 15, 2004
Showing with 68 additions and 34 deletions.
  1. +68 −34 mod/quiz/lib.php
View
102 mod/quiz/lib.php
@@ -2494,14 +2494,14 @@ function quiz_save_multianswer_alternatives
return $answers;
}
-function quiz_get_recent_quizzes($sincetime, $quiz="0", $user="") {
+function quiz_get_recent_mod_activity(&$activities, &$index, $sincetime, $courseid, $quiz="0", $user="", $groupid="") {
// Returns all quizzes since a given time. If quiz is specified then
// this restricts the results
global $CFG;
if ($quiz) {
- $quizselect = " AND q.id = '$quiz'";
+ $quizselect = " AND cm.id = '$quiz'";
} else {
$quizselect = "";
}
@@ -2511,51 +2511,85 @@ function quiz_get_recent_quizzes($sincetime, $quiz="0", $user="") {
$userselect = "";
}
- return get_records_sql("SELECT qa.*, q.name, u.firstname, u.lastname, u.picture, q.course, q.sumgrades as maxgrade
- FROM {$CFG->prefix}quiz_attempts qa,
- {$CFG->prefix}quiz q,
- {$CFG->prefix}user u
- WHERE qa.timefinish > '$sincetime'
- AND qa.userid = u.id $userselect
- AND qa.quiz = q.id $quizselect
- ORDER BY qa.timefinish ASC");
-}
+ $quizzes = get_records_sql("SELECT qa.*, q.name, u.firstname, u.lastname, u.picture,
+ q.course, q.sumgrades as maxgrade, cm.instance, cm.section
+ FROM {$CFG->prefix}quiz_attempts qa,
+ {$CFG->prefix}quiz q,
+ {$CFG->prefix}user u,
+ {$CFG->prefix}course_modules cm
+ WHERE qa.timefinish > '$sincetime'
+ AND qa.userid = u.id $userselect
+ AND qa.quiz = q.id $quizselect
+ AND cm.instance = q.id
+ AND cm.course = '$courseid'
+ AND q.course = cm.course
+ ORDER BY qa.timefinish ASC");
-function quiz_print_recent_instance_activity($quiz, $timestart, $user="") {
+ if (empty($quizzes))
+ return;
- global $CFG, $THEME;
+ foreach ($quizzes as $quiz) {
+ $tmpactivity->type = "quiz";
+ $tmpactivity->defaultindex = $index;
+ $tmpactivity->instance = $quiz->quiz;
- if (!$quizzes = quiz_get_recent_quizzes($timestart, $quiz->id, $user)) {
- return false;
- }
+ $tmpactivity->name = $quiz->name;
+ $tmpactivity->section = $quiz->section;
- foreach ($quizzes as $aquiz) {
- echo '<table border="0" cellpadding="3" cellspacing="0" class="sideblock">';
- echo "<tr><td bgcolor=\"$THEME->cellcontent2\" class=\"\" width=\"35\" valign=\"top\">";
- print_user_picture($aquiz->userid, $quiz->course, $aquiz->picture);
- echo "</td>";
+ $tmpactivity->content->attemptid = $quiz->id;
+ $tmpactivity->content->sumgrades = $quiz->sumgrades;
+ $tmpactivity->content->maxgrade = $quiz->maxgrade;
+ $tmpactivity->content->attempt = $quiz->attempt;
- echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"\" width=\"100%\">";
+ $tmpactivity->user->userid = $quiz->userid;
+ $tmpactivity->user->fullname = fullname($quiz);
+ $tmpactivity->user->picture = $quiz->picture;
- echo "<p>";
- echo "<font size=2>";
+ $tmpactivity->timestamp = $quiz->timefinish;
+ $activities[] = $tmpactivity;
- $fullname = fullname($aquiz);
- echo "<a href=\"$CFG->wwwroot/user/view.php?id=$aquiz->userid&course=$aquiz->course\">$fullname</a>";
+ $index++;
+ }
- if (isteacher($USER)) {
- $grade = "$aquiz->sumgrades / $aquiz->maxgrade";
- echo " (<a href=\"$CFG->wwwroot/mod/quiz/review.php?q=$aquiz->quiz&attempt=$aquiz->id\">$grade</a>)";
- echo get_string("attempt", "quiz") . " - $aquiz->attempt";
+ return;
+}
- }
+function quiz_print_recent_mod_activity($activity, $course, $detail=false) {
+ global $CFG, $THEME;
- echo "<br>";
- echo userdate($aquiz->timemodified);
+ echo '<table border="0" cellpadding="3" cellspacing="0">';
- echo "</font></p></td></tr></table>";
+ 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>";
+
+ if ($detail) {
+ echo "<img src=\"$CFG->modpixpath/$activity->type/icon.gif\" ".
+ "height=16 width=16 alt=\"$activity->type\"> ";
+ echo "<a href=\"$CFG->wwwroot/mod/quiz/view.php?id=" . $activity->instance . "\">"
+ . $activity->name . "</a> - ";
+
+ }
+
+ if (isteacher($USER)) {
+ $grades = "(" . $activity->content->sumgrades . " / " . $activity->content->maxgrade . ") ";
+ echo "<a href=\"$CFG->wwwroot/mod/quiz/review.php?q="
+ . $activity->instance . "&attempt="
+ . $activity->content->attemptid . "\">" . $grades . "</a> ";
+
+ echo get_string("attempt", "quiz") . " - " . $activity->content->attempt . "<br>";
}
+ echo "<a href=\"$CFG->wwwroot/user/view.php?id="
+ . $activity->user->userid . "&course=$course\">"
+ . $activity->user->fullname . "</a> ";
+
+ echo " - " . userdate($activity->timestamp);
+
+ echo "</font></td></tr>";
+ echo "</table>";
+
+ return;
}
?>

0 comments on commit 740f94d

Please sign in to comment.