2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
18 $content_base_href = 'get.php/';
20 $content_base_href = 'content/' . $_SESSION['course_id'] . '/';
22 // Verify that we may access this question
23 if (!isset($_SESSION['dd_question_ids']) || !is_array($_SESSION['dd_question_ids']) || !isset($_SESSION['dd_question_ids'][$_GET['qid']])) {
24 // Just exit as we're in an IFRAME
28 unset($_SESSION['dd_question_ids'][$_GET['qid']]);
29 if (count($_SESSION['dd_question_ids']) == 0) {
30 unset($_SESSION['dd_question_ids']);
32 session_write_close();
33 $_GET['qid'] = intval($_GET['qid']);
34 $sql = "SELECT * FROM ".TABLE_PREFIX."tests_questions WHERE question_id=$_GET[qid]";
35 $result = mysql_query($sql, $db);
36 $row = mysql_fetch_assoc($result);
38 $_letters = array(_AT('A'), _AT('B'), _AT('C'), _AT('D'), _AT('E'), _AT('F'), _AT('G'), _AT('H'), _AT('I'), _AT('J'));
39 $_colours = array('#FF9900', '#00FF00', '#0000FF', '#F23AA3', '#9999CC', '#990026', '#0099CC', '#22C921', '#007D48', '#00248F');
42 for ($i=0; $i < 10; $i++) {
43 if ($row['option_'. $i] != '') {
48 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
49 <html lang="<?php echo $_SESSION['lang']; ?>">
51 <title><?php echo SITE_NAME; ?> : <?php echo AT_print($row['question'], 'tests_questions.question'); ?></title>
52 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $myLang->getCharacterSet(); ?>" />
53 <meta name="Generator" content="ATutor - Copyright 2007 by http://atutor.ca" />
54 <base href="<?php echo AT_BASE_HREF . $content_base_href; ?>" />
55 <script type="text/javascript" src="<?php echo AT_BASE_HREF; ?>jscripts/lib/dd_question/jquery.js"></script>
56 <script type="text/javascript" src="<?php echo AT_BASE_HREF; ?>jscripts/lib/dd_question/interface.js"></script>
57 <script type="text/javascript" src="<?php echo AT_BASE_HREF; ?>jscripts/lib/dd_question/wz_jsgraphics.js"></script>
58 <link rel="stylesheet" href="<?php echo AT_BASE_HREF; ?>themes/default/styles.css" type="text/css" />
59 <style type="text/css">
65 background-color: #fdfdfd;
72 border: 1px solid #ccc;
89 background-color: #fc9;
92 background-color: #ffc;
98 <?php $response = explode('|', $_GET['response']); ?>
100 <?php for ($i=0; $i < 10; $i++): ?>
101 <?php if ($row['choice_'. $i] != ''): ?>
102 <div id="container<?php echo $i; ?>" style="position: absolute; top: 0px; left: 0px; width: 100%"></div>
107 <ul style="position: absolute; top: 10px; left: 5px" id="q">
108 <?php for ($i=0; $i < 10; $i++): ?>
109 <?php if ($row['choice_'. $i] != ''): ?>
110 <li class="question" id="q<?php echo $i; ?>" value="<?php echo $i; ?>">
111 <select name="s<?php echo $i; ?>" onchange="selectLine(this.value, '<?php echo $i; ?>');" id="s<?php echo $i; ?>">
112 <option value="-1">-</option>
113 <?php for ($j=0; $j < $num_options; $j++): ?>
114 <option value="<?php echo $j; ?>" <?php if($response[$i] == $j): ?>selected="selected"<?php endif; ?>><?php echo $_letters[$j]; ?></option>
118 <?php echo AT_print($row['choice_'.$i], 'tests_questions.question'); ?></li>
123 <ol style="position: absolute; list-style-type: upper-alpha; top: 10px; left: 310px" id="a">
124 <?php for ($i=0; $i < 10; $i++): ?>
125 <?php if ($row['option_'. $i] != ''): ?>
126 <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>
131 <script type="text/javascript">
139 <?php for ($i=0; $i < 10; $i++): ?>
140 <?php if ($row['choice_'. $i] != ''): ?>
141 jg[<?php echo $i; ?>] = new jsGraphics("container<?php echo $i; ?>");
142 jg[<?php echo $i; ?>].setStroke(3);
143 jg[<?php echo $i; ?>].setColor("<?php echo $_colours[$i]; ?>");
147 var container_html = $("#container0").html();
152 $('#q>li').Draggable(
154 containment: "document",
159 fx: 0 // doesn't update select menu in FF if > 0
163 $('#a>li').Droppable(
166 activeclass: 'dropactive',
167 hoverclass: 'drophover',
168 tolerance: "pointer",
169 ondrop: function (drag) {
170 var lx = drag.offsetLeft + $("#" + drag.id).width() + padding;
171 var ly = drag.offsetTop + $("#" + drag.id).height()/2 + 10;
172 var rx = this.offsetLeft + 310;
173 var ry = this.offsetTop + $("#" + this.id).height()/2 + 10;
175 document.getElementById('s' + drag.value).selectedIndex = this.value + 1;
177 window.top.document.getElementById("<?php echo $_GET['qid']; ?>q" + drag.value).value = this.value;
179 $("#container" + drag.value).html(container_html);
181 jg[drag.value].drawLine(lx, ly , rx, ry );
182 jg[drag.value].paint();
189 parent.iframeSetHeight(<?php echo $_GET['qid']; ?>, Math.max($("#q").height(), $("#a").height()));
190 <?php foreach ($response as $id => $value): ?>
191 selectLine(<?php echo $value; ?>, <?php echo $id; ?>);
196 function selectLine(value, id) {
198 window.top.document.getElementById("<?php echo $_GET['qid']; ?>q" + id).value = "-1";
199 $("#container" + id).html(container_html);
204 var lx = document.getElementById("q" + id).offsetLeft + $("#q" + id).width() + padding;
205 var ly = document.getElementById("q" + id).offsetTop + $("#q" + id).height()/2 + 10;
206 var rx = document.getElementById("a" + value).offsetLeft + 310;
207 var ry = document.getElementById("a" + value).offsetTop + $("#a" + value).height()/2 + 10;
209 window.top.document.getElementById("<?php echo $_GET['qid']; ?>q" + id).value = value;
211 $("#container" + id).html(container_html);
212 jg[id].drawLine(lx, ly , rx, ry );