EVOLUTION-NINJA
Edit File: user_chapter_wise_test.php
<div id="exam-container" style="position: relative; border: 1px solid #ccc; padding: 20px;"> <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <title>Nparrots Practice Test</title> <link rel="stylesheet" type="text/css" href="<?php echo base_url('public/assets/css/mock_test.css'); ?>" /> <link rel="stylesheet" type="text/css" href="<?php echo base_url('public/assets/css/bootstrap.min.css'); ?>" /> <link rel="stylesheet" type="text/css" href="<?php echo base_url('public/assets/css/font-awesome.min.css'); ?>" /> <link href='http://fonts.googleapis.com/css?family=Lato:400,700' rel='stylesheet' type='text/css'> <link rel='shortcut icon' type='image/x-icon' href='<?php echo base_url('public/assets/website_assets/images/Logo_AMCAD.png'); ?>' /> <script type="text/javascript" src="<?php echo base_url('public/assets/js/jquery-3.3.1.min.js'); ?>"></script> <script type="text/javascript" src="<?php echo base_url('public/assets/js/bootstrap.min.js'); ?>"></script> <link rel="stylesheet" href="<?php echo base_url('public/assets/toastr/toastr.min.css'); ?>"> <script type="text/javascript" src="<?php echo base_url('public/assets/toastr/toastr.min.js'); ?>"></script> <script type="text/javascript" src="<?php echo base_url('public/assets/js/jquery.countdownTimer.js'); ?>"></script> <link rel="stylesheet" type="text/css" href="<?php echo base_url('public/assets/css/jquery.countdownTimer.css'); ?>" /> </head> <body> <header> <?php $uri_id = current_url(true)->getSegment(5); ?> <div class="container-fluid"> <input type="hidden" value="<?= current_url(true)->getSegment(3) ?>" class="uri_chapter_id" /> <input type="hidden" value="<?= current_url(true)->getSegment(3) ?>" class="mapping_id" /> <div class="col-sm-2"> <a class="logo-lg"><img src="<?php echo base_url('public/assets/images/main_logo.png'); ?>" class="img-responsive"></a> </div> <div class="col-sm-7 header_right"> <ul> <li><?php echo $course_title; ?></li> <li>|</li> <li><?php echo $chapter_name; ?></li> <li>|</li> <li>Practice</li> </ul> </div> <div class="col-sm-3 header_right_div"> <ul> <li class="instruction"><a href="" data-toggle="modal" data-target="#test_instructions"><i class="fa fa-info-circle" aria-hidden="true"></i> Instructions</a></li> <li> <div id="hms_timer"></div> </li> <input type="hidden" class="timer" value="<?php echo $total_chapter_wise_questions->total_time; ?>" /> </ul> </div> </div><!-- container----> </header> <section class="anewer_question_middle"> <div class="container-fluid"> <div class="col-sm-5 col-md-4 col-lg-3 anewer_question_middle_left"> <div class=""> <?php $i = 1; foreach ($questions as $key => $value) { ?> <ul class="row"> <li class="anewer_question_no"><a href="javascript:void(0)" class="mark_later_qus mark_later<?php echo $value['question_id']; ?>" id="<?php echo $value['question_id']; ?>" <?php foreach ($mark_number as $vals) { if ($value['question_id'] == $vals->question_id) { ?> style="background-color:yellow" ; <?php } } ?>> <input type="hidden" id="chapter_id" value="<?php echo $value['chapter_id']; ?>"> <input type="hidden" id="subject_id" value="<?php echo $value['sub_domain_id']; ?>"> <input type="hidden" id="quest_num<?php echo $value['question_id']; ?>" value="<?php echo $i; ?>"> <span class="no_sl" id="<?php echo $i; ?>"><?php echo $i; ?><?php echo "."; ?> </span> </a></li> <?php if (!empty($value['ans1'])) { ?> <li><label class="round mark_checked1<?php echo $value['question_id']; ?>" <?php foreach ($mark_for_later as $val) { if ($value['question_id'] == $val->question_id) { ?> style="background: #337ab7; color: white; border: 1px solid white;" <?php } } ?>> A </label> <input type="hidden" class="ans1" value="1"> </li> <?php } else { ?> <?php } ?> <?php if (!empty($value['ans2'])) { ?> <li><label class="round mark_checked2<?php echo $value['question_id']; ?>" <?php foreach ($mark_for_later as $val) { if ($value['question_id'] == $val->question_id) { ?> style="background: #337ab7; color: white; border: 1px solid white;" <?php } } ?>> B </label> <input type="hidden" class="ans2" value="2"> </li> <?php } else { ?> <?php } ?> <?php if (!empty($value['ans3'])) { ?> <li><label class="round mark_checked3<?php echo $value['question_id']; ?>" <?php foreach ($mark_for_later as $val) { if ($value['question_id'] == $val->question_id) { ?> style="background: #337ab7; color: white; border: 1px solid white;" <?php } } ?>> C </label> <input type="hidden" class="ans3" value="3"> </li> <?php } else { ?> <?php } ?> <?php if (!empty($value['ans4'])) { ?> <li><label class="round mark_checked4<?php echo $value['question_id']; ?>" <?php foreach ($mark_for_later as $val) { if ($value['question_id'] == $val->question_id) { ?> style="background: #337ab7; color: white; border: 1px solid white;" <?php } } ?>> D </label> <input type="hidden" class="ans4" value="4"> </li> <?php } ?> </ul> <?php $i++; } ?> </div> </div><!-- col-sm-3------------------------------------------------------> <div class="col-sm-7 col-md-8 col-lg-9 blink_text"></div> <div class="col-sm-7 col-md-8 col-lg-9"> <div class="anewer_question_middle_right" id="append_next_question"> <?php $j = 1; foreach ($limitation_questions as $value) { ?> <input type="hidden" class="question_number" value="<?php echo $j; ?>"> <!--<h4><span><?php echo $j; ?><?php echo "."; ?> <input type="text" value="<?php echo $value['questions']; ?>" style="border: none; width: 95%;"/></span> </h4>--> <!--- <h4><span style="display:table-cell;"><?php echo $j; ?><?php echo "."; ?></span><textarea type="text" rows="auto" style="display:table-cell;border: none;line-height:1.3;padding-left: 10px;width:90%;height: auto !important;" id="text"><?php echo $value['questions']; ?></textarea> </h4>--> <!--<h4><span class="question_no"><?php echo $j; ?><?php echo "."; ?></span><textarea class="question_no_textarea" rows="" type="text" id="text"><?php echo $value['questions']; ?></textarea></h4>--> <!--<h4><span class="question_no"><?php echo $j; ?><?php echo "."; ?></span><pre></pre></h4>--> <div class="row"> <pre><code> <input type="hidden" name="question_number" id="question_number" value="<?php echo $j; ?>"/> <?php echo $j; ?><?php echo "."; ?> <?php echo $value['questions']; ?> </code></pre> </div> <input type="hidden" id="question_id" value="<?php echo $value['question_id']; ?>"> <input type="hidden" id="chapter_id" value="<?php echo $value['chapter_id']; ?>"> <input type="hidden" id="subject_id" value="<?php echo $value['sub_domain_id']; ?>"> <section id="first" class="section question_option"> <?php if (!empty($value['ans1'])) { ?> <div class="qustion_option"> <input type="radio" name="ans" id="radio-1" value="1" class="question_answer"> <label for="radio-1" class="question_answer_radio"><span class="radio question_radio"><span class="abcd">A</span> <input type="hidden" class="ans" name="answer" value="1"> <pre><code><?php echo $value['ans1']; ?></code></pre> </span></label> </div> <?php } else { ?> <?php } ?> <?php if (!empty($value['ans2'])) { ?> <div class="qustion_option"> <input type="radio" name="ans" id="radio-2" value="2" class="question_answer"> <label for="radio-2" class="question_answer_radio"><span class="radio question_radio"><span class="abcd">B</span> <input type="hidden" class="ans" name="answer" value="2"> <pre><code><?php echo $value['ans2']; ?></code></pre> </span></label> </div> <?php } else { ?> <?php } ?> <?php if (!empty($value['ans3'])) { ?> <div class="qustion_option"> <input type="radio" name="ans" id="radio-3" value="3" class="question_answer"> <label for="radio-3" class="question_answer_radio"><span class="radio question_radio"><span class="abcd">C</span> <input type="hidden" class="ans" name="answer" value="3"> <pre><code><?php echo $value['ans3']; ?></code></pre> </span></label> </div> <?php } else { ?> <?php } ?> <?php if (!empty($value['ans4'])) { ?> <div class="qustion_option"> <input type="radio" name="ans" id="radio-4" value="4" class="question_answer"> <label for="radio-4" class="question_answer_radio"><span class="radio question_radio"><span class="abcd">D</span> <input type="hidden" class="ans" name="answer" value="4"> <pre><code><?php echo $value['ans4']; ?></code></pre> </span></label> </div> <?php } else { ?> <?php } ?> </section> <?php $j++; } ?> </div><!-- col-sm-9----> </div> </div><!-- container----> </section> <!------------------------------------- middle Work END ------------------------------------------------> <footer> <div class="container-fluid"> <input type="hidden" name="mark_value" id="mark_value" value="0"> <div class="col-sm-5 col-md-5"> <!--<button type="button" class="btn btn-success buttonsri" id="marked_question"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Marked Questions</button>--> <!--<button type="button" class="btn btn-success buttonsri" id="mark_for_later"><input type="hidden" id="question_id" value="<//?php echo $value['question_id']; ?>"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Mark for later </button>--> <button type="button" class="btn btn-success buttonsri" id="preview_question"> <i class="fa fa-angle-double-left" aria-hidden="true"></i> Previous </button> </div> <div class="col-sm-3 col-md-3 footer_middle_qes"> <?php $c = 1; $tot = $total_chapter_wise_questions; ?> <p>Question <span style="color:#4cae4c;"><input type="text" class="q_ids" value="<?php echo $c; ?>" style="border:none;background-color: #efefec;width: 30px;" disabled /></span> of <span><?php echo $total_chapter_wise_questions->number_of_questions; ?></span></p> <input type="hidden" class="q_id" value="<?php echo $total_chapter_wise_questions->number_of_questions; ?>" /> </div> <div class="col-sm-4 col-md-4"> <button type="button" class="btn btn-success buttonsri" data-toggle="modal" data-target="#finish_this_test"> Finish this Test</button> <button type="button" class="btn btn-success buttonsri" id="next_question"> Next <i class="fa fa-angle-double-right" aria-hidden="true"></i> </button> </div> </div><!-- container----> </footer> <!---- finish Button Popup ----------------------------------------------------------> <!-- Modal --> <div class="modal fade" id="finish_this_test" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title" id="exampleModalLabel">Are you sure you want to finish this Test?</h4> <button type="button" class="close" data-dismiss="modal" aria-label="Close" style="text-align:right;"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-footer"> <button type="button" class="btn btn-success" onclick="finish(<?php echo $uri_id; ?>);">Yes, I'm done with this Test</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> </div> </div> </div> </div> <!-- Modal1 --> <div class="modal fade" id="test_instructions" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <div class="welcome_middle_one_middle"> <h4>Welcome to Online Test - 1</h4> <?php if (empty($chapter)) { ?> This is a Mock Test of <?php echo $subject->sub_domain; ?> online Course which contains <?php echo $total_chapter_wise_questions->number_of_questions; ?> multiple choice questions.</p> <?php } else { ?> <p>* This is a Mock Test of <?php echo $chapter->chapter_name; ?> online Course which contains <?php echo $total_chapter_wise_questions->number_of_questions; ?> multiple choice questions.</p> <?php } ?> <?php if (empty($total_chapter_wise_questions)) { ?> <p>* Test duration is <?php echo $total_subject_question_timings->total_time; ?> minutes.</p> <?php } else { ?> <p>* Test duration is <?php echo $total_chapter_wise_questions->total_time; ?> minutes.</p> <?php } ?> <!-- <p>* Test duration is 6 in total(72 seconds per question).</p>--> <p>* There is no negative marking.</p> <p>* If you are unsure about the answer, you have an option 'Mark For Later' which marks that question to review and you can answer whenever before finishing the test.</p> <!-- <p>* Simply mark the question for the later and review at the end of the exam.</p> --> <p>* On clicking the questions on the left side of the screen it will be redirected to the particular question.</p> <p>* Marked for later questions will be highlighted in green color among the questions on left side of the screen.</p> <p>* Write down the formulas, mindmaps, brain dump and any other notes you may need to refer during the test.</p> <div class="label_mark_final"> <div class="radio"> <label class="round_final mark_checked1147"></label> <label>Mark For Later</label> </div> <!--- <div class="radio"> <label><input type="radio" name="optradio">Attempted</label> </div>----> </div> </div> <div class=""> <?php foreach ($details as $det) { ?> <input type="hidden" value="<?php echo $det->selected_type; ?>" class="type_value" /> <input type="hidden" value="<?php echo $det->subject_id; ?>" class="sub_val" /> <input type="hidden" value="<?php echo $det->chapter_id; ?>" class="chapter_val" /> <?php } ?> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> </div> </div> </div> </div> <!-- Modal --> <div class="modal fade" id="marked_question_modal" role="dialog"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Marked Questions</h4> </div> <div class="modal-body"> <div id="marked_question_div"></div> </div> </div> </div> </div> </body> </html> </div> <script> $(document).ready(function() { var q_id = $('.q_id').val(); if (q_id == 1) { $('#next_question').hide(); $('#preview_question').hide(); } var f_id = 0; var footer_qid = f_id + 1; var s = $('.q_ids').val(footer_qid); var i = 1; $('#preview_question').hide(); $(document).on('click', '#mark_for_later', function() { $(this).attr('disabled', 'disabled'); document.getElementById('mark_value').value = ++i; var val = $('#question_id').val(); var question_number = $("#question_number").val(); $.ajax({ type: 'POST', url: '<?php echo site_url('mark_as_later_chapter') ?>', data: { qid: val, question_number: question_number }, success: function(response) { // response=jQuery.parseJSON(response); if (response.result == 1) { toastr["success"](response.message); var qid = $('.mark_later' + val).css('background-color', '#00ff00'); var qid = $('.mark_later' + val).css('border-radius', '50%'); var qid = $('.mark_later' + val).css('padding', '5px'); $('#preview_question').show(); var mapping_id = $('.mapping_id').val(); var qid = $('#question_id').val(); var cid = $('#chapter_id').val(); var ans = $('input[name=ans]:checked').val(); var mvalue = $('#mark_value').val(); $("#mark_for_later").removeAttr('disabled'); // $.ajax({ // type:'POST', // url:'<?php //echo site_url('next_question') ?>', // data:{'qid':qid,'cid':cid,'ans':ans,'mvalue':mvalue,'mapping_id':mapping_id}, // success:function(response){ // // response=jQuery.parseJSON(response); // if(response.result == 1) // { // $("#next_question").removeAttr('disabled'); // $("#mark_for_later").removeAttr('disabled'); // qid = response.message.qid; // chapter_id = response.message.chapter_id; // sub_domain_id = response.message.sub_domain_id; // questions = response.message.questions; // ans1 = response.message.ans1; // ans2 = response.message.ans2; // ans3 = response.message.ans3; // ans4 = response.message.ans4; // ans = response.message.ans; // cans = response.message.correct_answer; // var next_question_number = $('#next_question_number').val(); // var inc = 1; // var nxt_quest_id = parseInt(next_question_number)+parseInt(inc); // var next_question_number = $('#next_question_number').val(nxt_quest_id); // var q_id = $('.q_id').val(); // var a = $('.question_number').val(); // var b = 1; // var id = parseInt(a) + parseInt(b); // if(q_id == id) // { // $('#next_question').hide(); // } // var s = $('.q_ids').val(); // var fo_id = parseInt(s)+1; // var footer_qid = $('.q_ids').val(fo_id); // var html=''; // html +='<input type="hidden" class="question_number" value='+id+'>'; // // html +='<h4><span>'+id+''+'.'+' </span><input type="text" value="'+ questions +'" style="border: none; width: 95%;"/></h4>'; // // html +='<h4><span class="question_no">'+id+''+'.'+' </span><textarea class="question_no_textarea" rows="" type="text" id="text">'+ questions +'</textarea></h4>'; // html +=' <div class="row"><pre><code>'+id+''+'.'+' '+ questions +'</code></pre></div>'; // html +='<input type="hidden" id="question_id" value='+qid+'>'; // html +='<input type="hidden" id="chapter_id" value='+chapter_id+'>'; // html +='<input type="hidden" id="subject_id" value='+sub_domain_id+'>'; // html +='<section id="first" class="section question_option">'; // if(ans1 != "") // { // html +='<div class="qustion_option">'; // html +='<input type="radio" name="ans" id="radio-1" class="ans1" value="1">'; // //html +='<label for="radio-1" class="question_answer_radio"><span class="radio"><span class="abcd">A</span><input type="text" value="'+ ans1 +'" style="border: none; background: #f6f6f6;width:100%;"/></span></label>'; // html +='<label for="radio-1" class="question_answer_radio"><span class="radio"><span class="abcd">A</span><pre><code>'+ ans1 +'</code></pre></span></label>'; // html +='</div>'; // } // else // { // } // if(ans2 != "") // { // html +='<div class="qustion_option">'; // html +='<input type="radio" name="ans" id="radio-2" class="ans2" value="2">'; // html +='<label for="radio-2" class="question_answer_radio"><span class="radio"><span class="abcd">B</span><pre><code>'+ ans2 +'</code></pre></span></label>'; // html +='</div>'; // } // else // { // } // if(ans3 != "") // { // html +='<div class="qustion_option">'; // html +='<input type="radio" name="ans" id="radio-3" class="ans3" value="3">'; // html +='<label for="radio-3" class="question_answer_radio"><span class="radio"><span class="abcd">C</span><pre><code>'+ ans3 +'</code></pre></span></label>'; // html +='</div>'; // } // else // { // } // if(ans4 != "") // { // html +='<div class="qustion_option">'; // html +='<input type="radio" name="ans" id="radio-4" class="ans4" value="4">'; // html +='<label for="radio-4" class="question_answer_radio"><span class="radio"><span class="abcd">D</span><pre><code>'+ ans4 +'</code></pre></span></label>'; // html +='</div>'; // } // else // { // } // html +='</section>'; // $('#append_next_question').html(html); // if(cans == '1'){ // $(".ans1").attr( 'checked', true ); // }else if(cans == '2'){ // $(".ans2").attr( 'checked', true ); // }else if(cans == '3'){ // $(".ans3").attr( 'checked', true ); // }else if(cans == '4'){ // $(".ans4").attr( 'checked', true ); // } // } // else // { // $("#next_question").removeAttr('disabled'); // $("#mark_for_later").removeAttr('disabled'); // toastr["error"](response.message); // } // } // }); } else { var qid = $('.mark_later' + val).css('background-color', ' '); } } }); }); $(document).on('click', '#next_question', function() { $(this).attr('disabled', 'disabled'); $('#preview_question').show(); var mapping_id = $('.mapping_id').val(); var qid = $('#question_id').val(); var cid = $('#chapter_id').val(); var ans = $('input[name=ans]:checked').val(); var mvalue = $('#mark_value').val(); $.ajax({ type: 'POST', url: '<?php echo site_url('next_question') ?>', data: { 'qid': qid, 'cid': cid, 'ans': ans, 'mvalue': mvalue, 'mapping_id': mapping_id }, success: function(response) { // response=jQuery.parseJSON(response); if (response.result == 1) { $("#next_question").removeAttr('disabled'); qid = response.message.qid; chapter_id = response.message.chapter_id; sub_domain_id = response.message.sub_domain_id; questions = response.message.questions; ans1 = response.message.ans1; ans2 = response.message.ans2; ans3 = response.message.ans3; ans4 = response.message.ans4; ans = response.message.ans; cans = response.message.correct_answer; var next_question_number = $('#next_question_number').val(); var inc = 1; var nxt_quest_id = parseInt(next_question_number) + parseInt(inc); var next_question_number = $('#next_question_number').val(nxt_quest_id); var q_id = $('.q_id').val(); var a = $('.question_number').val(); var b = 1; var id = parseInt(a) + parseInt(b); if (q_id == id) { $('#next_question').hide(); } var s = $('.q_ids').val(); var fo_id = parseInt(s) + 1; var footer_qid = $('.q_ids').val(fo_id); var html = ''; html += '<input type="hidden" class="question_number" value=' + id + '>'; // html +='<h4><span>'+id+''+'.'+' </span><input type="text" value="'+ questions +'" style="border: none; width: 95%;"/></h4>'; // html +='<h4><span class="question_no">'+id+''+'.'+' </span><textarea class="question_no_textarea" rows="" type="text" id="text">'+ questions +'</textarea></h4>'; html += ' <div class="row"><pre><code><input type="hidden" name="question_number" id="question_number" value="' + id + '"/>' + id + '' + '.' + ' ' + questions + '</code></pre></div>'; html += '<input type="hidden" id="question_id" value=' + qid + '>'; html += '<input type="hidden" id="chapter_id" value=' + chapter_id + '>'; html += '<input type="hidden" id="subject_id" value=' + sub_domain_id + '>'; html += '<section id="first" class="section question_option">'; if (ans1 != "") { html += '<div class="qustion_option">'; html += '<input type="radio" name="ans" id="radio-1" class="ans1" value="1">'; //html +='<label for="radio-1" class="question_answer_radio"><span class="radio"><span class="abcd">A</span><input type="text" value="'+ ans1 +'" style="border: none; background: #f6f6f6;width:100%;"/></span></label>'; html += '<label for="radio-1" class="question_answer_radio"><span class="radio"><span class="abcd">A</span><pre><code>' + ans1 + '</code></pre></span></label>'; html += '</div>'; } else { } if (ans2 != "") { html += '<div class="qustion_option">'; html += '<input type="radio" name="ans" id="radio-2" class="ans2" value="2">'; html += '<label for="radio-2" class="question_answer_radio"><span class="radio"><span class="abcd">B</span><pre><code>' + ans2 + '</code></pre></span></label>'; html += '</div>'; } else { } if (ans3 != "") { html += '<div class="qustion_option">'; html += '<input type="radio" name="ans" id="radio-3" class="ans3" value="3">'; html += '<label for="radio-3" class="question_answer_radio"><span class="radio"><span class="abcd">C</span><pre><code>' + ans3 + '</code></pre></span></label>'; html += '</div>'; } else { } if (ans4 != "") { html += '<div class="qustion_option">'; html += '<input type="radio" name="ans" id="radio-4" class="ans4" value="4">'; html += '<label for="radio-4" class="question_answer_radio"><span class="radio"><span class="abcd">D</span><pre><code>' + ans4 + '</code></pre></span></label>'; html += '</div>'; } else { } html += '</section>'; $('#append_next_question').html(html); if (cans == '1') { $(".ans1").attr('checked', true); } else if (cans == '2') { $(".ans2").attr('checked', true); } else if (cans == '3') { $(".ans3").attr('checked', true); } else if (cans == '4') { $(".ans4").attr('checked', true); } } else { $("#next_question").removeAttr('disabled'); toastr["error"](response.message); } } }); }); $('#preview_question').click(function() { $('#next_question').show(); var mapping_id = $('.mapping_id').val(); var qid = $('#question_id').val(); var cid = $('#chapter_id').val(); $("#preview_question").attr('disabled', 'disabled'); $.ajax({ type: 'POST', url: '<?php echo site_url('previous_question') ?>', data: { 'qid': qid, 'cid': cid, 'mapping_id': mapping_id }, success: function(response) { // response=jQuery.parseJSON(response); if (response.result == 1) { $("#preview_question").removeAttr('disabled'); var qid = response.message.qid; var chapter_id = response.message.chapter_id; var sub_domain_id = response.message.sub_domain_id; var questions = response.message.questions; var ans1 = response.message.ans1; var ans2 = response.message.ans2; var ans3 = response.message.ans3; var ans4 = response.message.ans4; var ans = response.message.ans; var cans = response.message.correct_answer; var a = $('.question_number').val(); var b = 1; var id = parseInt(a) - parseInt(b); if (id == 1) { $('#preview_question').hide(); } var s = $('.q_ids').val(); var fo_id = parseInt(s) - 1; var footer_qid = $('.q_ids').val(fo_id); var html = ''; html += '<input type="hidden" class="question_number" value=' + id + '>'; // html +='<h4><span>'+id+''+'.'+' </span><input type="text" value="'+ questions +'" style="border: none; width: 95%;"/></h4>'; // html +='<h4><span class="question_no">'+id+''+'.'+'</span><textarea class="question_no_textarea" rows="" type="text" id="text">'+ questions +'</textarea></h4>'; html += ' <div class="row"><pre><code><input type="hidden" name="question_number" id="question_number" value="' + id + '"/>' + id + '' + '.' + ' ' + questions + '</code></pre></div>'; html += '<input type="hidden" id="question_id" value=' + qid + '>'; html += '<input type="hidden" id="chapter_id" value=' + chapter_id + '>'; html += '<input type="hidden" id="subject_id" value=' + sub_domain_id + '>'; html += '<section id="first" class="section question_option">'; if (ans1 != "") { html += '<div class="qustion_option">'; html += '<input type="radio" name="ans" id="radio-1" class="ans1" value="1">'; html += '<label for="radio-1"><span class="radio"><span class="abcd">A</span><pre><code>' + ans1 + '</code></pre></span></label>'; html += '</div>'; } else { } if (ans2 != "") { html += '<div class="qustion_option">'; html += '<input type="radio" name="ans" id="radio-2" class="ans2" value="2">'; html += '<label for="radio-2"><span class="radio"><span class="abcd">B</span><pre><code>' + ans2 + '</code></pre></span></label>'; html += '</div>'; } else { } if (ans3 != "") { html += '<div class="qustion_option">'; html += '<input type="radio" name="ans" id="radio-3" class="ans3" value="3">'; html += '<label for="radio-3"><span class="radio"><span class="abcd">C</span><pre><code>' + ans3 + '</code></pre></span></label>'; html += '</div>'; } else { } if (ans4 != "") { html += '<div class="qustion_option">'; html += '<input type="radio" name="ans" id="radio-4" class="ans4" value="4">'; html += '<label for="radio-4"><span class="radio"><span class="abcd">D</span><pre><code>' + ans4 + '</code></pre></span></label>'; html += '</div>'; } else { } html += '</section>'; $('#append_next_question').html(html); if (cans == '1') { $(".ans1").attr('checked', true); } else if (cans == '2') { $(".ans2").attr('checked', true); } else if (cans == '3') { $(".ans3").attr('checked', true); } else if (cans == '4') { $(".ans4").attr('checked', true); } } else { toastr["error"](response.message); } } }); }); $('.mark_later_qus').click(function() { var qid = $(this).attr('id'); var cid = $('#chapter_id').val(); var sid = $('#subject_id').val(); var no_sl = $('#quest_num' + qid).val(); var tot_quests = $('.q_id').val(); $.ajax({ type: 'POST', url: '<?php echo site_url('mark_later_qus_chapter') ?>', data: { 'qid': qid, 'cid': cid, 'sid': sid }, success: function(response) { // response=jQuery.parseJSON(response); if (response.result == 1) { var qid = response.message.qid; var chapter_id = response.message.chapter_id; var sub_domain_id = response.message.sub_domain_id; var questions = response.message.questions; var ans1 = response.message.ans1; var ans2 = response.message.ans2; var ans3 = response.message.ans3; var ans4 = response.message.ans4; var ans = response.message.ans; var cans = response.message.correct_answer; /*var a = $('.question_number').val(); var b = 1; var id = parseInt(a) + parseInt(b);*/ var a = $('.question_number').val(); var b = 1; var id = parseInt(a) + parseInt(b); var footer_qid = $('.q_ids').val(no_sl); if (no_sl == 1) { $('#preview_question').hide(); } else { $('#preview_question').show(); } if (no_sl == tot_quests) { $('#next_question').hide(); } else { $('#next_question').show(); } var html = ''; html += '<input type="hidden" class="question_number" value=' + no_sl + '>'; // html +='<h4><span>'+no_sl+''+'.'+' </span><input type="text" value="'+ questions +'" style="border: none; width: 95%;"/></h4>'; html += ' <div class="row"><pre><code>' + no_sl + '' + '.' + ' ' + questions + '</code></pre></div>'; html += '<input type="hidden" id="question_id" value=' + qid + '>'; html += '<input type="hidden" id="chapter_id" value=' + chapter_id + '>'; html += '<input type="hidden" id="subject_id" value=' + sub_domain_id + '>'; html += '<section id="first" class="section question_option">'; if (ans1 != "") { html += '<div class="qustion_option">'; html += '<input type="radio" name="ans" id="radio-1" class="ans1" value="1">'; html += '<label for="radio-1"><span class="radio"><span class="abcd">A</span><pre><code>' + ans1 + '</code></pre></span></label>'; html += '</div>'; } else { } if (ans2 != "") { html += '<div class="qustion_option">'; html += '<input type="radio" name="ans" id="radio-2" class="ans2" value="2">'; html += '<label for="radio-2"><span class="radio"><span class="abcd">B</span><pre><code>' + ans2 + '</code></pre></span></label>'; html += '</div>'; } else { } if (ans3 != "") { html += '<div class="qustion_option">'; html += '<input type="radio" name="ans" id="radio-3" class="ans3" value="3">'; html += '<label for="radio-3"><span class="radio"><span class="abcd">C</span><pre><code>' + ans3 + '</code></pre></span></label>'; html += '</div>'; } else { } if (ans4 != "") { html += '<div class="qustion_option">'; html += '<input type="radio" name="ans" id="radio-4" class="ans4" value="4">'; html += '<label for="radio-4"><span class="radio"><span class="abcd">D</span><pre><code>' + ans4 + '</code></pre></span></label>'; html += '</div>'; } else { } html += '</section>'; $('#append_next_question').html(html); if (cans == '1') { $(".ans1").attr('checked', true); } else if (cans == '2') { $(".ans2").attr('checked', true); } else if (cans == '3') { $(".ans3").attr('checked', true); } else if (cans == '4') { $(".ans4").attr('checked', true); } } else { toastr["error"](response.message); } } }); }); }); $(document).on('change', '.qustion_option', function() { var qid = $('#question_id').val(); var cid = $('#chapter_id').val(); var ans = $('input[name=ans]:checked').val(); var mvalue = $('#mark_value').val(); //$('.mark_checked'+qid).attr( 'checked', true ); var ans1 = $('.ans1').val(); var ans2 = $('.ans2').val(); var ans3 = $('.ans3').val(); var ans4 = $('.ans4').val(); //alert(ans); //alert(ans1); if (ans == ans1) { $('.mark_checked1' + qid).css({ "background-color": "#337ab7", "color": "white", "border": "1px solid white" }); $('.mark_checked2' + qid).css({ "background-color": "", "color": "black", "border": "1px solid white" }); $('.mark_checked3' + qid).css({ "background-color": "", "color": "black", "border": "1px solid white" }); $('.mark_checked4' + qid).css({ "background-color": "", "color": "black", "border": "1px solid white" }); } else if (ans == ans2) { $('.mark_checked1' + qid).css({ "background-color": "", "color": "black", "border": "1px solid white" }); $('.mark_checked2' + qid).css({ "background-color": "#337ab7", "color": "white", "border": "1px solid white" }); $('.mark_checked3' + qid).css({ "background-color": "", "color": "black", "border": "1px solid white" }); $('.mark_checked4' + qid).css({ "background-color": "", "color": "black", "border": "1px solid white" }); } else if (ans == ans3) { $('.mark_checked1' + qid).css({ "background-color": "", "color": "black", "border": "1px solid white" }); $('.mark_checked2' + qid).css({ "background-color": "", "color": "black", "border": "1px solid white" }); $('.mark_checked3' + qid).css({ "background-color": "#337ab7", "color": "white", "border": "1px solid white" }); $('.mark_checked4' + qid).css({ "background-color": "", "color": "black", "border": "1px solid white" }); } else if (ans == ans4) { $('.mark_checked1' + qid).css({ "background-color": "", "color": "black", "border": "1px solid white" }); $('.mark_checked2' + qid).css({ "background-color": "", "color": "black", "border": "1px solid white" }); $('.mark_checked3' + qid).css({ "background-color": "", "color": "black", "border": "1px solid white" }); $('.mark_checked4' + qid).css({ "background-color": "#337ab7", "color": "white", "border": "1px solid white" }); } $('.mark_later' + qid).css('background-color', ''); $.ajax({ type: 'POST', url: '<?php echo site_url('insert_chapter_wise_answers') ?>', data: { 'qid': qid, 'cid': cid, 'ans': ans, 'mvalue': mvalue }, success: function(response) { } }); }); function finish(str) { var chapter_id = $('#chapter_id').val();; $.ajax({ type: 'POST', url: '<?php echo site_url('insert_unattended_chapter_wise_answers') ?>', data: { 'chapter_id': chapter_id }, success: function(response) { window.location.href = "<?php echo site_url('online_test_result_chapter_wise'); ?>/<?= current_url(true)->getSegment(3) ?>/" +chapter_id ; // window.location.href = "<?php echo site_url('online_test_result_chapter_wise'); ?>/<?= current_url(true)->getSegment(4) ?>/" + str; } }); } function instruction(str) { window.location.href = "<?php echo site_url('test-welcome-page'); ?>/" + str; } </script> <script> $(function() { var a = $('.timer').val(); // a = a.replace('00:', ''); var strarray = a.split(':'); var chapter_id = $('.uri_chapter_id').val(); //alert(chapter_id); $('#hms_timer').countdowntimer({ hours: strarray[0], minutes: strarray[1], seconds: strarray[2], size: "lg", pauseButton: "pauseBtnhms", stopButton: "stopBtnhms" }); var sec = 60; var hour = parseInt(strarray[0]) * parseInt(sec) * parseInt(sec); var min = parseInt(strarray[1]) * parseInt(sec); var time = parseInt(hour) + parseInt(min); var final_timeout = parseInt(time) * 1000; setTimeout(function() { // window.location.href = "<//?php echo site_url("online_test_result_chapter_wise"); ?>/<//?= current_url(true)->getSegment(5) ?>/" + chapter_id; window.location.href = "<?php echo base_url('/') ?>"; }, final_timeout); }); </script> <script type="text/javascript"> history.pushState({ page: 1 }, "Title 1", "#no-back"); window.onhashchange = function(event) { window.location.hash = "no-back"; }; $(function() { $(document).keydown(function(e) { return (e.which || e.keyCode) != 116; }); }); </script> <!---<script type="text/javascript"> var message="Sorry, right-click has been disabled"; function clickIE() {if (document.all) {(message);return false;}} function clickNS(e) {if (document.layers||(document.getElementById&&!document.all)) { if (e.which==2||e.which==3) {(message);return false;}}} if (document.layers) {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;} else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;} document.oncontextmenu=new Function("return false") </script> ----> <script type="text/javascript"> $(document).keydown(function(e) { var key = e.charCode || e.keyCode; if (key == 17) { // enter key do nothing } else { e.preventDefault(); } }); </script> <style type="text/css"> .modal-dialog { margin: 60px auto; } .instruction { cursor: pointer; } .round { width: 30px; height: 30px; border: 1px solid silver; text-align: center; line-height: 25px; border-radius: 50px; margin-top: -10px; margin-bottom: 0 !important; } .actives_round { background: #337ab7; color: white; border: 1px solid white; } .question_answer_radio { width: 100%; } textarea { border: 0 none white; overflow: initial; } /* .question_no { //display: table-cell; } .question_no_textarea { display: table-cell; border: none; line-height: 1.3; padding-left: 20px; width: 90%; height: 15em; }*/ pre { background-color: transparent !important; border: 1px solid transparent !important; font-size: 15px !important; } pre code { white-space: pre-line; text-align: justify; line-height: 1.8; } .question_option pre { padding: 0px; margin: 0 0 0px; font-weight: initial; } .checkbox, .radio { /*display: flex !important;*/ align-items: center !important; } @media only screen and (min-width:320px) and (max-width:640px) { .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 { position: initial !important; } } .round_final { width: 30px; height: 30px; border: 1px solid silver; text-align: center; line-height: 25px; border-radius: 50px; margin-top: -10px; margin-bottom: 0 !important; background-color: #00ff00; vertical-align: middle; } .label_mark_finals label { vertical-align: middle; } </style> <script> //$("textarea").resizable(); var observe; if (window.attachEvent) { observe = function(element, event, handler) { element.attachEvent('on' + event, handler); }; } else { observe = function(element, event, handler) { element.addEventListener(event, handler, false); }; } function init() { var text = document.getElementById('text'); function resize() { text.style.height = 'auto'; text.style.height = text.scrollHeight + 'px'; } function delayedResize() { window.setTimeout(resize, 0); } observe(text, 'change', resize); observe(text, 'cut', delayedResize); observe(text, 'paste', delayedResize); observe(text, 'drop', delayedResize); observe(text, 'keydown', delayedResize); text.focus(); text.select(); resize(); } </script> <script type="text/javascript"> $(document).ready(function() { setInterval(TimeLeft, 1000); //TimeLeft(); function TimeLeft() { var hms = $("#hms_timer").text(); if (hms < '00:10:00') { $(".blink_text").html('<h5 style="color:red;">Remaining time left is ' + hms + '</h5>'); } else { $(".blink_text").empty(); } } $(document).on('click', '#marked_question', function() { var val = $('#question_id').val(); var val1 = $('.mark_as_value').val(); $.ajax({ type: 'POST', url: '<?php echo site_url('get-marked-chapter-questions') ?>', data: { qid: val }, success: function(response) { // response=jQuery.parseJSON(response); if (response.result == 1) { var questions = ''; var sl = 1; $.each(response.message, function(key, val) { questions += '<p>' + val.question_number + '. ' + val.questions + '</p>'; sl++; }); $("#marked_question_div").html(questions); $("#marked_question_modal").modal("show"); } else { } } }); }); }); </script> <!-----------------------------------------------------------------------> <style> #warningModal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); color: white; display: none; justify-content: center; align-items: center; z-index: 1; flex-direction: column; text-align: center; } #warningModal button { margin: 10px; padding: 10px 20px; font-size: 18px; } </style> <div id="warningModal"> <div id="warningText" style="font-size: 22px; margin-bottom: 20px;"></div> <button onclick="terminateTest()" style="background-color:Red;color:white;">OK (Terminate)</button> <button onclick="closeModal()" style="background-color:green;color:white;">Cancel (Continue)</button> </div> <script> const logoutUrl = "<?= base_url('user-logout') ?>"; let warningCount = 0; const maxWarnings = 10; let currentReason = ""; let modalShownOnce = false; let mouseWarningGiven = false; // 🟡 NEW function handleWarning(reasonText) { warningCount++; currentReason = reasonText; // Log event fetch("warn.php", { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: "reason=" + encodeURIComponent(reasonText) + "&count=" + warningCount }); // 🔴 If already shown modal and now another tab switch → terminate if (modalShownOnce && reasonText.includes("Tab switch")) { alert("Repeated suspicious activity (Tab switch). Test terminated."); window.location.href = logoutUrl; return; } // 🔴 If mouse warning already given and again triggers tab switch → terminate if (mouseWarningGiven && reasonText.includes("Tab switch")) { alert("Mouse warning ignored. Tab switch detected. Test terminated."); window.location.href = logoutUrl; return; } if (warningCount >= maxWarnings) { alert("Maximum warnings exceeded. Test terminated."); window.location.href = logoutUrl; return; } // Set flags if (reasonText.includes("Mouse moved")) { mouseWarningGiven = true; // 🟡 Mark that mouse warning was shown } modalShownOnce = true; // Show warning modal document.getElementById("warningText").innerText = `${reasonText} (${warningCount}/${maxWarnings} warnings)\nClick OK to terminate the test.\nClick Cancel to continue.`; document.getElementById("warningModal").style.display = "flex"; } function terminateTest() { alert("You have chosen to terminate the test.\nYour activity has been logged."); window.location.href = logoutUrl; } function closeModal() { document.getElementById("warningModal").style.display = "none"; } // 🔹 Tab switch detection document.addEventListener("visibilitychange", function () { if (document.hidden) { handleWarning("Tab switch detected!"); } }); // // 🔹 Mouse leave (top only) // document.addEventListener("DOMContentLoaded", function () { // const examContainer = document.getElementById("exam-container"); // if (examContainer) { // examContainer.addEventListener("mouseleave", function (e) { // const rect = examContainer.getBoundingClientRect(); // if (e.clientY < rect.top) { // handleWarning("Mouse moved out of the exam area (top side)!"); // } // }); // } // }); document.addEventListener("mouseleave", function (e) { if ( e.clientY <= 0 || // Top (toolbar area) e.clientY >= window.innerHeight || // Bottom (taskbar or OS dock) e.clientX <= 0 || // Left side e.clientX >= window.innerWidth // Right side ) { handleWarning("Mouse moved outside the browser window!"); } }); // 🔹 Keyboard cheat detection document.addEventListener("keyup", function (e) { if ( (e.key === "Tab" && (e.altKey || e.ctrlKey)) || (e.key === "F5") ) { handleWarning("Suspicious keyboard action detected!"); } }); // 🔹 Right-click block document.addEventListener("contextmenu", e => e.preventDefault()); // 🔹 DevTools, Save/Source shortcut block document.onkeydown = function(e) { if ( e.key === "F12" || (e.ctrlKey && e.shiftKey && ['I','J','C','U'].includes(e.key.toUpperCase())) || (e.ctrlKey && ['S', 'U'].includes(e.key.toUpperCase())) ) { return false; } }; </script> <style> .header { height: 50px; } .logo-lg img { width: 52%; margin-left: 25px; } .header_links ul { padding-top: 1%; } </style>