-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
357 lines (307 loc) · 15.8 KB
/
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
<?php
define('STUDENT_IMAGE_URL', 'http://192.168.1.43/other/draganddrop/images');
$question_no = 1;
$no_of_questions = 1;
$PTActivity = array();
$AllPTActivity = array();
$word_hides_list = Array('5'=>'Pixel','6'=>'responsive','7'=>'feature','8'=>'level');
$question_master = Array('QuestionMaster'=>Array('id' => '117','title' => 'Cloze 1','intro' => 'Intro'));
$question = Array('Question' => Array('cloze_text' => 'Pixel perfect mobile responsive design and feature reach recruitment website technology us to deliver a bespoke recruitment website design on a structure that is highly flexible. Our own advanced and feature rich CMS system means that we build the best websites and then constantly update it. Delivering exceptional results, our technology will take your website to the next level.','id' => '1378','type_id' => '5','display' => '','marks' => 1,'hint' => ''),'QDifficultyLevel' => Array('title'=>'Easy'));
?>
<!DOCTYPE html>
<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">
<title>Page Title</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/flatly/bootstrap.min.css"/>
<link rel="stylesheet" href="css/jquery-ui.css">
<script type="text/javascript" src="js/jquery-1.12.4.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript" src="js/touche.min.js"></script>
<style type="text/css">
/* draggable targets */
#divShuffle { margin-bottom: 5px;}
#clozeText { line-height:30px; }
#itemList.droppable{
padding: 10px;
width: 100%;
}
#itemList span.draggable{
margin-right: 3px;
padding: 5px;
cursor: move;
}
#clozeText span.droppable{
margin-right: 3px;
padding: 0 20px;
}
#clozeText span.draggable{
background: none;
border: none;
margin-right: 3px;
cursor: move;
}
body {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera */
}
</style>
<script type="text/javascript">
var question_no = '<?php echo $question_no; ?>';
var answer = '<?php echo @$PTActivity["answer"]; ?>';
answer = answer.trim();
$(document).ready(function() {
draganddrop();
//Record Activity
if(answer != '')
{
$("#linkSkip").hide();
$("#linkNext").show();
}else{
$("#linkSkip").show();
$("#linkNext").hide();
}
$('body').on('change', 'input.chkFlag', function() {
//record_activity(question_no);
if($(this).is(':checked')){
$(this).parent('label').addClass('active');
}else{
$(this).parent('label').removeClass('active');
}
});
$('body').on('click', 'a.action', function() {
var action = $(this).attr('data-action');
$("#txtAction").val(action);
//record_activity(question_no);
});
update_answerList();
update_itemList();
update_droppable();
//record_activity(question_no);
});
function draganddrop()
{
$( ".draggable" ).draggable({
revert: "invalid"
});
$( ".droppable" ).droppable({
accept: ".draggable",
classes: {
"ui-droppable-active": "ui-state-active",
"ui-droppable-hover": "ui-state-hover"
},
/*over: function(event, ui) {
$(this).css('height','30px');
},
out: function(event, ui) {
$(this).css('height','30px');
},*/
drop: function( event, ui ) {
/*if($( this ).attr('id') == 'itemList'){
$( this ).append(ui.draggable.css('left','0px').css('top','0px'));
}else{
$(this).html(ui.draggable.css('left','0px').css('top','0px'));
}*/
if($( this ).attr('id') == 'itemList'){
$( this ).append(ui.draggable.css('left','').css('top',''));
}else{
$(this).html(ui.draggable.css('left','').css('top',''));
}
update_answerList();
update_itemList();
update_droppable();
draganddrop();
//window.location.reload();
}
});
}
function validateQuestion()
{
var txtAnswerObj = $("#txtAnswer");
if (txtAnswerObj.val().trim().length == 0) {
$(txtAnswerObj).val("");
$.growl.error({ message: "Please change the order as per blanks on the coze text" });
return false;
}
return true;
}
function update_itemList()
{
var obj = $("#divShuffle div#itemList span.draggable");
var jsonWordHides = [];
$.each(obj, function(i) {
jsonWordHides.push($(this).text());
});
$("#txtItem").val(jsonWordHides);
}
function update_answerList()
{
var obj2 = $(".main_left_box div#clozeText span.draggable");
var jsonAnswerList = [];
$.each(obj2, function(i) {
if($(this).text().trim().length > 0)
{
jsonAnswerList.push($(this).text());
}
});
$("#txtAnswer").val(jsonAnswerList);
if(jsonAnswerList.length > 0)
{
$("#linkSkip").hide();
$("#linkNext").show();
}else{
$("#linkSkip").show();
$("#linkNext").hide();
}
}
function update_droppable()
{
var obj2 = $(".main_left_box div#clozeText span.droppable");
$.each(obj2, function(i) {
if($(this).find("span.draggable").length >= 1){
$(this).droppable( "option", "disabled", true );
$( this ).addClass( "ui-state-highlight" );
}else{
$(this).droppable( "option", "disabled", false );
$( this ).removeClass( "ui-state-highlight" );
}
$(this).removeClass('ui-droppable-active');
$(this).removeClass('ui-state-active');
});
$("#txtClozeText").val($("#clozeText").html());
}
</script>
</head>
<body>
<div class="container">
<div class="row">
<input type="hidden" id="txtQuestionNo" name="data[question_no]" value="<?php echo $question_no; ?>">
<input type="hidden" id="txtQuestionMasterId" name="data[question_master_id]" value="<?php echo $question_master['QuestionMaster']['id']; ?>">
<input type="hidden" id="txtQuestionId" name="data[question_id]" value="<?php echo $question['Question']['id']; ?>">
<div class="background-color page-title">
<h1 class="heading-title">
<?php echo $question_master['QuestionMaster']['title']; ?>
<?php if(isset($question_master['QuestionMaster']['intro']) && !empty($question_master['QuestionMaster']['intro'])){ ?>
<span><?php echo nl2br($question_master['QuestionMaster']['intro']); ?></span>
<?php } ?>
</h1>
</div>
<?php if(isset($question['Question']['cloze_text']) && !empty($question['Question']['cloze_text'])){ ?>
<div class="main_left_box">
<?php
$dbClozeText = nl2br(trim($question['Question']['cloze_text']));
$wordHidesList = $word_hides_list;
$wordHidesArr = array_values($wordHidesList);
$itemArr = array();
$itemArr = $wordHidesArr;
if(isset($PTActivity["item"]))
{
if(strlen(trim($PTActivity["item"])))
{
$itemArr = array();
$itemArr = explode(',', $PTActivity["item"]);
}
}
$answerArr = array();
if(isset($PTActivity["answer"]))
{
if(strlen(trim($PTActivity["answer"])))
{
$answerArr = explode(',', $PTActivity["answer"]);
}
}
if( !isset($PTActivity["cloze_text"]) || strlen(trim($PTActivity["cloze_text"])) == 0 )
{
$cloze_text = $dbClozeText;
foreach ($itemArr as $key => $word)
{
if(in_array( $word, $answerArr ) == false)
{
$cloze_text = preg_replace("/\b$word\b/u", "<span class='droppable ui-widget-header'></span>", $cloze_text, 1);
}
}
}
else
{
$cloze_text = $PTActivity["cloze_text"];
}
$cloze_text = trim($cloze_text);
?>
<div id="clozeText" class="panel-body">
<?php echo $cloze_text; ?>
</div>
</div>
<?php } ?>
<div class="main_left_box">
<div class="Timeduration"><?php echo $question_no; ?></div>
<div class="panel-body">
<div class="Questionname">
<h3>
<span class="Markspq <?php echo $question['QDifficultyLevel']['title']; ?>"><em>Difficulty</em><?php echo $question['QDifficultyLevel']['title']; ?></span>
<span class="Markspq"><em>Marks</em><?php echo ($question['Question']['marks'] * count($wordHidesArr)); ?></span>
</h3>
<?php
shuffle($wordHidesArr);
//print_r($wordHidesArr);
$itemHtml = "<div id='itemList' class='droppable ui-widget-header'>";
$itemArr = array();
foreach ($wordHidesArr as $key => $word)
{
if(in_array( $word, $answerArr ) == false)
{
$itemHtml .= "<span class='draggable ui-widget-content'>$word</span>";
array_push($itemArr, $word);
}
else
{
array_push($answerArr, $word);
}
}
$itemHtml .= "</div>";
$itemHtml = trim($itemHtml);
if( !isset($PTActivity["item"]) || strlen(trim($PTActivity["item"])) == 0 )
{
$itemString = implode(',', $itemArr);
}
else
{
$itemString = trim($PTActivity["item"]);
}
if( !isset($PTActivity["answer"]) || strlen(trim($PTActivity["answer"])) == 0 )
{
$answerString = implode(',', $answerArr);
}
else
{
$answerString = trim($PTActivity["answer"]);
}
?>
<div class="Anset clozeWord">
<div id="divShuffle">
<?php echo $itemHtml; ?>
</div>
</div>
<div class="Hint">
<p>Note: Drag the words into the boxes to complete the sentences. If you want to change already placed words, simply drag the word to another box.</p>
</div>
<input type="text" name="data[cloze_text]" id="txtClozeText" value="<?php echo trim(@$PTActivity['cloze_text']); ?>">
<input type="text" name="data[item]" id="txtItem" value="<?php echo trim($itemString); ?>">
<input type="text" name="data[answer]" id="txtAnswer" value="<?php echo trim($answerString); ?>">
<input type="hidden" name="data[action]" id="txtAction" value="<?php echo @$PTActivity['action']; ?>">
</div>
</div>
</div>
</div>
</div>
</body>
</html>