2 define('AT_INCLUDE_PATH', '../../../include/');
3 require(AT_INCLUDE_PATH.'vitals.inc.php');
4 authenticate(AT_PRIV_BASICLTI);
6 require_once('forms.php');
9 // Filter all GET data //
10 $_POST['framed'] = intval($_POST['framed']);
11 $_POST['popup'] = intval($_POST['popup']);
12 $_POST['cid'] = intval($_POST['cid']);
14 if ( !is_int($_SESSION['course_id']) || $_SESSION['course_id'] < 1 ) {
15 $msg->addFeedback('NEED_COURSE_ID');
19 // Add/Update The Tool
20 if ( isset($_POST['toolid']) && at_form_validate($blti_content_edit_form, $msg)) {
21 $toolid = $_POST['toolid']; // Escaping is done in the at_form_util code
22 $sql = "SELECT * FROM ".TABLE_PREFIX."basiclti_content
23 WHERE content_id=".$_POST[cid]." AND course_id=".$_SESSION[course_id];
26 $result = mysql_query($sql, $db);
27 if ( $toolid == '--none--' ) {
28 $sql = "DELETE FROM ". TABLE_PREFIX . "basiclti_content
29 WHERE content_id=".$_POST[cid]." AND
30 course_id=".$_SESSION[course_id];
31 $result = mysql_query($sql, $db);
32 if ($result===false) {
33 $msg->addError('MYSQL_FAILED');
35 $msg->addFeedback('BASICLTI_DELETED');
37 } else if ( mysql_num_rows($result) == 0 ) {
38 $sql = "INSERT INTO ". TABLE_PREFIX . "basiclti_content
39 SET toolid='".$toolid."', content_id=".$_POST[cid].",
40 course_id=".$_SESSION[course_id];
42 $result = mysql_query($sql, $db);
43 if ($result===false) {
44 $msg->addError('MYSQL_FAILED');
46 $msg->addFeedback('BASICLTI_SAVED');
49 } else if ( $result !== false ) {
51 $gradebook_test_id = 0;
52 $basiclti_content_row = mysql_fetch_assoc($result);
53 $placementsecret = $basiclti_content_row['placementsecret'];
54 $gradebook_check = intval($_POST['gradebook_test_id']);
55 if ( isset($_POST['gradebook_test_id']) && $gradebook_check > 0 ) {
56 $gradebook_test_id = $gradebook_check;
57 $sql = "SELECT g.gradebook_test_id AS id, g.title AS title
58 FROM ".TABLE_PREFIX."gradebook_tests AS g
59 WHERE g.course_id = ".$_SESSION[course_id]."
60 AND g.type = 'External' and g.grade_scale_id = 0
61 AND gradebook_test_id = ".$gradebook_test_id;
62 $result = mysql_query($sql, $db);
63 if ( $result === false ) {
64 $gradebook_test_id = 0;
66 if ( strlen($placementsecret) < 1 ) {
67 $placementsecret = uniqid("bl",true);
71 // Override these fields (don't take from form)
72 $fields = array('toolid' => $toolid, 'gradebook_test_id' => $gradebook_test_id,
73 'placementsecret' => $placementsecret);
74 $sql = at_form_update($_POST, $blti_content_edit_form, $fields);
75 $sql = "UPDATE ". TABLE_PREFIX . "basiclti_content
76 SET ".$sql." WHERE content_id=".$_POST[cid]." AND
77 course_id=".$_SESSION[course_id];
78 $result = mysql_query($sql, $db);
79 if ($result===false) {
80 $msg->addError('MYSQL_FAILED');
82 $msg->addFeedback('BASICLTI_SAVED');
87 // echo("<hr>$sql<hr>\n");
89 $cid = intval($_REQUEST['cid']);
91 global $framed, $popup;
93 if ((isset($_REQUEST['popup']) && $_REQUEST['popup']) &&
94 (!isset($_REQUEST['framed']) || !$_REQUEST['framed'])) {
97 } elseif (isset($_REQUEST['framed']) && $_REQUEST['framed'] && isset($_REQUEST['popup']) && $_REQUEST['popup']) {
106 require(AT_INCLUDE_PATH.'header.inc.php');
108 /* get a list of all the tools, we have */
109 $sql = "SELECT * FROM ".TABLE_PREFIX."basiclti_tools WHERE course_id = 0".
110 " OR course_id=".$_SESSION[course_id]." ORDER BY course_id,title";
112 $toolresult = mysql_query($sql, $db);
113 $num_tools = mysql_num_rows($toolresult);
115 //If there are no Tools, don't display anything except a message
116 if ($num_tools == 0){
117 $msg->addInfo('NO_PROXY_TOOLS');
123 <div class="input-form">
125 <form name="datagrid" action="" method="POST">
127 <fieldset class="group_form">
128 <legend class="group_form"><?php echo _AT('bl_content_title'); ?></legend>
130 <?php echo _AT('basiclti_comment');?>
132 <?php echo $msg->printFeedbacks();
134 // Get the current content item
135 $sql = "SELECT * FROM ".TABLE_PREFIX."basiclti_content
136 WHERE content_id=$cid";
137 $contentresult = mysql_query($sql, $db);
138 $basiclti_content_row = mysql_fetch_assoc($contentresult);
139 // if ( $basiclti_content_row ) echo("FOUND"); else echo("NOT");
142 <?php echo _AT('bl_choose_tool'); ?><br/>
143 <select id="toolid" name="toolid" onchange="datagrid.submit();">
144 <option value="--none--"> </option><?php
145 $basiclti_tool_row = false;
146 $found = false; // Only the first one
147 while ( $tool = mysql_fetch_assoc($toolresult) ) {
149 if ( ! $found && $tool['toolid'] == $basiclti_content_row['toolid'] ) {
150 $selected = ' selected="yes"';
151 $basiclti_tool_row = $tool;
154 echo '<option value="'.$tool['toolid'].'"'.$selected.'>'.$tool['title']."</option>\n";
159 if ( $basiclti_tool_row != false && $basiclti_tool_row['acceptgrades'] == 1 ) {
160 $sql = "SELECT g.gradebook_test_id AS id, g.title AS title
161 FROM ".TABLE_PREFIX."gradebook_tests AS g
162 WHERE g.course_id = ".$_SESSION[course_id]."
163 AND g.type = 'External' and g.grade_scale_id = 0";
164 $graderesult = mysql_query($sql, $db);
165 if ( $graderesult !== false && mysql_num_rows($graderesult) > 0) { ?>
167 <?php echo _AT('bl_choose_gradbook_entry'); ?><br/>
168 <select id="gradebook_test_id" name="gradebook_test_id">
169 <option value="--none--"> </option><?php
170 while ( $gradeitem = mysql_fetch_assoc($graderesult) ) {
171 echo($gradeitem['title']);
173 if ( $gradeitem['id'] == $basiclti_content_row['gradebook_test_id'] ) {
174 $selected = ' selected="yes"';
176 echo '<option value="'.$gradeitem['id'].'"'.$selected.'>'.$gradeitem['title']."</option>\n";
183 <input type="hidden" name="cid" value="<?php echo($cid);?>" />
185 if ( $basiclti_tool_row !== false ) {
186 $blti_content_edit_form = filterForm($basiclti_tool_row, $blti_content_edit_form);
187 at_form_generate($basiclti_content_row, $blti_content_edit_form);
188 echo('<input type="submit" name="save" value="Save" class="button" />'."\n");
196 if($basiclti_tool_row){
197 echo '<h3>'.$basiclti_tool_row['title'].' '._AT('bl_settings').'</h3>';
198 echo '<ul style="list-style-type:none;">';
199 foreach($basiclti_tool_row as $title=>$setting){
200 if($title == "password" || $title == "resourcekey" && $basiclti_tool_row['course_id'] == 0){
201 // Hide the tool password if its not an instructor created tool //
202 // Don't print out the key or password id its an admin added tool
206 echo '<li>'.$title.' = '.$setting.'</li>';
211 //echo("<hr><pre>\n");print_r($basiclti_tool_row); echo("\n</pre>\n");
213 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>