807 lines
32 KiB
PHP
807 lines
32 KiB
PHP
<style type="text/css">
|
|
.invisible {
|
|
display: none;
|
|
}
|
|
.exmqus_btnblock{
|
|
margin-inline: auto;
|
|
}
|
|
</style>
|
|
<main class="common_margin" id="main">
|
|
<div class=" main-inner-content main-wrap">
|
|
<div class="main-inner-content">
|
|
<!------test/exam page start------>
|
|
<div class="exm_mainblock">
|
|
<div class="exmqus_inner">
|
|
<div class="exmdiv_sec">
|
|
<div class="exm_block">
|
|
<div class="exmqus_header">
|
|
<div class="exmqusheader_l">
|
|
<div id="exam-name" class="exmqus_headerheading"></div>
|
|
</div>
|
|
<div class="exmqusheader_r">
|
|
|
|
<div id="pagination-num" class="exmqus_headerqus"></div>
|
|
<div class="exmqus_headertym"></div>
|
|
<div id="marks_per_question" style="margin-left:30px;font-size: 12px;font-weight: 600;"></div>
|
|
</div>
|
|
</div>
|
|
<div class="exm_scrollsec">
|
|
<div class="exm_qusblock">
|
|
<div id="ques-num" class="exmqus"></div>
|
|
<div id="ques-body" class="exmqus_detail"></div>
|
|
</div>
|
|
<div class="img-block">
|
|
|
|
</div>
|
|
<div class="exm_ansblock">
|
|
<div class="exm_anshead">Please Answer Your Question </div>
|
|
<div class="exmradiobtn">
|
|
<input type="radio" id="r1" value="A" name="ans" class="radio-ans" aria-label="Single radio One">
|
|
<label id="a1"><span>A</span></label>
|
|
</div>
|
|
<div class="exmradiobtn">
|
|
<input type="radio" id="r2" value="B" name="ans" class="radio-ans" aria-label="Single radio One">
|
|
<label id="a2"><span>B</span></label>
|
|
</div>
|
|
<div class="exmradiobtn">
|
|
<input type="radio" id="r3" value="C" name="ans" class="radio-ans" aria-label="Single radio One">
|
|
<label id="a3"><span>C</span></label>
|
|
</div>
|
|
<div class="exmradiobtn">
|
|
<input type="radio" id="r4" value="D" name="ans" class="radio-ans" aria-label="Single radio One">
|
|
<label id="a4"><span>D</span></label>
|
|
</div>
|
|
<div class="exmradiobtn">
|
|
<input type="radio" id="tf1" value="1" name="anss" class="radio-ans" aria-label="Single radio One">
|
|
<label id="t1"><span>True</span></label>
|
|
</div>
|
|
<div class="exmradiobtn">
|
|
<input type="radio" id="tf2" value="0" name="anss" class="radio-ans" aria-label="Single radio One">
|
|
<label id="t2"><span>False</span></label>
|
|
</div>
|
|
<div class="txtarea">
|
|
<textarea id="sa" name="sa" class="form-control" rows="4"></textarea>
|
|
</div>
|
|
<div class="txtarea">
|
|
<textarea id="la" name="la" class="form-control" rows="6"></textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="exmqus_btnsec">
|
|
<div class="exmqus_btnblock">
|
|
<button id="btn-prev" type="button" class="exm_prebtn" >Previous question</button>
|
|
|
|
|
|
<button id="btn-next" type="button" class="exm_nxtbtn">Next question</button>
|
|
|
|
<button id="btn-finish" type="button" class="exm_prevbtns finishexambtn">Submit</button>
|
|
</div>
|
|
<!-- <div class="exmqus_skip"><i class="fa fa-angle-right" aria-hidden="true"></i><i class="fa fa-angle-right" aria-hidden="true"></i>Skip for now</div> -->
|
|
|
|
</div>
|
|
</div>
|
|
<div class="exm_pagination">
|
|
<div class="exm_paginationsec">
|
|
<div id="blocks" class="exm_pagination_top">
|
|
|
|
</div>
|
|
<div id="pagination-btns" class="exm_pagination_btm">
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<!------test/exam page end------>
|
|
|
|
<!-- model for click -->
|
|
<div class="viewDoc delete-modal-wrap" >
|
|
<div class="modal fade" id="submitModal" role="dialog">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
<div class="delete-modal">
|
|
<i class="fas fa-exclamation-circle"></i>
|
|
<input type="hidden" id="sdid" />
|
|
<h4 >Are you sure?</h4>
|
|
<p>Are you sure you want to submit the record?</p>
|
|
<div class="delete-modal-btn">
|
|
<button type="button" class="subject_addbtn subject_addbtn_green btn_submit_answer" >Submit</button>
|
|
<button type="button" class="subject_addbtn subject_addbtn_cancel" data-dismiss="modal">Cancel</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal fade" id="timeUpModal" role="dialog">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<button type="button" class="close btn_submit_answer" data-dismiss="modal">×</button>
|
|
<div class="delete-modal">
|
|
<i class="fas fa-exclamation-circle"></i>
|
|
<input type="hidden" id="sdid" />
|
|
<h4>Time up !!!</h4>
|
|
<p>Thank you</p>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<!-- Live exam logics -->
|
|
<script type="text/javascript">
|
|
|
|
function displayFormat(qtype)
|
|
{
|
|
|
|
if(qtype=='2')
|
|
{
|
|
$('#a1').css('display','none');
|
|
$('#a2').css('display','none');
|
|
$('#a3').css('display','none');
|
|
$('#a4').css('display','none');
|
|
$('#t1').css('display','block');
|
|
$('#t2').css('display','block');
|
|
$('#sa').css('display','none');
|
|
$('#la').css('display','none');
|
|
}else if(qtype=='1')
|
|
{
|
|
$('#a1').css('display','block');
|
|
$('#a2').css('display','block');
|
|
$('#a3').css('display','block');
|
|
$('#a4').css('display','block');
|
|
$('#t1').css('display','none');
|
|
$('#t2').css('display','none');
|
|
$('#sa').css('display','none');
|
|
$('#la').css('display','none');
|
|
}else if(qtype=='3')
|
|
{
|
|
$('#a1').css('display','none');
|
|
$('#a2').css('display','none');
|
|
$('#a3').css('display','none');
|
|
$('#a4').css('display','none');
|
|
$('#t1').css('display','none');
|
|
$('#t2').css('display','none');
|
|
$('#sa').css('display','block');
|
|
$('#la').css('display','none');
|
|
}else if(qtype=='4')
|
|
{
|
|
$('#a1').css('display','none');
|
|
$('#a2').css('display','none');
|
|
$('#a3').css('display','none');
|
|
$('#a4').css('display','none');
|
|
$('#t1').css('display','none');
|
|
$('#t2').css('display','none');
|
|
$('#sa').css('display','none');
|
|
$('#la').css('display','block');
|
|
}
|
|
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
|
|
var my_id = '<?php echo $student_id; ?>';
|
|
var arr_ques='';
|
|
var test_id = '<?= $exam_question_Id; ?>';
|
|
var s_date,e_date,msec ;
|
|
$.post(
|
|
"<?= base_url(); ?>student/getAllQues",
|
|
{ test_id: test_id },
|
|
function(data)
|
|
{
|
|
arr_ques = JSON.parse(data);
|
|
arr_ans = [];
|
|
// console.log(arr_ques);
|
|
|
|
for(var i=0;i<arr_ques.length;i++)
|
|
{
|
|
arr_ans['a_'+i] = '';
|
|
}
|
|
|
|
|
|
//setting initial questions
|
|
$('#exam-name').html( arr_ques[0].subject_name +' - '+ arr_ques[0].e_name);
|
|
$('#marks_per_question').html(arr_ques[0].marks +' Mark');
|
|
$('#pagination-num').html('1/'+arr_ques.length);
|
|
$('#ques-num').html('1: ');
|
|
$('#ques-body').html(arr_ques[0].question_name);
|
|
|
|
|
|
$('#a1').html(arr_ques[0].option_a);
|
|
$('#a2').html(arr_ques[0].option_b);
|
|
$('#a3').html(arr_ques[0].option_c);
|
|
$('#a4').html(arr_ques[0].option_d);
|
|
if (arr_ques[0].image != "") {
|
|
var img = '<img src="<?php echo base_url() ?>'+ arr_ques[0].image +'" width="120" height="120" class="my-3">';
|
|
$('.img-block').html(img);
|
|
}
|
|
displayFormat(arr_ques[0].question_type_id);
|
|
|
|
|
|
|
|
//setting initial paginations - blocks
|
|
var counter = arr_ques.length;
|
|
var i=0;
|
|
var r1=1;
|
|
var r2=10;
|
|
while(counter>0)
|
|
{
|
|
i++;
|
|
if(counter<=10)
|
|
{
|
|
if(i==1)
|
|
{
|
|
$('#blocks').append('<div id="block_'+i+'" class="exm_pagination_block exm_pagination_active">'+r1+'-'+arr_ques.length+'</div>');
|
|
}
|
|
else
|
|
{
|
|
$('#blocks').append('<div id="block_'+i+'" class="exm_pagination_block">'+r1+'-'+arr_ques.length+'</div>');
|
|
}
|
|
counter-=10;
|
|
}
|
|
else
|
|
{
|
|
if(i==1)
|
|
{
|
|
$('#blocks').append('<div id="block_'+i+'" class="exm_pagination_block exm_pagination_active">'+r1+'-'+r2+'</div>');
|
|
}
|
|
else
|
|
{
|
|
$('#blocks').append('<div id="block_'+i+'" class="exm_pagination_block">'+r1+'-'+r2+'</div>');
|
|
}
|
|
counter-=10;
|
|
r1+=10;
|
|
r2+=10;
|
|
}
|
|
}
|
|
|
|
//setting initial paginations - pagination btns
|
|
var r1=1;
|
|
var r2=10;
|
|
if(arr_ques.length<=10)
|
|
{
|
|
r2=arr_ques.length;
|
|
}
|
|
for(i=1;i<=arr_ques.length;i++)
|
|
{
|
|
if(i==1)
|
|
{
|
|
$('#pagination-btns').append('<div id="page_'+i+'" class="exm_pagination_no exm_pagination_noactive">'+i+'</div>');
|
|
}
|
|
else
|
|
{
|
|
if(i>=r1 && i<=r2)
|
|
{
|
|
$('#pagination-btns').append('<div id="page_'+i+'" class="exm_pagination_no">'+i+'</div>');
|
|
}
|
|
else
|
|
{
|
|
$('#pagination-btns').append('<div id="page_'+i+'" class="exm_pagination_no invisible">'+i+'</div>');
|
|
}
|
|
}
|
|
}
|
|
$('#btn-finish').css('display','none');
|
|
}
|
|
);
|
|
|
|
|
|
|
|
// Previous button logic
|
|
$('#btn-prev').click(function(){
|
|
if($('#r1').is(':checked') || $('#r2').is(':checked') || $('#r3').is(':checked') || $('#r4').is(':checked') || $('#tf1').is(':checked') || $('#tf2').is(':checked') || $('#sa').val() !='' || $('#la').val() !='')
|
|
{
|
|
var current_ques_num = parseInt($('.exm_pagination_noactive').html());
|
|
var next_ques_num = parseInt(current_ques_num) - parseInt(1);
|
|
|
|
if(arr_ques[next_ques_num].question_type_id=='1')
|
|
{
|
|
var ans = $('input[name="ans"]:checked').val();
|
|
}else if(arr_ques[next_ques_num].question_type_id=='2'){
|
|
var ans = $('input[name="anss"]:checked').val();
|
|
}else if(arr_ques[next_ques_num].question_type_id=='3') {
|
|
var ans = $('#sa').val();
|
|
}else if(arr_ques[next_ques_num].question_type_id=='4') {
|
|
var ans = $('#la').val();
|
|
}
|
|
|
|
// store answer in answer array
|
|
|
|
if (next_ques_num <= 0) {
|
|
next_ques_num = arr_ques.length;
|
|
}
|
|
|
|
arr_ans[current_ques_num-1] = ans;
|
|
|
|
$('.exm_pagination_no').removeClass('exm_pagination_noactive');
|
|
$('#page_'+next_ques_num).addClass('exm_pagination_noactive');
|
|
|
|
//Setting up question & options
|
|
$('#exam-name').html(arr_ques[next_ques_num-1].e_name);
|
|
$('#marks_per_question').html(arr_ques[next_ques_num-1].marks +' Mark');
|
|
$('#pagination-num').html(next_ques_num+'/'+arr_ques.length);
|
|
$('#ques-num').html(next_ques_num+': ');
|
|
$('#ques-body').html(arr_ques[next_ques_num-1].question_name);
|
|
$('#a1').html(arr_ques[next_ques_num-1].option_a);
|
|
$('#a2').html(arr_ques[next_ques_num-1].option_b);
|
|
$('#a3').html(arr_ques[next_ques_num-1].option_c);
|
|
$('#a4').html(arr_ques[next_ques_num-1].option_d);
|
|
|
|
if (arr_ques[next_ques_num-1].image != "") {
|
|
$('.img-block').show();
|
|
var img = '<img src="<?php echo base_url() ?>'+ arr_ques[next_ques_num-1].image +'" width="120" height="120" class="my-3">';
|
|
$('.img-block').html(img);
|
|
}else{
|
|
$('.img-block').hide();
|
|
}
|
|
|
|
displayFormat(arr_ques[next_ques_num-1].question_type_id);
|
|
|
|
//Check for checked radios
|
|
if(typeof arr_ans[next_ques_num-1]!=='undefined')
|
|
{
|
|
if(arr_ans[next_ques_num-1]=='A')
|
|
{
|
|
$('#r1').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='B')
|
|
{
|
|
$('#r2').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='C')
|
|
{
|
|
$('#r3').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='D')
|
|
{
|
|
$('#r4').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='1')
|
|
{
|
|
$('#tf1').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='0')
|
|
{
|
|
$('#tf2').prop('checked',true);
|
|
}
|
|
else if(arr_ques[next_ques_num-1].question_type_id=='3')
|
|
{
|
|
$('#sa').val(arr_ans[next_ques_num-1]);
|
|
}
|
|
else{
|
|
$('#la').val(arr_ans[next_ques_num-1]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$('#r1').prop('checked',false);
|
|
$('#r2').prop('checked',false);
|
|
$('#r3').prop('checked',false);
|
|
$('#r4').prop('checked',false);
|
|
$('#tf1').prop('checked',false);
|
|
$('#tf2').prop('checked',false);
|
|
$('#sa').val('');
|
|
$('#la').val('');
|
|
}
|
|
// Check for blocks
|
|
var num_of_blocks = $('.exm_pagination_block').length;
|
|
for(var i=1;i<=num_of_blocks;i++)
|
|
{
|
|
var block_r2 = i*10;
|
|
var block_r1 = block_r2-9;
|
|
var active_block_number = 0;
|
|
if(next_ques_num<=block_r2 && next_ques_num>=block_r1)
|
|
{
|
|
active_block_number = i;
|
|
$('.exm_pagination_block').removeClass('exm_pagination_active');
|
|
$('#block_'+active_block_number).addClass('exm_pagination_active');
|
|
//check pagination btns
|
|
$('.exm_pagination_no').addClass('invisible');
|
|
for(var x=block_r1;x<=block_r2;x++)
|
|
{
|
|
$('#page_'+x).removeClass('invisible');
|
|
}
|
|
}
|
|
}
|
|
// Last Question logic
|
|
if(next_ques_num==arr_ques.length)
|
|
{
|
|
$('#btn-next').css('display','none');
|
|
$('#btn-finish').css('display','inline-block');
|
|
}
|
|
else
|
|
{
|
|
$('#btn-next').css('display','inline-block');
|
|
$('#btn-finish').css('display','none');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
alert('Please Answer your Question');
|
|
}
|
|
});
|
|
|
|
|
|
// Next button logic
|
|
$('#btn-next').click(function(){
|
|
if($('#r1').is(':checked') || $('#r2').is(':checked') || $('#r3').is(':checked') || $('#r4').is(':checked') || $('#tf1').is(':checked') || $('#tf2').is(':checked') || $('#sa').val() !='' || $('#la').val() !='')
|
|
{
|
|
var current_ques_num = parseInt($('.exm_pagination_noactive').html());
|
|
var next_ques_num = current_ques_num+1;
|
|
// store answer in answer array
|
|
|
|
if(arr_ques[next_ques_num-2].question_type_id=='1')
|
|
{
|
|
var ans = $('input[name="ans"]:checked').val();
|
|
}else if(arr_ques[next_ques_num-2].question_type_id=='2'){
|
|
var ans = $('input[name="anss"]:checked').val();
|
|
}else if(arr_ques[next_ques_num-2].question_type_id=='3') {
|
|
var ans = $('#sa').val();
|
|
}else if(arr_ques[next_ques_num-2].question_type_id=='4') {
|
|
var ans = $('#la').val();
|
|
}
|
|
arr_ans[current_ques_num-1] = ans;
|
|
|
|
$('.exm_pagination_no').removeClass('exm_pagination_noactive');
|
|
$('#page_'+next_ques_num).addClass('exm_pagination_noactive');
|
|
|
|
//Setting up quesiion & options
|
|
$('#exam-name').html(arr_ques[next_ques_num-1].e_name);
|
|
$('#marks_per_question').html(arr_ques[next_ques_num-1].marks +' Mark');
|
|
$('#pagination-num').html(next_ques_num+'/'+arr_ques.length);
|
|
$('#ques-num').html(next_ques_num+': ');
|
|
$('#ques-body').html(arr_ques[next_ques_num-1].question_name);
|
|
$('#a1').html(arr_ques[next_ques_num-1].option_a);
|
|
$('#a2').html(arr_ques[next_ques_num-1].option_b);
|
|
$('#a3').html(arr_ques[next_ques_num-1].option_c);
|
|
$('#a4').html(arr_ques[next_ques_num-1].option_d);
|
|
|
|
if (arr_ques[next_ques_num-1].image != "") {
|
|
$('.img-block').show();
|
|
var img = '<img src="<?php echo base_url() ?>'+ arr_ques[next_ques_num-1].image +'" width="120" height="120" class="my-3">';
|
|
$('.img-block').html(img);
|
|
}else{
|
|
$('.img-block').hide();
|
|
}
|
|
|
|
displayFormat(arr_ques[next_ques_num-1].question_type_id);
|
|
|
|
//Check for checked radios
|
|
if(typeof arr_ans[next_ques_num-1]!=='undefined')
|
|
{
|
|
if(arr_ans[next_ques_num-1]=='A')
|
|
{
|
|
$('#r1').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='B')
|
|
{
|
|
$('#r2').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='C')
|
|
{
|
|
$('#r3').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='D')
|
|
{
|
|
$('#r4').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='1')
|
|
{
|
|
$('#tf1').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='0')
|
|
{
|
|
$('#tf2').prop('checked',true);
|
|
}
|
|
else if(arr_ques[next_ques_num-1].question_type_id == '3')
|
|
{
|
|
$('#sa').val(arr_ans[next_ques_num-1]);
|
|
}
|
|
else{
|
|
$('#la').val(arr_ans[next_ques_num-1]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$('#r1').prop('checked',false);
|
|
$('#r2').prop('checked',false);
|
|
$('#r3').prop('checked',false);
|
|
$('#r4').prop('checked',false);
|
|
$('#tf1').prop('checked',false);
|
|
$('#tf2').prop('checked',false);
|
|
$('#sa').val('');
|
|
$('#la').val('');
|
|
}
|
|
// Check for blocks
|
|
var num_of_blocks = $('.exm_pagination_block').length;
|
|
for(var i=1;i<=num_of_blocks;i++)
|
|
{
|
|
var block_r2 = i*10;
|
|
var block_r1 = block_r2-9;
|
|
var active_block_number = 0;
|
|
if(next_ques_num<=block_r2 && next_ques_num>=block_r1)
|
|
{
|
|
active_block_number = i;
|
|
$('.exm_pagination_block').removeClass('exm_pagination_active');
|
|
$('#block_'+active_block_number).addClass('exm_pagination_active');
|
|
//check pagination btns
|
|
$('.exm_pagination_no').addClass('invisible');
|
|
for(var x=block_r1;x<=block_r2;x++)
|
|
{
|
|
$('#page_'+x).removeClass('invisible');
|
|
}
|
|
}
|
|
}
|
|
// Last Question logic
|
|
if(next_ques_num==arr_ques.length)
|
|
{
|
|
$('#btn-next').css('display','none');
|
|
$('#btn-finish').css('display','inline-block');
|
|
}
|
|
else
|
|
{
|
|
$('#btn-next').css('display','inline-block');
|
|
$('#btn-finish').css('display','none');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
alert('Please select an Answer');
|
|
}
|
|
});
|
|
|
|
|
|
// block change logic
|
|
$(document).on('click', '.exm_pagination_block', function(){
|
|
var block_id = $(this).attr('id');
|
|
$('.exm_pagination_block').removeClass('exm_pagination_active');
|
|
$('#'+block_id).addClass('exm_pagination_active');
|
|
var block_num = block_id.substring(block_id.indexOf('_') + 1);
|
|
var block_r2 = block_num*10;
|
|
var block_r1 = block_r2-9;
|
|
$('.exm_pagination_no').addClass('invisible');
|
|
for(var i=1;i<=arr_ques.length;i++)
|
|
{
|
|
if(i>=block_r1 && i<=block_r2)
|
|
{
|
|
$('#page_'+i).removeClass('invisible');
|
|
}
|
|
}
|
|
});
|
|
|
|
// pagination btns click logic
|
|
$(document).on('click', '.exm_pagination_no', function(){
|
|
var current_ques_num = parseInt($('.exm_pagination_noactive').html());
|
|
|
|
// arr_ans[current_ques_num-1] = ans;
|
|
if(arr_ques[current_ques_num-1].question_type_id=='1')
|
|
{
|
|
var ans = $('input[name="ans"]:checked').val();
|
|
}else if(arr_ques[current_ques_num-1].question_type_id=='2'){
|
|
var ans = $('input[name="anss"]:checked').val();
|
|
}else if(arr_ques[current_ques_num-1].question_type_id=='3') {
|
|
var ans = $('#sa').val();
|
|
}else if(arr_ques[current_ques_num-1].question_type_id=='4') {
|
|
var ans = $('#la').val();
|
|
}
|
|
arr_ans[current_ques_num-1] = ans;
|
|
|
|
|
|
var pagination_id = $(this).attr('id');
|
|
$('.exm_pagination_no').removeClass('exm_pagination_noactive');
|
|
$('#'+pagination_id).addClass('exm_pagination_noactive');
|
|
var ques_num = $('#'+pagination_id).html();
|
|
ques_num = parseInt(ques_num)-1;
|
|
$('#exam-name').html(arr_ques[ques_num].e_name);
|
|
$('#marks_per_question').html(arr_ques[ques_num].marks +' Mark');
|
|
$('#pagination-num').html((ques_num+1)+'/'+arr_ques.length);
|
|
$('#ques-num').html((ques_num+1)+': ');
|
|
$('#ques-body').html(arr_ques[ques_num].question_name);
|
|
$('#a1').html(arr_ques[ques_num].option_a);
|
|
$('#a2').html(arr_ques[ques_num].option_b);
|
|
$('#a3').html(arr_ques[ques_num].option_c);
|
|
$('#a4').html(arr_ques[ques_num].option_d);
|
|
|
|
if (arr_ques[ques_num].image != "") {
|
|
$('.img-block').show();
|
|
var img = '<img src="<?php echo base_url() ?>'+ arr_ques[ques_num].image +'" width="120" height="120" class="my-3">';
|
|
$('.img-block').html(img);
|
|
}else{
|
|
$('.img-block').hide();
|
|
}
|
|
|
|
|
|
displayFormat(arr_ques[ques_num].question_type_id);
|
|
|
|
//Check for checked radios
|
|
var next_ques_num = parseInt($('.exm_pagination_noactive').html());
|
|
|
|
if(typeof arr_ans[next_ques_num-1]!=='undefined')
|
|
{
|
|
if(arr_ans[next_ques_num-1]=='A')
|
|
{
|
|
$('#r1').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='B')
|
|
{
|
|
$('#r2').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='C')
|
|
{
|
|
$('#r3').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='D')
|
|
{
|
|
$('#r4').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='1')
|
|
{
|
|
$('#tf1').prop('checked',true);
|
|
}
|
|
else if(arr_ans[next_ques_num-1]=='0')
|
|
{
|
|
$('#tf2').prop('checked',true);
|
|
}
|
|
else if(arr_ques[next_ques_num-1].question_type_id == '3')
|
|
{
|
|
$('#sa').val(arr_ans[next_ques_num-1]);
|
|
}
|
|
else{
|
|
$('#la').val(arr_ans[next_ques_num-1]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$('#r1').prop('checked',false);
|
|
$('#r2').prop('checked',false);
|
|
$('#r3').prop('checked',false);
|
|
$('#r4').prop('checked',false);
|
|
$('#tf1').prop('checked',false);
|
|
$('#tf2').prop('checked',false);
|
|
$('#sa').val('');
|
|
$('#la').val('');
|
|
}
|
|
// Last Question logic
|
|
if(next_ques_num==arr_ques.length)
|
|
{
|
|
$('#btn-next').css('display','none');
|
|
$('#btn-finish').css('display','inline-block');
|
|
}
|
|
else
|
|
{
|
|
$('#btn-next').css('display','inline-block');
|
|
$('#btn-finish').css('display','none');
|
|
}
|
|
});
|
|
|
|
|
|
|
|
// Ask user before submit
|
|
|
|
$(document).on('click', '#btn-finish', function(){
|
|
|
|
$('#submitModal').modal({
|
|
backdrop: 'static',
|
|
keyboard: false
|
|
});
|
|
|
|
});
|
|
|
|
// finish exam and store answer
|
|
$(document).on('click', '.btn_submit_answer', function(){
|
|
|
|
var current_ques_num = parseInt($('.exm_pagination_noactive').html());
|
|
var next_ques_num = current_ques_num+1;
|
|
// store answer in answer array
|
|
|
|
if(arr_ques[next_ques_num-2].question_type_id=='1')
|
|
{
|
|
var ans = $('input[name="ans"]:checked').val();
|
|
}else if(arr_ques[next_ques_num-2].question_type_id=='2'){
|
|
var ans = $('input[name="anss"]:checked').val();
|
|
}else if(arr_ques[next_ques_num-2].question_type_id=='3') {
|
|
var ans = $('#sa').val();
|
|
}else if(arr_ques[next_ques_num-2].question_type_id=='4') {
|
|
var ans = $('#la').val();
|
|
}
|
|
|
|
arr_ans[current_ques_num-1] = ans;
|
|
|
|
var arr_to_send = {};
|
|
for(var i=0;i<arr_ques.length;i++)
|
|
{
|
|
arr_to_send[i] = {
|
|
'student_id':my_id,
|
|
'exams_id':arr_ques[i].test_id,
|
|
'exam_questions_id':arr_ques[i].id,
|
|
'answer':arr_ans[i]};
|
|
}
|
|
var arr_json = JSON.stringify(arr_to_send);
|
|
// console.log(arr_json);
|
|
$.post(
|
|
"<?php echo base_url(); ?>student/submit_exam_answer",
|
|
{ ans_array: arr_json},
|
|
function(data)
|
|
{
|
|
window.location.href = "<?php echo base_url(); ?>student/my-tests-exams";
|
|
}
|
|
);
|
|
|
|
});
|
|
|
|
function convert(s){
|
|
|
|
var hrs = Math.floor(s % (3600*24) / 3600);
|
|
var min = Math.floor(s % 3600 / 60);
|
|
var sec = Math.floor(s % 60);
|
|
return "Time Remaining " + hrs + " hrs : " + min + " min : " + sec +" sec";
|
|
}
|
|
|
|
var interval = setInterval(timer , 1000);
|
|
var counter = 0;
|
|
|
|
var s_date = new Date('<?php echo $exams_data[0]['exam_starttime']; ?>').getTime();
|
|
var e_date = new Date('<?php echo $exams_data[0]['exam_endtime']; ?>').getTime();
|
|
|
|
|
|
let NDate = NepaliFunctions.GetCurrentBsDate();
|
|
|
|
var temp_date = new Date();
|
|
let bSDate = NepaliFunctions.GetAdMonth(NDate.month-1);
|
|
|
|
|
|
var append_time = bSDate + ' ' + NDate.day +','+ NDate.year +' '+ temp_date.getHours()+':'+ temp_date.getMinutes()+':'+temp_date.getSeconds();
|
|
|
|
|
|
var current_date = new Date(append_time).getTime();
|
|
|
|
var check_time_start = s_date - current_date;
|
|
var timeLeft ;
|
|
|
|
if (check_time_start < 0) {
|
|
timeLeft = parseInt((e_date - current_date) / 1000);
|
|
} else{
|
|
timeLeft = (e_date - s_date) / 1000;
|
|
}
|
|
|
|
// var timeLeft = (e_date - s_date) / 1000;
|
|
|
|
$(".exmqus_headertym").html(convert(timeLeft - counter));
|
|
|
|
function timer(){
|
|
counter ++;
|
|
$(".exmqus_headertym").html(convert(timeLeft - counter));
|
|
if (counter == timeLeft) {
|
|
clearInterval(interval);
|
|
pop_up_message();
|
|
// alert("time's up");
|
|
}
|
|
}
|
|
|
|
//show user popup after time out
|
|
|
|
function pop_up_message() {
|
|
$('#timeUpModal').modal({
|
|
backdrop: 'static',
|
|
keyboard: false
|
|
});
|
|
}
|
|
|
|
|
|
});
|
|
|
|
$(".closehide_btn").click(function() {
|
|
$('.my-tabs-items').removeClass('my-tabs-items_toggler');
|
|
});
|
|
$(".toggler_resp").click(function() {
|
|
$('.my-tabs-items').addClass('my-tabs-items_toggler');
|
|
|
|
});
|
|
|
|
</script>
|
|
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>/assets_student/css/test-exam.css"> |