-
Notifications
You must be signed in to change notification settings - Fork 1
/
adm_index.php
executable file
·421 lines (389 loc) · 14.6 KB
/
adm_index.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<?php require_once("includes/initialize.php"); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Administration</title>
<!-- new stylesheet-->
<link href="style/style.css" type="text/css" rel="stylesheet" media="screen">
<script type="text/javascript" src="js/jquery.js"></script>
<script language="javascript" type="application/javascript">
function urlencode(str) {
return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}
function doc(name){
return urlencode(document.getElementById(name).value);
}
function postRequest(strURL,fn_name){
var xmlHttp;
if(window.XMLHttpRequest){ // For Mozilla, Safari, ...
var xmlHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject){ // For Internet Explorer
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open('POST', strURL, true);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.onreadystatechange = function(){
if (xmlHttp.readyState == 4){
updatepage(xmlHttp.responseText,fn_name);
}
}
xmlHttp.send(strURL);
}
function updatepage(str,fn_name){
if (fn_name=='show_addDomain')
{
document.getElementById("change").innerHTML = str;
document.getElementById("hide_list").style.display='block';
}
else if(fn_name=='show_modDomain')
{
document.getElementById("change").innerHTML = str;
document.getElementById("hide_list").style.display='block';
}
else if(fn_name=='addDomain')
{
document.getElementById("result").style.display='block';
document.getElementById("result").innerHTML = str;
listTestDomain('add');
}
else if(fn_name=='listTestDomain')
document.getElementById("listTestDomain").innerHTML = str;
else if(fn_name=='addTest'){
document.getElementById("hide_list").style.display='block';
document.getElementById("result").style.display='none';
document.getElementById("change").innerHTML = str;
}
else if(fn_name=='addTestInfo'){
document.getElementById("hide_list").style.display='none';
document.getElementById("hide_list").style.display='none';
document.getElementById("change").innerHTML = str;
}
else if(fn_name=='addQuesDirectly'){
document.getElementById("hide_list").style.display='none';
document.getElementById("change").innerHTML = str;
}
else if(fn_name=='listTestNames'){
document.getElementById("testnames_div").innerHTML = str;
}
else if(fn_name=='insert_ques'){
document.getElementById("result").style.display='block';
document.getElementById("result").innerHTML = str;
clearquesvalues();
}
else if(fn_name=='modify_domainSub'){
document.getElementById("change").innerHTML = str;
}
}
function ajax_call(fn_name)
{
if(fn_name=='showadd')
{
document.getElementById("addcontent").style.display='table';
document.getElementById("modcontent").style.display='none';
listTestDomain('add');
}
else if(fn_name=='showmod')
{
document.getElementById("addcontent").style.display='none';
document.getElementById("modcontent").style.display='table';
listTestDomain('mod');
ajax_call('show_modDomain');
}
else if(fn_name=='show_addDomain')
{
postRequest('ajax/show_addDomain.php',fn_name);
}
else if(fn_name=='show_modDomain')
{
postRequest('ajax/show_modDomain.php',fn_name);
}
else if(fn_name=='show_modify')
{
postRequest('ajax/show_modify.php',fn_name);
}
else if(fn_name=='show_delete')
{
postRequest('ajax/show_delete.php',fn_name);
}
else if(fn_name=='addDomain')
{
var d=doc("txtDomain");
if(d=='')
{
alert ("No value entered");
return false
}
document.getElementById("txtDomain").value="";
var url="ajax/addDomain.php";
url = url + "?d="+d
postRequest(url,fn_name)
}
}
function listTestDomain(val){
document.getElementById("hide_list").style.display='block';
//var oid=<php echo $_SESSION['owner_id'];?>;
var oid=<?php echo $_SESSION['owner_id']?>;
var url="ajax/listTestDomain.php";
url = url + "?oid="+oid;
url = url + "&p="+val;
postRequest(url,'listTestDomain');
}
function addTestInfo(val)
{
if(document.getElementById("txttestname").value==""){
alert("Enter the Test Name.");
document.getElementById("txttestname").focus();
return false
}
else if(document.getElementById("txtqno").value=="" || isNaN(document.getElementById("txtqno").value)){
alert("Enter valid value for number of questions.");
document.getElementById("txtqno").focus();
return false
}
else if(document.getElementById("hrs").value=="" || isNaN(document.getElementById("hrs").value)){
alert("Enter valid value for Hours.");
document.getElementById("hrs").focus();
return false
}
else if(document.getElementById("mins").value==""|| isNaN(document.getElementById("mins").value)){
alert("Enter valid value for Minutes.");
document.getElementById("mins").focus();
return false
}
else if(document.getElementById("secs").value==""|| isNaN(document.getElementById("secs").value)){
alert("Enter valid value for Seconds.");
document.getElementById("secs").focus();
return false
}
var url="ajax/addQues.php";
url = url + "?tname="+document.getElementById("txttestname").value;
url = url + "&qno="+document.getElementById("txtqno").value;
url = url + "&time="+document.getElementById("hrs").value+":"+document.getElementById("mins").value+":"+document.getElementById("secs").value;
url = url + "&ow_id="+document.getElementById("owner_id").value;
if(val=='**novalue**')
url = url + "&td_id="+document.getElementById("testdomain_id").value;
else
url = url + "&td_id="+val;
postRequest(url,'addTestInfo');
}
function addTest(id,name)
{
var url="ajax/addtest.php";
if(id!='' && name!=''){
url = url + "?did="+id;
url = url + "&dname="+name;
}
postRequest(url,'addTest');
}
function gettestnames(id,oid,tname)
{
var url="ajax/listTestNames.php";
url = url + "?td_id="+id;
url = url + "&ow_id="+oid;
url = url + "&tname="+tname;
postRequest(url,'listTestNames');
}
function modifytest(id,cname,oid)
{
var url="ajax/modify_domainSub.php";
url = url + "?td_id="+id;
url = url + "&tdname="+urlencode(cname);
url = url + "&ow_id="+oid;
postRequest(url,'modify_domainSub');
}
function addQuesDirectly()
{
//var oid=<php echo $_SESSION['owner_id'];?>;
var oid=1;
var url="ajax/addQues.php";
url = url + "?ow_id="+oid;
postRequest(url,'addQuesDirectly');
}
function ShowValMod(id,tname,oid)
{
document.getElementById("txttdname").value=tname;
document.getElementById("hidtdid").value=id;
document.getElementById("hidoid").value=oid;
}
</script>
<script type="text/javascript" language="javascript">
function gettid(mySelect)
{
myIndex=mySelect.selectedIndex;
myValue=mySelect.options[myIndex].value;
return myValue;
}
function gettname(mySelect)
{
myIndex=mySelect.selectedIndex;
myValue=mySelect.options[myIndex].text;
return myValue;
}
</script>
<script type="text/javascript" language="javascript">
function gettidval(){
var a=document.frm.myselect.selectedIndex;
myValue=document.frm.myselect.options[a].value;
return myValue;
}
</script>
<script type="text/javascript" language="javascript">
function ValidateSubmit()
{
if(document.getElementById("taques").value==''){
alert ("Enter a Question.");
document.getElementById("taques").focus();
return false;
}
else if(document.getElementById("txtop1").value=='' || document.getElementById("txtop2").value=="" || document.getElementById("txtop3").value=="" || document.getElementById("txtop4").value==""){
alert ("Enter all options.");
return false;
}
else if(document.getElementById("txtmarks").value==""){
alert("Enter marks.");
document.getElementById("txtmarks").focus();
return false;
}
else if (isNaN(document.getElementById("txtmarks").value)){
alert ("Enter a numeric value for marks.");
document.getElementById("txtmarks").focus();
return false;
}
myOption = -1;
for (i=document.frm.RG.length-1; i > -1; i--)
{
if (document.frm.RG[i].checked)
{
myOption = i; i = -1;
}
}
if (myOption == -1)
{
alert("You must select an Option.");
return false;
}
if(document.frm.myselect.options[document.frm.myselect.selectedIndex].value=='0'){
alert ("Select Defficulty Level");
return false;
}
var url="ajax/insert_ques.php";
url = url + "?tques="+doc("taques");
url = url + "&marks="+doc("txtmarks");
url = url + "&ans="+document.frm.RG[myOption].value;
url = url + "&dl="+document.frm.myselect.options[document.frm.myselect.selectedIndex].value;
url = url + "&op1="+doc("txtop1");
url = url + "&op2="+doc("txtop2");
url = url + "&op3="+doc("txtop3");
url = url + "&op4="+doc("txtop4");
url = url + "&tdid="+document.frm.td_select.options[document.frm.td_select.selectedIndex].value;
url = url + "&tid="+document.frm.tid_select.options[document.frm.tid_select.selectedIndex].value;
postRequest(url,'insert_ques');
}
function clearquesvalues()
{
document.getElementById("taques").value='';
document.getElementById("txtop1").value='';
document.getElementById("txtop2").value='';
document.getElementById("txtop3").value='';
document.getElementById("txtop4").value='';
document.getElementById("txtmarks").value="";
}
</script>
</head>
<body onload="listTestDomain('add');">
<div id="menu_wrap">
<div style="width:960px; margin: 0 auto; background:#e9e6e6; height: 10px;">
<!--div added to creat the top 10 px space-->
</div>
<div id="menu">
<ul>
<li><a href="adm_index.php">Admin Home</a></li>
<li><a href="profile.php?record=<?php echo $_SESSION['user_id'];?>">View Profile</a></li>
<li><a href="editpro.php?record=<?php echo $_SESSION['user_id'];?>">Edit Profile</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</div><!-- div menu closed-->
</div><!--div menu_wrap closed -->
<div id="wrapper">
<div id="content_wrap">
<div id="header">
<p>Welcome <?php echo $_SESSION['uname'];?></p>
</div><!-- div header closed-->
<!-- no need of the leftbar so not using it.-->
<div id="rightbar">
<!--
width of right bar = 940 - ((width of left bar) + 12 + 30)
if width of left bar = 0 the delete the following text <<< style="width: 704px;" >>>
from the rightbar div to get 100% rightbar
-->
<table style="text-align:center;">
<tr>
<td>
<input type="button" class="button blue medium" id="btnadd" name="btnadd" value="Add Content" onClick="ajax_call('showadd')"/>
</td>
<td>
<input type="button" class="button green medium" id="btnmod" name="btnmod" value="Modify Content" onClick="ajax_call('showmod')"/>
</td>
<td>
<input type="button" class="button blue medium2" value="Display Reports" onClick="ajax_call('showrep')"/>
</td>
</tr>
</table>
<table id="addcontent" style="text-align:center;">
<tr>
<td>
<input type="button" class="button blue medium" value="Add Category" onClick="ajax_call('show_addDomain')"/>
</td>
<td>
<input type="button" class="button blue medium" value="Add Test" onClick="addTest('*null*','*null*')"/>
</td>
<td>
<input type="button" class="button blue medium" value="Add Questions" onClick="addQuesDirectly()"/>
</td>
</tr>
</table>
<table id="modcontent" style="display:none;text-align:center;">
<tr>
<td>
<input type="button" class="button green medium" value="Edit/Delete Category" onClick="ajax_call('show_modDomain')"/>
</td>
<td>
<input type="button" class="button green medium" value="Edit/Delete Test" onClick="addTest('*null*','*null*')"/>
</td>
<td>
<input type="button" class="button green medium" value="Edit/Delete Question" onClick="addQuesDirectly()"/>
</td>
</tr>
</table>
<div id="contentval"><!-- this is the full content div to be updated on ajax call of the entire right container-->
<table>
<tr>
<td>
<div id="hide_list">
<div id="listTestDomain"></div>
</div><!-- this is to hide the list when needed-->
</td>
<td>
<div id="change"><!-- this is the div to be updated on ajax call of the right container-->
</div><!-- this is end of change div-->
</td>
</tr>
<tr>
<td> </td>
<td colspan="2">
<div id="result"><!-- this is the result div to get the result of whatever processing is done. -->
</div>
</td>
</tr>
</table>
</div><!-- div contentval closed-->
</div><!-- div rightbar closed-->
<div style="clear: both;"></div>
</div><!-- div content_wrap closed -->
</div><!-- div wrapper closed -->
</body>
</html>