35ab27d41afad039c9b85d1906cd74fb3e0bdc42
[atutor.git] / mods / scorm_packages / packages / preferences.php
1 <?php
2 /*
3  * packages/preferences.php
4  *
5  * This file is part of ATutor, see http://www.atutor.ca
6  * 
7  * Copyright (C) 2005  Matthai Kurian 
8  * 
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; either version 2
12  * of the License, or (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  * 
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  */
23
24 define('AT_INCLUDE_PATH', '../../../include/');
25 require(AT_INCLUDE_PATH.'vitals.inc.php');
26
27
28
29 $sql = "SELECT  lvalue, rvalue
30         FROM   ".TABLE_PREFIX."cmi
31         WHERE   item_id = 0
32         AND     member_id = " . $_SESSION[member_id]
33         ;
34
35 $result = mysql_query($sql, $db);
36 while ($row = mysql_fetch_assoc($result)) {
37         $p[$row['lvalue']] = $row['rvalue'];
38 }
39
40 if (!isset ($p['auto_advance'])) {
41         $p['auto_advance']           = 0;
42         $sql = "INSERT INTO ".TABLE_PREFIX."cmi
43                 VALUES (NULL, 0, $_SESSION[member_id], 'auto_advance', '0')";
44         $result = mysql_query($sql, $db);
45
46 }
47 if (!isset ($p['show_rte_communication'])) {
48         $p['show_rte_communication'] = 0;
49         $sql = "INSERT INTO ".TABLE_PREFIX."cmi
50                 VALUES (NULL, 0, $_SESSION[member_id],
51                         'show_rte_communication', '0'
52                 )";
53         $result = mysql_query($sql, $db);
54 }
55
56 if (isset ($_POST['upd'])) {
57         $p['auto_advance'] = $_POST['auto_advance'];
58         $sql = "UPDATE ".TABLE_PREFIX."cmi
59                 SET     rvalue = '$p[auto_advance]'
60                 WHERE   member_id = $_SESSION[member_id]
61                 AND     item_id = 0
62                 AND     lvalue = 'auto_advance'
63                 ";
64         $result1 = mysql_query($sql, $db);
65
66
67         $p['show_rte_communication'] = $_POST['show_rte_communication'];
68         $sql = "UPDATE ".TABLE_PREFIX."cmi
69                 SET     rvalue = '$p[show_rte_communication]'
70                 WHERE   member_id = $_SESSION[member_id]
71                 AND     item_id = 0
72                 AND     lvalue = 'show_rte_communication'
73                 ";
74         $result2 = mysql_query($sql, $db);
75
76         if ($result1 && $result2) {
77                 $msg->addFeedback (SCORM_SETTINGS_SAVED);
78         } else {
79                 $msg->addError (SCORM_SETTINGS_SAVE_FAILED);
80         }
81 }
82
83 require(AT_INCLUDE_PATH.'header.inc.php');
84 ?>
85
86 <div class="input-form" style="padding:1em;">
87 <form name="form1" method="post"
88             enctype="multipart/form-data">
89             <input type="hidden" name="upd" value="1">
90
91 <p> <?php echo _AT(packages_auto_advance_info);?> </p>
92 <p>
93 <input type="checkbox" id="auto_advance" name="auto_advance" value="1" 
94 <?php echo ($p['auto_advance']?'checked':'');?> />
95 <label for="auto_advance"><?php echo _AT('packages_auto_advance');?><label>
96 </p>
97
98 <p> <?php echo _AT(packages_show_rte_communication_info);?> </p>
99 <p>
100 <input type="checkbox" id="show_rte_communication" name="show_rte_communication"
101        value="1" 
102 <?php echo ($p['show_rte_communication']?'checked':'');?> />
103 <label for="show_rte_communication">
104         <?php echo _AT('packages_show_rte_communication');?>
105 <label>
106 </p>
107
108 <div class="row buttons">
109 <input type="submit" name="submit" value="<?php echo _AT('save');?> " />
110 </div>
111
112 </form>
113 </div>
114
115 <?php require (AT_INCLUDE_PATH.'footer.inc.php');?>