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 /************************************************************************/
14 define('TR_INCLUDE_PATH', '../include/');
15 require_once(TR_INCLUDE_PATH.'vitals.inc.php');
16 require_once(TR_INCLUDE_PATH.'classes/testQuestions.class.php');
17 require_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
18 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsDAO.class.php');
19 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsCategoriesDAO.class.php');
20 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsAssocDAO.class.php');
24 Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
25 $testsDAO = new TestsDAO();
26 $testsQuestionsCategoriesDAO = new TestsQuestionsCategoriesDAO();
27 $testsQuestionsAssocDAO = new TestsQuestionsAssocDAO();
29 $_pages['tests/questions.php']['title_var'] = 'questions';
30 $_pages['tests/questions.php']['parent'] = 'tests/index.php';
31 $_pages['tests/questions.php']['children'] = array('tests/add_test_questions.php?tid='.$_GET['tid'].'&_course_id='.$_course_id);
33 $_pages['tests/add_test_questions.php?tid='.$_GET['tid'].'&_course_id='.$_course_id]['title_var'] = 'add_questions';
34 $_pages['tests/add_test_questions.php?tid='.$_GET['tid'].'&_course_id='.$_course_id]['parent'] = 'tests/questions.php?tid='.$_GET['tid'].'&_course_id='.$_course_id;
36 $_pages['tests/questions.php']['guide'] = 'instructor/?p=add_questions.php';
38 $tid = intval($_REQUEST['tid']);
40 if (isset($_POST['submit'])) {
42 foreach ($_POST['weight'] as $qid => $weight) {
44 $weight = intval($weight);
46 $orders = $_POST['ordering'];
48 $orders = array_keys($orders);
50 foreach ($orders as $k => $id)
51 $orders[$k] = intval($id);
53 $orders = array_flip($orders);
55 $testsQuestionsAssocDAO->Update($tid, $qid, $weight, $orders[$qid]+1);
59 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
60 header('Location: '.$_SERVER['PHP_SELF'] .'?tid='.$tid.'&_course_id='.$_course_id);
65 $cats[0] = _AT('cats_uncategorized');
66 $cat_rows = $testsQuestionsCategoriesDAO->getByCourseID($_course_id);
67 if (is_array($cat_rows)) {
68 foreach ($cat_rows as $cat_row) {
69 $cats[$cat_row['category_id']] = $cat_row['title'];
73 require_once(TR_INCLUDE_PATH.'header.inc.php');
75 $row = $testsDAO->get($tid);
76 echo '<div class="input-form">';
77 echo '<h3>'._AT('questions_for').' '.AT_print($row['title'], 'tests.title').'</h3>';
79 $rows = $testsQuestionsAssocDAO->getZeroWeightRowsByTestID($tid);
80 if (is_array($rows)) {
81 $msg->printWarnings('QUESTION_WEIGHT');
86 $rows = $testsQuestionsAssocDAO->getByTestID($tid);
88 $savant->assign('cats', $cats);
89 $savant->assign('rows', $rows);
90 $savant->assign('tid', $tid);
91 $savant->assign('course_id', $_course_id);
92 $savant->display('tests/questions.tmpl.php');
94 require_once(TR_INCLUDE_PATH.'footer.inc.php');?>