2 /****************************************************************/
\r
4 /****************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or*/
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /****************************************************************/
\r
14 define('AT_INCLUDE_PATH', '../../../include/');
\r
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
\r
16 require(AT_INCLUDE_PATH.'../mods/_standard/tests/classes/testQuestions.class.php');
\r
18 authenticate(AT_PRIV_TESTS);
\r
20 $tid = intval($_REQUEST['tid']);
\r
22 if (isset($_POST['reset_filter'])) unset($_POST);
\r
24 $_pages['mods/_standard/tests/results_all_quest.php']['title_var'] = 'question_statistics';
\r
25 $_pages['mods/_standard/tests/results_all_quest.php']['parent'] = 'mods/_standard/tests/index.php';
\r
26 $_pages['mods/_standard/tests/results_all_quest.php']['children'] = array('mods/_standard/tests/results_all.php?tid='.$tid);
\r
28 $_pages['mods/_standard/tests/results_all.php?tid='.$tid]['title_var'] = 'mark_statistics';
\r
29 $_pages['mods/_standard/tests/results_all.php?tid='.$tid]['parent'] = 'mods/_standard/tests/results_all_quest.php';
\r
31 require(AT_INCLUDE_PATH.'header.inc.php');
\r
33 $sql = "SELECT TQ.*, TQA.* FROM ".TABLE_PREFIX."tests_questions TQ INNER JOIN ".TABLE_PREFIX."tests_questions_assoc TQA USING (question_id) WHERE TQ.course_id=$_SESSION[course_id] AND TQA.test_id=$tid ORDER BY TQA.ordering, TQA.question_id";
\r
34 $result = mysql_query($sql, $db);
\r
35 $questions = array();
\r
36 while ($row = mysql_fetch_array($result)) {
\r
38 $questions[] = $row;
\r
39 $q_sql .= $row['question_id'].',';
\r
41 $q_sql = substr($q_sql, 0, -1);
\r
42 $num_questions = count($questions);
\r
45 $sql = "SELECT out_of, title, randomize_order FROM ".TABLE_PREFIX."tests WHERE test_id=$tid";
\r
46 $result = mysql_query($sql, $db);
\r
47 $row = mysql_fetch_assoc($result);
\r
48 $tt = $row['title'];
\r
49 $random = $row['randomize_order'];
\r
51 echo '<h3>'.$row['title'].'</h3><br />';
\r
53 //get all the questions in this test, store them
\r
54 $sql = "SELECT TQ.*, TQA.* FROM ".TABLE_PREFIX."tests_questions TQ INNER JOIN ".TABLE_PREFIX."tests_questions_assoc TQA USING (question_id) WHERE TQ.course_id=$_SESSION[course_id] AND TQA.test_id=$tid ORDER BY TQA.ordering, TQA.question_id";
\r
56 $result = mysql_query($sql, $db);
\r
57 $questions = array();
\r
58 while ($row = mysql_fetch_assoc($result)) {
\r
59 $questions[$row['question_id']] = $row;
\r
61 $long_qs = substr($long_qs, 0, -1);
\r
63 //get the answers: count | q_id | answer
\r
64 $sql = "SELECT count(*), A.question_id, A.answer, A.score
\r
65 FROM ".TABLE_PREFIX."tests_answers A, ".TABLE_PREFIX."tests_results R
\r
66 WHERE R.status=1 AND R.result_id=A.result_id AND R.final_score<>'' AND R.test_id=$tid";
\r
68 if ($_POST["user_type"] == 1) $sql .= " AND R.member_id not like 'G_%' AND R.member_id > 0 ";
\r
69 if ($_POST["user_type"] == 2) $sql .= " AND (R.member_id like 'G_%' OR R.member_id = 0) ";
\r
71 $sql .= " GROUP BY A.question_id, A.answer
\r
72 ORDER BY A.question_id, A.answer";
\r
74 $result = mysql_query($sql, $db);
\r
77 <div class="input-form">
\r
78 <form method="post" action="<?php echo $_SERVER['PHP_SELF'] . '?tid='.$tid; ?>">
\r
80 <?php echo _AT('user_type'); ?><br />
\r
81 <input type="radio" name="user_type" value="1" id="u0" <?php if ($_POST['user_type'] == 1) { echo 'checked="checked"'; } ?> /><label for="u0"><?php echo _AT('registered_members'); ?></label>
\r
82 <input type="radio" name="user_type" value="2" id="u1" <?php if ($_POST['user_type'] == 2) { echo 'checked="checked"'; } ?> /><label for="u1"><?php echo _AT('guests'); ?></label>
\r
83 <input type="radio" name="user_type" value="0" id="u2" <?php if (!isset($_POST['user_type']) || ($_POST['user_type'] != 1 && $_POST['user_type'] != 2)) { echo 'checked="checked"'; } ?> /><label for="u2"><?php echo _AT('all'); ?></label>
\r
86 <div class="row buttons">
\r
87 <input type="submit" name="filter" value="<?php echo _AT('filter'); ?>" />
\r
88 <input type="submit" name="reset_filter" value="<?php echo _AT('reset_filter'); ?>" />
\r
89 <input type="hidden" name="test_id" value="<?php echo $tid; ?>" />
\r
95 echo '<img src="images/checkmark.gif" alt="'._AT('correct_answer').'" />- '._AT('correct_answer').'<br /></p>';
\r
98 while ($row = mysql_fetch_assoc($result)) {
\r
99 $ans[$row['question_id']][$row['answer']] = array('count'=>$row['count(*)'], 'score'=>$row['score']);
\r
103 foreach ($questions as $q_id => $q) {
\r
104 /* for random: num_results is going to be specific to each question.
\r
105 * This is a randomized test which means that it is possible each question has been answered a
\r
106 * different number of times. Statistics are therefore based on the number of times each
\r
107 * question was answered, not the number of times the test has been taken.
\r
110 //catch random unanswered
\r
112 $obj = TestQuestions::getQuestion($q['type']);
\r
113 $obj->displayResultStatistics($q, $ans[$q_id]);
\r
117 require(AT_INCLUDE_PATH.'footer.inc.php');
\r