-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetQuestions.jsp
More file actions
191 lines (184 loc) · 6.95 KB
/
Copy pathsetQuestions.jsp
File metadata and controls
191 lines (184 loc) · 6.95 KB
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
<!DOCTYPE Html>
<html>
<%
String assesment = (String)session.getAttribute("assesment");
String role = (String)session.getAttribute("role");
if (role == null ){
response.setStatus(response.SC_MOVED_TEMPORARILY);
response.setHeader("Location", "index.html");
}else if (assesment == null){
response.setStatus(response.SC_MOVED_TEMPORARILY);
response.setHeader("Location", "selectSubjectCode.html");
}
%>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Course</title>
<link rel="stylesheet" href="css/semantic.min.css"></link>
<style>
img{
margin-bottom:-10px;
margin-top:-10px;
}
body{
padding:20px;
}
</style>
</head>
<body>
<!-- nav bar ends-->
<div id="new">
<div class="ui form">
<div class="fields">
<div class="field">
<button class="ui blue button" id="head" onclick="addNewQues()">Add New Question</button>
</div>
<!--div class="field">
<input id="subjectCode" placeholder="Enter subject code"></input>
</div>
<div class="field">
<button class="ui green button" onclick="">set</button>
</div-->
</div>
</div>
<table class="ui celled table" id="tableQues">
</table>
<button class="ui green button" onclick="submit()">Update Questions</button>
</div>
<div id="old">
<table class="ui celled table" id="oldQues">
</table>
</div>
<script src="js/jquery-3.1.1.min.js"></script>
<!--jquery should be loaded before sematic and your custom javascript -->
<script src="js/semantic.min.js"></script>
<script>
var height = $("body").innerHeight();
var hgt = height*0.15;
$('.margin').height(hgt);
</script>
<script>
$(".form").submit(function(e){
e.preventDefault();
});
h=`<thead>
<tr>
<th>Question No</th>
<th>Course Outcome No</th>
<th>Marks</th>
</tr>
</thead>`
$( "#head" ).one( "click", function() {
$("#tableQues").append(h);
});
qCount = 0;
cooptionsarr = [];
var coFlag = false;
$("#oldQuesLabel").hide();
set();
function hideNew(a){
if(a){
$("#new").hide();
$("#old").show();
}else{
$("#new").show();
$("#old").hide();
}
}
function set(){
$.get("getQuesAndStud", {/*subjectCode:$("#subjectCode").val()*/} , function(result){
console.log(result);
if(result.message == "done"){
q = result.questions.questions;
//console.log(q);
s = "<thead><tr><th>Qno</th><th>CO</th><th>mark</th><tbody>";
for ( i in q){
s = s + "<tr><td>" + q[i].qno + "</td><td>" + q[i].co + "</td><td>" + q[i].mark + "</td></tr>";
}
s = s + "</tbody>";
//console.log(s);
$("#oldQuesLabel").show();
$("#oldQues").append(s);
hideNew(true);
}else{
hideNew(false);
}
});
$.get("getCoDetails", {/*subjectCode:$("#subjectCode").val()*/} , function(result){
console.log(result);
if (result.co.length > 0 ){
cooptionsarr = [];
for (i in result.co){
cooptionsarr.push(result.co[i].co);
}
coFlag = true;
} else {
alert("CO not received");
}
});
}
function getCoOptions(){
s = '';
for ( i in cooptionsarr){
s = s + '<option value="'+cooptionsarr[i]+'">'+cooptionsarr[i]+'</option>';
}
return s;
}
function addNewQues(){
if (!coFlag){
alert("Set Course id");
return;
}
s = `<tr>
<td><div class="ui input"><input placeholder="qNo" id="qno`+qCount+`" value="q`+(qCount+1)+`"></div></td>
<td>
<select id="qCo`+qCount+`" class="coListing">
`+getCoOptions()+`
</select>
</td>
<td><div class="ui input"><input type="text" placeholder="Maximum Marks" id="qMark`+qCount+`"></div></td>
</tr>`
qCount++;
$("#tableQues").append(s);
}
function submit(){
if (!coFlag){
alert("Set Course id");
return;
}
//alert("s");
arr = [];
console.log("clicked");
for (i = 0; i< qCount; i++){
obj = {};
obj.qno = $("#qno"+i).val();
obj.co = $("#qCo"+i).val();//todo:change
obj.mark = Number($("#qMark"+i).val());
arr.push(obj);
}
subjectCode = $("#subjectCode").val();
/*assesment = "dummyass";
section = "dummysec";
department = "dummyDept"
year = "dummyYr";
*/
data = {};
data.subjectCode = subjectCode;
/*data.assesment = assesment;
data.section = section;
data.department = department;
data.year = year;*/
data.questions = arr;
var jsonData = JSON.stringify(data);
console.log(jsonData);
$.get("/OAS/setQuestions",{data:jsonData},function(result){
console.log("result error:"+result.error);
alert(result.message);
});
}
//TODO: Testing
</script>
</body>
</html>