Index: lang/en_utf8/quiz.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en_utf8/quiz.php,v
retrieving revision 1.79
diff -u -r1.79 quiz.php
--- lang/en_utf8/quiz.php 19 Sep 2007 15:38:14 -0000 1.79
+++ lang/en_utf8/quiz.php 20 Sep 2007 13:33:05 -0000
@@ -365,6 +365,7 @@
$string['notenoughsubquestions'] = 'Not enough sub-questions have been defined!
Do you want to go back and fix this question?';
$string['notimedependentitems'] = 'Time dependent items are not currently supported by the quiz module. As a work around, set a time limit for the whole quiz. Do you wish to choose a different item (or use the current item regardless)?';
$string['numattempts'] = '$a->studentnum $a->studentstring have made $a->attemptnum attempts';
+$string['numattemptsmade'] = '$a attempts made on this quiz';
$string['numberabbr'] = '#';
$string['numerical'] = 'Numerical';
$string['onlyteachersexport'] = 'Only teachers can export questions';
Index: mod/quiz/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/quiz/lib.php,v
retrieving revision 1.279
diff -u -r1.279 lib.php
--- mod/quiz/lib.php 19 Sep 2007 15:38:15 -0000 1.279
+++ mod/quiz/lib.php 20 Sep 2007 13:33:05 -0000
@@ -231,6 +231,30 @@
return true;
}
+/**
+ * @param integer $quizid the quiz id.
+ * @param integer $userid the userid.
+ * @param string $status 'all', 'finished' or 'unfinished' to control
+ * @return an array of all the user's attempts at this quiz. Returns an empty array if there are none.
+ */
+function quiz_get_user_attempts($quizid, $userid, $status = 'finished', $includepreviews = false) {
+ $status_condition = array(
+ 'all' => '',
+ 'finished' => ' AND timefinish > 0',
+ 'unfinished' => ' AND timefinish = 0'
+ );
+ $previewclause = '';
+ if (!$includepreviews) {
+ $previewclause = ' AND preview = 0';
+ }
+ if ($attempts = get_records_select('quiz_attempts',
+ "quiz = '$quizid' AND userid = '$userid'" . $previewclause . $status_condition[$status],
+ 'attempt ASC')) {
+ return $attempts;
+ } else {
+ return array();
+ }
+}
/**
* Return grade for given user or all users.
@@ -955,4 +979,68 @@
// otherwise, this user does not have permission
return false;
}
+
+/**
+ * Prints quiz summaries on MyMoodle Page
+ */
+function quiz_print_overview($courses, &$htmlarray) {
+ global $USER, $CFG;
+/// These next 6 Lines are constant in all modules (just change module name)
+ if (empty($courses) || !is_array($courses) || count($courses) == 0) {
+ return array();
+ }
+
+ if (!$quizs = get_all_instances_in_courses('quiz', $courses)) {
+ return;
+ }
+
+/// Fetch some language strings outside the main loop.
+ $strquiz = get_string('modulename', 'quiz');
+ $strquizcloses = get_string('quizcloses', 'quiz');
+ $strquizopens = get_string('quizopens', 'quiz');
+ $strnoattempts = get_string('noattempts', 'quiz');
+ $now = date();
+
+ foreach ($quizs as $quiz) {
+ if (($quiz->timeclose != 0) && ($quiz->timeclose >= $now)) { // A quiz is scheduled
+ $str = '