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 if (!defined('TR_INCLUDE_PATH')) { exit; }
14 global $_course_id, $_content_id;
16 include_once(TR_INCLUDE_PATH.'classes/DAO/ContentTestsAssocDAO.class.php');
17 include_once(TR_INCLUDE_PATH.'classes/DAO/TestsDAO.class.php');
18 /* Get the list of associated tests with this content on page load */
19 $cid = $_REQUEST['cid'] = $_content_id; //uses request 'cause after 'saved', the cid will become $_GET.
21 $testsDAO = new TestsDAO();
24 $all_tests = $testsDAO->getByCourseID($_course_id);
25 /* get a list of all the tests we have, and links to create, edit, delete, preview */
26 //$sql = "SELECT *, UNIX_TIMESTAMP(start_date) AS us, UNIX_TIMESTAMP(end_date) AS ue
27 // FROM ".TABLE_PREFIX."tests
28 // WHERE course_id=$_SESSION[course_id]
29 // ORDER BY start_date DESC";
30 //$result = mysql_query($sql, $db);
31 if (is_array($all_tests)) $num_tests = count($all_tests);
33 //If there are no tests, don't display anything except a message
35 $msg->addInfo(array('NO_TESTS', TR_BASE_HREF.'tests/create_test.php?_course_id='.$_course_id));
41 foreach ($all_tests as $row) {
42 $results[$i]['test_id'] = $row['test_id'];
43 $results[$i]['title'] = $row['title'];
50 <span style="font-weight:bold"><?php echo _AT('about_content_tests', TR_BASE_HREF.'tests/create_test.php?_course_id='.$_course_id); ?></span>
54 <p><?php echo _AT('custom_test_message'); ?></p>
55 <textarea name="test_message"><?php echo $_POST['test_message']; ?></textarea>
59 if (is_array($results)) print_test_table($results, $_POST['tid']);
61 function print_test_table($results, $post_tids, $id_prefix='') {?>
63 <input type="hidden" name="visited_tests" value="1" />
64 <table class="data" summary="" style="width: 90%" rules="cols">
67 <th scope="col"> </th>
68 <th scope="col"><?php echo _AT('title'); ?></th>
72 <?php if (is_array($results)) { ?>
73 <?php foreach ($results as $row) { ?>
76 if (is_array($post_tids) && in_array($row['test_id'], $post_tids)){
77 $checkMe = ' checked="checked"';
80 <tr onmousedown="toggleTestSelect('<?php echo $id_prefix; ?>r_<?php echo $row['test_id']; ?>');rowselect(this);" id="<?php echo $id_prefix; ?>r_<?php echo $row['test_id']; ?>">
81 <td><input type="checkbox" name="<?php echo $id_prefix; ?>tid[]" value="<?php echo $row['test_id']; ?>" id="<?php echo $id_prefix; ?>t<?php echo $row['test_id']; ?>" <?php echo $checkMe; ?> onmouseup="this.checked=!this.checked" /></td>
82 <td><?php echo $row['title']; ?></td>
92 <script language="javascript" type="text/javascript">
93 function toggleTestSelect(r_id){
94 var row = document.getElementById(r_id);
95 var checkBox = row.cells[0].firstChild;
97 if (checkBox.checked == true){
98 checkBox.checked = false;
100 checkBox.checked = true;