2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2010 */
6 /* Inclusive Design Institute */
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 /************************************************************************/
13 define('TR_INCLUDE_PATH', '../include/');
14 require_once(TR_INCLUDE_PATH.'vitals.inc.php');
15 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsDAO.class.php');
19 if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
20 $content_base_href = 'get.php/';
22 $content_base_href = 'content/' . $_course_id . '/';
24 // Verify that we may access this question
25 if (!isset($_SESSION['dd_question_ids']) || !is_array($_SESSION['dd_question_ids']) || !isset($_SESSION['dd_question_ids'][$_GET['qid']])) {
26 // Just exit as we're in an IFRAME
30 unset($_SESSION['dd_question_ids'][$_GET['qid']]);
31 if (count($_SESSION['dd_question_ids']) == 0) {
32 unset($_SESSION['dd_question_ids']);
34 session_write_close();
35 $_GET['qid'] = intval($_GET['qid']);
37 $testQuestionsDAO = new TestsQuestionsDAO();
38 $row = $testQuestionsDAO->get($_GET['qid']);
40 $_letters = array(_AT('A'), _AT('B'), _AT('C'), _AT('D'), _AT('E'), _AT('F'), _AT('G'), _AT('H'), _AT('I'), _AT('J'));
41 $_colours = array('#FF9900', '#00FF00', '#0000FF', '#F23AA3', '#9999CC', '#990026', '#0099CC', '#22C921', '#007D48', '#00248F');
44 for ($i=0; $i < 10; $i++) {
45 if ($row['option_'. $i] != '') {
50 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
51 <html lang="<?php echo $_SESSION['lang']; ?>">
53 <title><?php echo SITE_NAME; ?> : <?php echo AT_print($row['question'], 'tests_questions.question'); ?></title>
54 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $myLang->getCharacterSet(); ?>" />
55 <meta name="Generator" content="AContent - Copyright 2010 by http://atutor.ca" />
56 <base href="<?php echo TR_BASE_HREF . $content_base_href; ?>" />
57 <script type="text/javascript" src="<?php echo TR_BASE_HREF; ?>include/jscripts/infusion/InfusionAll.js"></script>
58 <script type="text/javascript" src="<?php echo TR_BASE_HREF; ?>include/jscripts/interface.js"></script>
59 <script type="text/javascript" src="<?php echo TR_BASE_HREF; ?>include/jscripts/wz_jsgraphics.js"></script>
60 <link rel="stylesheet" href="<?php echo TR_BASE_HREF; ?>themes/default/styles.css" type="text/css" />
61 <style type="text/css">
67 background-color: #fdfdfd;
74 border: 1px solid #ccc;
91 background-color: #fc9;
94 background-color: #ffc;
100 <?php $response = explode('|', $_GET['response']); ?>
102 <?php for ($i=0; $i < 10; $i++): ?>
103 <?php if ($row['choice_'. $i] != ''): ?>
104 <div id="container<?php echo $i; ?>" style="position: absolute; top: 0px; left: 0px; width: 100%"></div>
109 <ul style="position: absolute; top: 10px; left: 5px" id="q">
110 <?php for ($i=0; $i < 10; $i++): ?>
111 <?php if ($row['choice_'. $i] != ''): ?>
112 <li class="question" id="q<?php echo $i; ?>" value="<?php echo $i; ?>">
113 <select name="s<?php echo $i; ?>" onchange="selectLine(this.value, '<?php echo $i; ?>');" id="s<?php echo $i; ?>">
114 <option value="-1">-</option>
115 <?php for ($j=0; $j < $num_options; $j++): ?>
116 <option value="<?php echo $j; ?>" <?php if($response[$i] == $j): ?>selected="selected"<?php endif; ?>><?php echo $_letters[$j]; ?></option>
120 <?php echo AT_print($row['choice_'.$i], 'tests_questions.question'); ?></li>
125 <ol style="position: absolute; list-style-type: upper-alpha; top: 10px; left: 310px" id="a">
126 <?php for ($i=0; $i < 10; $i++): ?>
127 <?php if ($row['option_'. $i] != ''): ?>
128 <li class="answer" id="a<?php echo $i; ?>" value="<?php echo $i; ?>"><?php echo $_letters[$i]; ?>. <?php echo AT_print($row['option_'.$i], 'tests_questions.question'); ?></li>
133 <script type="text/javascript">
141 <?php for ($i=0; $i < 10; $i++): ?>
142 <?php if ($row['choice_'. $i] != ''): ?>
143 jg[<?php echo $i; ?>] = new jsGraphics("container<?php echo $i; ?>");
144 jg[<?php echo $i; ?>].setStroke(3);
145 jg[<?php echo $i; ?>].setColor("<?php echo $_colours[$i]; ?>");
149 var container_html = $("#container0").html();
154 $('#q>li').Draggable(
156 containment: "document",
161 fx: 0 // doesn't update select menu in FF if > 0
165 $('#a>li').Droppable(
168 activeclass: 'dropactive',
169 hoverclass: 'drophover',
170 tolerance: "pointer",
171 ondrop: function (drag) {
172 var lx = drag.offsetLeft + $("#" + drag.id).width() + padding;
173 var ly = drag.offsetTop + $("#" + drag.id).height()/2 + 10;
174 var rx = this.offsetLeft + 310;
175 var ry = this.offsetTop + $("#" + this.id).height()/2 + 10;
177 document.getElementById('s' + drag.value).selectedIndex = this.value + 1;
179 window.top.document.getElementById("<?php echo $_GET['qid']; ?>q" + drag.value).value = this.value;
181 $("#container" + drag.value).html(container_html);
183 jg[drag.value].drawLine(lx, ly , rx, ry );
184 jg[drag.value].paint();
191 parent.iframeSetHeight(<?php echo $_GET['qid']; ?>, Math.max($("#q").height(), $("#a").height()));
192 <?php foreach ($response as $id => $value): ?>
193 selectLine(<?php echo $value; ?>, <?php echo $id; ?>);
198 function selectLine(value, id) {
200 window.top.document.getElementById("<?php echo $_GET['qid']; ?>q" + id).value = "-1";
201 $("#container" + id).html(container_html);
206 var lx = document.getElementById("q" + id).offsetLeft + $("#q" + id).width() + padding;
207 var ly = document.getElementById("q" + id).offsetTop + $("#q" + id).height()/2 + 10;
208 var rx = document.getElementById("a" + value).offsetLeft + 310;
209 var ry = document.getElementById("a" + value).offsetTop + $("#a" + value).height()/2 + 10;
211 window.top.document.getElementById("<?php echo $_GET['qid']; ?>q" + id).value = value;
213 $("#container" + id).html(container_html);
214 jg[id].drawLine(lx, ly , rx, ry );