+++ /dev/null
-<?php\r
-/************************************************************************/\r
-/* ATutor */\r
-/************************************************************************/\r
-/* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/\r
-/* Adaptive Technology Resource Centre / University of Toronto */\r
-/* http://atutor.ca */\r
-/* */\r
-/* This program is free software. You can redistribute it and/or */\r
-/* modify it under the terms of the GNU General Public License */\r
-/* as published by the Free Software Foundation. */\r
-/************************************************************************/\r
-// $Id: grade_scale_add.php 7208 2008-05-28 16:07:24Z cindy $\r
-\r
-$page = 'gradebook';\r
-\r
-define('AT_INCLUDE_PATH', '../../include/');\r
-require_once(AT_INCLUDE_PATH.'vitals.inc.php');\r
-authenticate(AT_PRIV_GRADEBOOK);\r
-\r
-require_once("lib/gradebook.inc.php");\r
-\r
-// Checks if the given test has students taken it more than once, if has,\r
-// print feedback and return false, otherwise, return true.\r
-function is_test_updatable($gradebook_test_id)\r
-{\r
- global $db, $msg;\r
- \r
- $sql = "SELECT g.id, t.title FROM ".TABLE_PREFIX."gradebook_tests g, ".TABLE_PREFIX."tests t WHERE g.id=t.test_id AND g.type='ATutor Test' AND g.gradebook_test_id = ". $gradebook_test_id;\r
- $result = mysql_query($sql, $db) or die(mysql_error());\r
- $row = mysql_fetch_assoc($result);\r
- \r
- $no_error = true;\r
- \r
- $studs_take_num = get_studs_take_more_than_once($_SESSION["course_id"], $row["id"]);\r
- \r
- foreach ($studs_take_num as $student => $num)\r
- {\r
- if ($no_error) $no_error = false;\r
- $error_msg .= $student . ": " . $num . " times<br>";\r
- }\r
- \r
- if (!$no_error)\r
- {\r
- $f = array('UPDATE_GRADEBOOK',\r
- $row['title'], \r
- $error_msg);\r
- $msg->addFeedback($f);\r
- }\r
-\r
- if ($no_error) \r
- return true;\r
- else \r
- return false;\r
-}\r
-\r
-function update_gradebook($gradebook_test_id, $member_id)\r
-{\r
- global $db;\r
-\r
- $sql = "SELECT id, grade_scale_id FROM ".TABLE_PREFIX."gradebook_tests WHERE gradebook_test_id = ". $gradebook_test_id;\r
- $result = mysql_query($sql, $db) or die(mysql_error());\r
- $row = mysql_fetch_assoc($result);\r
- $test_id = $row["id"];\r
- $grade_scale_id = $row["grade_scale_id"];\r
- \r
- // get grade\r
- $grade = get_member_grade($test_id, $member_id, $grade_scale_id);\r
- \r
- if ($grade <> "")\r
- {\r
- $sql = "REPLACE INTO ".TABLE_PREFIX."gradebook_detail(gradebook_test_id, member_id, grade) VALUES (".$gradebook_test_id.", ".$member_id.", '".$grade."')";\r
- $result = mysql_query($sql, $db) or die(mysql_error());\r
- }\r
-}\r
-\r
-// Initialize all applicable tests array and all enrolled students array\r
-$tests = array();\r
-$students = array();\r
-\r
-// generate gradebook test array\r
-$sql = "SELECT *, t.title FROM ".TABLE_PREFIX."gradebook_tests g, ".TABLE_PREFIX."tests t WHERE g.id = t.test_id AND g.type='ATutor Test' AND t.course_id=".$_SESSION["course_id"];\r
-$result = mysql_query($sql, $db) or die(mysql_error());\r
-while ($row = mysql_fetch_assoc($result))\r
-{\r
- $test["gradebook_test_id"] = $row["gradebook_test_id"];\r
- $test["title"] = $row["title"];\r
- \r
- array_push($tests, $test);\r
-}\r
-\r
-// generate students array\r
-$sql = "SELECT m.first_name, m.last_name, e.member_id FROM ".TABLE_PREFIX."members m, ".TABLE_PREFIX."course_enrollment e WHERE m.member_id = e.member_id AND e.course_id=".$_SESSION["course_id"]." AND e.approved='y' AND e.role<>'Instructor' ORDER BY m.first_name,m.last_name";\r
-$result = mysql_query($sql, $db) or die(mysql_error());\r
-\r
-while ($row = mysql_fetch_assoc($result))\r
-{\r
- $student["first_name"] = $row["first_name"];\r
- $student["last_name"] = $row["last_name"];\r
- $student["member_id"] = $row["member_id"];\r
- \r
- array_push($students, $student);\r
-}\r
-// end of initialization\r
-\r
-if (isset($_POST['cancel'])) \r
-{\r
- $msg->addFeedback('CANCELLED');\r
- header('Location: gradebook_tests.php');\r
- exit;\r
-} \r
-else if (isset($_POST['update'])) \r
-{\r
- if (!$msg->containsErrors()) \r
- {\r
- if ($_POST["gradebook_test_id"] == 0)\r
- {\r
- foreach($tests as $test)\r
- {\r
- if (is_test_updatable($test["gradebook_test_id"]))\r
- {\r
- if ($_POST["member_id"]==0)\r
- {\r
- // delete old data for this test\r
- $sql = "DELETE from ".TABLE_PREFIX."gradebook_detail WHERE gradebook_test_id = ".$test["gradebook_test_id"];\r
- $result = mysql_query($sql, $db) or die(mysql_error());\r
- \r
- foreach($students as $student)\r
- update_gradebook($test["gradebook_test_id"], $student["member_id"]);\r
- }\r
- else\r
- update_gradebook($test["gradebook_test_id"], $_POST["member_id"]);\r
- }\r
- }\r
- }\r
- else\r
- {\r
- if (is_test_updatable($_POST["gradebook_test_id"]))\r
- {\r
- if ($_POST["member_id"]==0)\r
- {\r
- // delete old data for this test\r
- $sql = "DELETE from ".TABLE_PREFIX."gradebook_detail WHERE gradebook_test_id = ".$_POST["gradebook_test_id"];\r
- $result = mysql_query($sql, $db) or die(mysql_error());\r
- \r
- foreach($students as $student)\r
- update_gradebook($_POST["gradebook_test_id"], $student["member_id"]);\r
- }\r
- else\r
- update_gradebook($_POST["gradebook_test_id"], $_POST["member_id"]);\r
- }\r
- }\r
- \r
- $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');\r
- }\r
-} \r
-\r
-require(AT_INCLUDE_PATH.'header.inc.php');\r
-\r
-?>\r
-<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">\r
-<div class="input-form">\r
- <fieldset class="group_form"><legend class="group_form"><?php echo _AT('update_gradebook'); ?></legend>\r
-\r
-<?php\r
-if (count($tests) == 0)\r
-{\r
-?>\r
- <div class="row">\r
- <strong><?php echo _AT('none_found'); ?></strong>\r
- </div>\r
-<?php \r
-}\r
-else\r
-{\r
- // list of tests\r
- echo ' <div class="row">'."\n\r";\r
- echo ' <label for="select_tid1">'. _AT("tests") .'</label><br />'."\n\r";\r
- echo ' <select name="gradebook_test_id" id="select_tid1">'."\n\r";\r
- echo ' <option value="0">'. _AT('all') .'</option>'."\n\r";\r
-\r
- foreach($tests as $test)\r
- {\r
- echo ' <option value="'.$test[gradebook_test_id].'">'.$test[title].'</option>'."\n\r";\r
- }\r
- echo ' </select>'."\n\r";\r
- echo ' </div>'."\n\r";\r
-\r
- // list of students\r
- echo ' <div class="row">'."\n\r";\r
- echo ' <label for="select_sid">'. _AT("students") .'</label><br />'."\n\r";\r
- echo ' <select name="member_id" id="select_sid">'."\n\r";\r
- echo ' <option value="0">'. _AT('all') .'</option>'."\n\r";\r
-\r
- foreach($students as $student)\r
- {\r
- echo ' <option value="'.$student[member_id].'">'.$student[first_name].' '.$student[last_name].'</option>'."\n\r";\r
- }\r
- echo ' </select>'."\n\r";\r
- echo ' </div>'."\n\r";\r
-?>\r
-\r
- <div class="row buttons">\r
- <input type="submit" name="update" value="<?php echo _AT('update'); ?>" />\r
- <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />\r
- </div>\r
-<?php\r
-}\r
-?>\r
- </fieldset>\r
-\r
-</div>\r
-</form>\r
-\r
-<form name="form1" method="post" action="mods/gradebook/verify_tests.php">\r
-<div class="input-form">\r
- <fieldset class="group_form"><legend class="group_form"><?php echo _AT('combine_tests'); ?></legend>\r
- <div class="row">\r
- <p><?php echo _AT('combine_tests_info'); ?></p>\r
- </div>\r
-\r
-<?php\r
-if (count($tests) == 0)\r
-{\r
-?>\r
- <div class="row">\r
- <strong><?php echo _AT('none_found'); ?></strong>\r
- </div>\r
-<?php \r
-}\r
-else\r
-{\r
- // list of tests\r
- echo ' <div class="row">'."\n\r";\r
- echo ' <label for="select_tid2">'. _AT("tests") .' '. _AT("combine_into").'</label><br />'."\n\r";\r
- echo ' <select name="gradebook_test_id" id="select_tid2">'."\n\r";\r
-\r
- foreach($tests as $test)\r
- echo ' <option value="'.$test[gradebook_test_id].'">'.$test[title].'</option>'."\n\r";\r
-\r
- echo ' </select>'."\n\r";\r
- echo ' </div>'."\n\r";\r
-\r
- // list of atutor tests that can be combined. \r
- // These tests can only be taken once and are not in gradebook yet\r
- // note: surveys are excluded by checking if question weights are defined\r
- $sql_at = "SELECT * FROM ".TABLE_PREFIX."tests t".\r
- " WHERE course_id=".$_SESSION["course_id"].\r
- " AND num_takes = 1".\r
- " AND NOT EXISTS (SELECT 1".\r
- " FROM ".TABLE_PREFIX."gradebook_tests g".\r
- " WHERE g.id = t.test_id".\r
- " AND g.type='ATutor Test')".\r
- " AND test_id IN (SELECT test_id FROM ".TABLE_PREFIX."tests_questions_assoc ".\r
- " WHERE weight > 0 ".\r
- " GROUP BY test_id ".\r
- " HAVING count(*) > 1) ".\r
- " ORDER BY title";\r
- $result_at = mysql_query($sql_at, $db) or die(mysql_error());\r
- \r
- if (mysql_num_rows($result_at) == 0)\r
- echo _AT('none_found');\r
- else\r
- {\r
- echo ' <div class="row">'."\n\r";\r
- echo ' <label for="select_tid3">'. _AT("tests") .' '. _AT("combine_from").'</label><br />'."\n\r";\r
- echo ' <select name="test_id" id="select_tid3">'."\n\r";\r
- \r
- if (mysql_num_rows($result_at) > 0)\r
- {\r
- while ($row_at = mysql_fetch_assoc($result_at))\r
- {\r
- echo ' <option value="'.$row_at[test_id].'">'.$row_at[title].'</option>'."\n\r";\r
- }\r
- }\r
- \r
- echo ' </select>'."\n\r";\r
- echo ' </div>'."\n\r";\r
- }\r
-?>\r
-\r
- <div class="row buttons">\r
- <input type="submit" name="combine" value="<?php echo _AT('combine'); ?>" />\r
- <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />\r
- </div>\r
-<?php\r
-}\r
-?>\r
- </fieldset>\r
-\r
-</div>\r
-</form>\r
-\r
-<?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>\r