-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexpress2.php
executable file
·218 lines (155 loc) · 5.84 KB
/
express2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?PHP // $Id: edit.php,v 1.15 2005/07/14 20:58:07 skodak Exp $
require_once('../../config.php');
require_once('lib.php');
$id = required_param('id', PARAM_INT); // Course Module ID
$gravar = optional_param('gravar', 0, PARAM_INT);
$qtde_biblio = optional_param('qtde_biblio', 0, PARAM_INT);
$qtde_hw = optional_param('qtde_hw', 0, PARAM_INT);
$qtde_tips = optional_param('qtde_tips', 0, PARAM_INT);
for($i = 1 ; $i <= $qtde_biblio; $i++){
$variavel = 'suggestion_title'.$i;
$variavel2 = 'suggestion'.$i;
$$variavel = optional_param('suggestion_title'.$i, 0); //
$$variavel2 = optional_param('suggestion'.$i, 0); //
}
for($i = 1 ; $i <= $qtde_hw; $i++){
$variavel = 'hotword_title'.$i;
$variavel2 = 'hotword'.$i;
$$variavel = optional_param('hotword_title'.$i, 0); //
$$variavel2 = optional_param('hotword'.$i, 0); //
}
for($i = 1 ; $i <= $qtde_tips; $i++){
$variavel = 'tip_title'.$i;
$variavel2 = 'tip'.$i;
$$variavel = optional_param('tip_title'.$i, 0); //
$$variavel2 = optional_param('tip'.$i, 0); //
}
// =========================================================================
// security checks START - only teachers edit
// =========================================================================
require_login();
if (!$cm = get_record('course_modules', 'id', $id)) {
error('Course Module ID was incorrect');
}
if (!$course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
if (!isteacheredit($course->id)) {
error('Only editing teachers can edit books!', $_SERVER['HTTP_REFERER']);
}
if (!$book = get_record('hiperbook', 'id', $cm->instance)) {
error('Course module is incorrect');
}
/// If data submitted, then process and store.
if ( ($form = data_submitted() )& $gravar) {
//TODO: skip it for now
// $db->debug =true;
// insere os registros
for($i =1 ; $i <= $qtde_hw; $i++ ){
$variavel = 'hotword'.$i;
$variavel2 = 'hotword_title'.$i;
$element->content = $$variavel;
$element->title = $$variavel2;
$element->hotwordnum = $i;
$element->idhiperbook = $cm->instance;
$element->groupid = 0;
$element->userid = $USER->id;
$element->opentostudents = 0;
if(!$newid = insert_record('hiperbook_chapters_hotword',$element)) {
error('Could not update your hiperbook!');
}
}
for($i =1 ; $i <= $qtde_biblio; $i++ ){
$variavel = 'suggestion'.$i;
$variavel2 = 'suggestion_title'.$i;
$element->content = $$variavel;
$element->title = $$variavel2;
$element->hotwordnum = $i;
$element->idhiperbook = $cm->instance;
$element->groupid = 0;
$element->userid = $USER->id;
$element->opentostudents = 0;
if(!$newid = insert_record('hiperbook_chapters_suggestions',$element)) {
error('Could not update your hiperbook!');
}
}
for($i =1 ; $i <= $qtde_tips; $i++ ){
$variavel = 'tip'.$i;
$variavel2 = 'tip_title'.$i;
$element->content = $$variavel;
$element->title = $$variavel2;
$element->hotwordnum = $i;
$element->idhiperbook = $cm->instance;
$element->groupid = 0;
$element->userid = $USER->id;
$element->opentostudents = 0;
if(!$newid = insert_record('hiperbook_chapters_tips',$element)) {
error('Could not update your hiperbook!');
}
}
redirect($CFG->wwwroot."/mod/hiperbook/express0.php?id=".$id);
}
$strbook = get_string('modulename', 'hiperbook');
$strbooks = get_string('modulenameplural', 'hiperbook');
$stredit = get_string('edit'). ' templates';
$pageheading = get_string('editingpage', 'hiperbook');
if ($course->category) {
$navigation = '<a href="../../course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->';
} else {
$navigation = '';
}
print_header( "$course->shortname: $book->name",
$course->fullname,
"$navigation <a href=\"index.php?id=$course->id\">$strbooks</A> -> <a href=\"view.php?id=$cm->id\"> $book->name </a> -> <a href=\"express0.php?id=$cm->id\"> implementação </a> -> definindo Biblioteca ",
'',
'',
true,
'',
''
);
?>
<form id="form1" name="form1" method="post" action="express2.php">
<input type="hidden" name="id" value="<?php echo $id ?>" />
<input type="hidden" name="qtde_hw" value="<?php echo $qtde_hw ?>" />
<input type="hidden" name="gravar" value="1" />
<input type="hidden" name="qtde_tips" value="<?php echo $qtde_tips ?>" />
<input type="hidden" name="qtde_biblio" value="<?php echo $qtde_biblio ?>" />
<p>Glossario</p>
<?php
for($i=1;$i<=$qtde_hw;$i++){
echo '<input type="text" name="hotword_title'.$i.'" /><br>';
$d = 'hotword'.$i;
print_textarea($usehtmleditor, 14, 44, 220, 150, $d, $book->template_hw, $course->id);
echo '<br>';
}
?>
<p>Dicas</p>
<p><?php
for($i=1;$i<=$qtde_tips;$i++){
echo '<input type="text" name="tip_title'.$i.'" /><br>';
print_textarea($usehtmleditor, 14, 44, 220, 150, 'tip'.$i, $book->template_tips, $course->id);
echo '<br>';
}
?>
<p>Bibliografias</p>
<?php
for($i=1;$i<=$qtde_biblio;$i++){
echo '<input type="text" name="suggestion_title'.$i.'" /><br>';
print_textarea($usehtmleditor, 14, 44, 220, 150, 'suggestion'.$i, $book->template_suggs, $course->id);
echo '<br>';
}
if ($usehtmleditor ) {
use_html_editor();
}
?>
<p>
<label>
<input type="submit" name="button" id="button" value="Submit" />
</label>
</p>
</form>
<p> </p>
</body>
</html>