diff --git a/lang/en_utf8/quiz.php b/lang/en_utf8/quiz.php
index e0a1a65c185..d3e8f9e8667 100644
--- a/lang/en_utf8/quiz.php
+++ b/lang/en_utf8/quiz.php
@@ -365,6 +365,7 @@ $string['notenoughanswers'] = 'This type of question requires at least $a answer
$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';
@@ -426,6 +427,7 @@ $string['quizavailable'] = 'The quiz is available until: $a';
$string['quizclose'] = 'Close the quiz';
$string['quizclosed'] = 'This quiz closed on $a';
$string['quizcloses'] = 'Quiz closes';
+$string['quizcloseson'] = 'This quiz will close at $a';
$string['quiznotavailable'] = 'The quiz will not be available until: $a';
$string['quizopen'] = 'Open the quiz';
$string['quizopens'] = 'Quiz opens';
diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php
index b92cf28465c..1dd6175b254 100644
--- a/mod/quiz/lib.php
+++ b/mod/quiz/lib.php
@@ -231,6 +231,30 @@ function quiz_cron () {
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,71 @@ function quiz_check_file_access($attemptid, $questionid) {
// 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');
+ $strnoattempts = get_string('noattempts', 'quiz');
+
+/// We want to list quizzes that are currently available, and which have a close date.
+/// This is the same as what the lesson does, and the dabate is in MDL-10568.
+ $now = date();
+ foreach ($quizs as $quiz) {
+ if ($quiz->timeclose >= $now && $quiz->timeopen < $now) {
+ /// Give a link to the quiz, and the deadline.
+ $str = '