From: moodler Date: Thu, 24 Jul 2003 16:43:24 +0000 (+0000) Subject: New simplestat report module. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c90f563e398f20b0cf473efb55bbf9b8ffb35420;p=moodle.git New simplestat report module. This is very simple so far just to do some tests on larger datasets. Soon it will have XLS and text download, as well as more question information. --- diff --git a/mod/quiz/report/simplestat/report.php b/mod/quiz/report/simplestat/report.php new file mode 100644 index 0000000000..fd18a4a608 --- /dev/null +++ b/mod/quiz/report/simplestat/report.php @@ -0,0 +1,94 @@ +questions); + + /// For each person in the class, get their best attempt + /// and create a table listing results for each person + if ($users = get_course_students($course->id, "u.lastname ASC")) { + foreach ($users as $user) { + + $data[$user->id]->name = "$user->firstname $user->lastname"; + $data[$user->id]->grades = array(); // by default + + if (!$attempts = quiz_get_user_attempts($quiz->id, $user->id)) { + continue; + } + if (!$bestattempt = quiz_calculate_best_attempt($quiz, $attempts)) { + continue; + } + if (!$questions = quiz_get_attempt_responses($bestattempt, $quiz)) { + continue; + } + quiz_remove_unwanted_questions($questions, $quiz); + + if (!$results = quiz_grade_attempt_results($quiz, $questions)) { + error("Could not re-grade this quiz attempt!"); + } + + $count = 0; + foreach ($questionorder as $questionid) { + $count++; + $data[$user->id]->grades[$count] = $results->grades[$questionid]; + } + } + } + + optional_variable($output, ""); + + /// If spreadsheet is wanted, produce one + if ($output = "xls") { + } + + /// If a text file is wanted, produce one + if ($output = "xls") { + } + + /// Otherwise, display the table as HTML + + $count = count($questionorder); + $datacount = count($data); + $total = array(); + + echo ""; + echo ""; + echo ""; + for ($i=1; $i<=$count; $i++) { + $total[$i] = 0.0; + echo ""; + } + echo ""; + + foreach ($data as $userid => $datum) { + echo ""; + echo ""; + foreach ($datum->grades as $key => $grade) { + echo ""; + $total[$key]+= $grade; + } + echo ""; + } + + echo ""; + echo ""; + for ($i=1; $i<=$count; $i++) { + $average = format_float($total[$i] / $datacount, 2); + echo ""; + } + echo ""; + + echo "
 $i
$datum->name$grade
 $average
"; + + return true; + } +} + +?>