AC_4897, AC_4898, AC_4899: Multifile uploader fixes.
[acontent.git] / docs / tests / preview.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12
13 define('TR_INCLUDE_PATH', '../include/');
14 require_once(TR_INCLUDE_PATH.'vitals.inc.php');
15 require_once(TR_INCLUDE_PATH.'classes/testQuestions.class.php');
16 require_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
17 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsDAO.class.php');
18 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsAssocDAO.class.php');
19
20 global $_course_id;
21 //Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
22 $testsDAO = new TestsDAO();
23 $testsQuestionsAssocDAO = new TestsQuestionsAssocDAO();
24
25 $_letters = array(_AT('a'), _AT('b'), _AT('c'), _AT('d'), _AT('e'), _AT('f'), _AT('g'), _AT('h'), _AT('i'), _AT('j'));
26
27 if ($_POST['back']) {
28         header('Location: index.php?_course_id='.$_course_id);
29         exit;
30
31
32 if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
33         $content_base_href = 'get.php/';
34 } else {
35         $content_base_href = 'content/' . $_SESSION['course_id'] . '/';
36 }
37
38 require_once(TR_INCLUDE_PATH.'header.inc.php');
39
40 $tid = intval($_GET['tid']);
41
42 // check that the test_id is correct
43 if (!($test_row = $testsDAO->get($tid))) {
44         $msg->printErrors('ITEM_NOT_FOUND');
45         require (TR_INCLUDE_PATH.'footer.inc.php');
46         exit;
47 }
48
49 $rows = $testsQuestionsAssocDAO->getByTestID($tid);
50 $count = 1;
51 ?>
52 <form method="post" action="<?php echo $_SERVER['PHP_SELF'].'?_course_id='.$_course_id; ?>" name="preview">
53
54 <?php if (is_array($rows)) {?>
55         <div class="input-form">
56         <div class="row"><h2><?php echo $test_row['title']; ?></h2></div>
57
58
59         <?php if ($test_row['instructions'] != ''): ?>
60                 <div style="background-color: #f3f3f3; padding: 5px 10px; margin: 0px; border-top: 1px solid">
61                         <strong><?php echo _AT('instructions'); ?></strong>
62                 </div>
63                 <div class="row" style="padding-bottom: 20px"><?php echo $test_row['instructions']; ?></div>
64         <?php endif; ?>
65         
66         <?php
67         foreach ($rows as $row) {
68                 $o = TestQuestions::getQuestion($row['type']);
69                 $o->display($row);
70         }
71         
72         // "back" button only appears when the request is from index page of "tests" module
73         if (stripos($_SERVER['HTTP_REFERER'], 'tests/index.php')) { ?>
74         <div class="row buttons">
75                 <input type="submit" value="<?php echo _AT('back'); ?>" name="back" />
76         </div>
77         <?php }?>
78         </div>
79 </form>
80 <script type="text/javascript">
81 //<!--
82 function iframeSetHeight(id, height) {
83         document.getElementById("qframe" + id).style.height = (height + 20) + "px";
84 }
85 //-->
86 </script>
87 <?php
88 } else {
89         $msg->printErrors('NO_QUESTIONS');
90 }
91
92
93 require_once(TR_INCLUDE_PATH.'footer.inc.php');
94 ?>