ok
Direktori : /home2/selectio/public_html/tnpsctestbatch.com/quiz/ |
Current File : /home2/selectio/public_html/tnpsctestbatch.com/quiz/subject-test.php |
<?php include "header.php"; // if(!isset($_SESSION['user_exam'])) { // echo ("<script LANGUAGE='JavaScript'> // window.alert('Please Login...'); // window.location.href='https://tnpsctestbatch.com/login.php'; // </script>"); // exit; // } $subject_query = $pdo->prepare("SELECT * FROM tbl_subject WHERE id=".$_GET['subject_id']); $subject_query->execute(); $subject_result = $subject_query->fetchAll(PDO::FETCH_ASSOC); $subject_total=$subject_query->rowCount(); $topic_query = $pdo->prepare("SELECT * FROM tbl_topic WHERE id=".$_GET['topics_id']); $topic_query->execute(); $topic_result = $topic_query->fetchAll(PDO::FETCH_ASSOC); $topic_total=$topic_query->rowCount(); ?> <style> .form_header_content h2 { font-size: 1.8125rem; background: -webkit-linear-gradient(#36d0dc, #5a87e5); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-weight: 800; } .count_box { display: none !important; } .img-thumbnail { padding: 0.25rem; background-color: #fff; border: 1px solid #dee2e6; border-radius: 0.25rem; max-width: 100%; height: 332px; width: auto; } .multisteps_form { width:100%; border-radius: 20px; background-image:none; background-color: #011f41; min-height: auto; } h1 { color: white; font-size: 24px; } .form_items li { width: 100%; color: #000a38; font-size: 1.3125rem; padding: 10px; background-color: #fbfbfb; margin-top: 1.25rem; cursor: pointer; -webkit-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; } .form_items li:after { display:none; content: ""; width: 1.875rem; height: 1.875rem; top: 50%; left: 14px; -webkit-transform: translateY(-50%); transform: translateY(-50%); position: absolute; border-radius: 100%; border: 2px solid #e2e2e2; background: -webkit-gradient(linear, left top, left bottom, from(#38cedc), to(#5784dd)); background: linear-gradient(#38cedc, #5784dd); } .form_items li label { margin-left: -46px; cursor: pointer; line-height: 20px; } .form_items li.active:before { display: none; } .skippedquiz{ position: absolute; top: 22%; left: 85%; transform: translate(-50%, -50%); width: 285px; height: auto; background-color: white; border-radius: 10px; box-shadow: 0 7px 30px rgba(62, 9, 11, .3); } .skipped_number{ padding: 17px; margin-top: 10px; background-color: orange; color: white; font-weight: 800; } .right_number{ padding: 17px; margin-top: 10px; background-color: green; color: white; font-weight: 800; } .wrong_number{ padding: 17px; margin-top: 10px; background-color: red; color: white; font-weight: 800; } .default_number{ padding: 17px; margin-top: 10px; background-color: black; color: white; font-weight: 800; } .comment-text-sm{ color:white; } .bg-white{ background-color: black !important; } .commented-user{ color:white; } .mt-2 { padding-left: 29px; padding-top: 14px padding-bottom: 14px } </style> <?php if(isset($_SESSION['user_exam'])){ $exam_session_id = $_SESSION['user_exam']['id']; }else{ $exam_session_id = $_COOKIE['users_id']; } if(isset($_SESSION['user_exam'])) { $user_id = $_SESSION['user_exam']['id']; } $date = date('Y-m-d'); ?> <div class="container"> <div class="row"> <div class="col-md-9" > <?php // open page first working this Query start here $first_sql = $pdo->prepare("SELECT tbl_questions.* FROM tbl_questions WHERE tbl_questions.subjet_id=? AND tbl_questions.topic_id=? AND tbl_questions.standard_id=? ORDER BY tbl_questions.id DESC LIMIT 1 "); $first_sql->execute(array($_GET['subject_id'],$_GET['topics_id'],$_GET['standared_id'])); $first_result = $first_sql->fetchAll(PDO::FETCH_ASSOC); $first_total=$first_sql->rowCount(); // open page first working this Query End here $condition = ""; if(isset($_GET['question_id'])){ $condition.="AND tbl_questions.id=".$_GET['question_id']; $question_id = $_GET['question_id']; }else{ $condition.= "ORDER BY tbl_questions.id desc LIMIT 1"; $question_id = $first_result[0]['id']; } $progress_percentage=0; // last submit button query start here $question_sql = $pdo->prepare("SELECT * FROM tbl_questions WHERE tbl_questions.subjet_id=? AND tbl_questions.topic_id=? AND tbl_questions.standard_id=? ORDER BY tbl_questions.id ASC LIMIT 1"); $question_sql->execute(array($_GET['subject_id'],$_GET['topics_id'],$_GET['standared_id'])); $question_result = $question_sql->fetchAll(PDO::FETCH_ASSOC); $question_total=$question_sql->rowCount(); // last submit button query End here // skipped question query start here //if(isset($_GET['question_id'])){ // $skipped_color_total=1; // $skkiped_color_sql = $pdo->prepare("SELECT * FROM tbl_current_affairs_result WHERE type = ? AND question_id=? AND user_id=? AND date=? ORDER BY id"); // $skkiped_color_sql->execute(array($_GET['title_id'],$question_id,$exam_session_id,$date)); // $skipped_color_result = $skkiped_color_sql->fetchAll(PDO::FETCH_ASSOC); // $skipped_color_total=$skkiped_color_sql->rowCount(); //} $skipped_sql = $pdo->prepare("SELECT * FROM tbl_questions WHERE tbl_questions.subjet_id=? AND tbl_questions.topic_id=? AND tbl_questions.standard_id=? ORDER BY tbl_questions.id DESC "); $skipped_sql->execute(array($_GET['subject_id'],$_GET['topics_id'],$_GET['standared_id'])); $skipped_result = $skipped_sql->fetchAll(PDO::FETCH_ASSOC); $skipped_total=$skipped_sql->rowCount(); // skipped question query end here error_log("SELECT *, (SELECT id FROM tbl_questions WHERE id != ".$question_id." AND id < ".$question_id." ORDER BY id DESC LIMIT 1) as next_question_id FROM tbl_questions WHERE tbl_questions.subjet_id=".$_GET['subject_id']." AND tbl_questions.topic_id=".$_GET['topics_id']." AND tbl_questions.standard_id=".$_GET['standared_id']." $condition"); $statement = $pdo->prepare("SELECT *, (SELECT id FROM tbl_questions WHERE id != ".$question_id." AND id < ".$question_id." ORDER BY id DESC LIMIT 1) as next_question_id FROM tbl_questions WHERE tbl_questions.subjet_id=".$_GET['subject_id']." AND tbl_questions.topic_id=".$_GET['topics_id']." AND tbl_questions.standard_id=".$_GET['standared_id']." $condition"); $statement->execute(array($_GET['subject_id'],$_GET['topics_id'],$_GET['standared_id'])); $result = $statement->fetchAll(PDO::FETCH_ASSOC); $total=$statement->rowCount(); $ques_total=$statement->rowCount(); $progress = 100/$total; $i=0; if($total>0){ foreach ($result as $row) { $color_query = $pdo->prepare("SELECT * FROM tbl_subject_result WHERE type=? AND subject_id =? AND topics_id = ? AND standared_id = ? AND question_id=? AND user_id=? AND date=? ORDER BY id DESC "); $color_query->execute(array(1,$_GET['subject_id'],$_GET['topics_id'],$_GET['standared_id'],$row['id'],$exam_session_id,$date)); $color_result = $color_query->fetchAll(PDO::FETCH_ASSOC); $color_total=$color_query->rowCount(); $i++; $progress_percentage+=$progress; ?> <form class="position-relative overflow-hidden mt-5" id="subject_questions_<?=$i?>"> <div class="multisteps_form_panel step" > <div class="multisteps_form"> <!-- Form-content --> <input type="hidden" id="color_question_id" value="<?=$color_result[0]['question_id'] ?>"> <input type="hidden" id="color_user_id" value="<?=$exam_session_id?>"> <input type="hidden" id="color_answer_id" value="<?=$color_result[0]['select_option'] ?>"> <input type="hidden" id="color_type_id" value="<?=$color_result[0]['type'] ?>"> <input type="hidden" id="subject_id" value="<?=$_GET['subject_id'] ?>"> <input type="hidden" id="topics_id" value="<?=$_GET['topics_id']?>"> <input type="hidden" id="standared_id" value="<?=$_GET['standared_id'] ?>"> <span class="question_number text-uppercase mb-3 float-end">QUESTION <?=$i?>/<?=$total?> </span> <div class="progress rounded-pill"> <div class="progress-bar" role="progressbar" style="width: <?=$progress_percentage?>%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div> </div> <h1 class="question_title px-5 py-3 animate__animated animate__fadeInRight animate_25ms"> <?= nl2br($row['questions'])?> </h1> </div> <!-- Form-items --> <div class="form_items ps-5"> <ul class="list-unstyled p-0"> <div class="container"> <div class="row"> <div class="col-md-1"> <li style="background-color: #011f41;"> <label style="padding-left: 12px; color:white;" for="opt_1">A.</label> </li> </div> <div class="col-md-11"> <li class="step_1 ps-5 rounded-pill animate__animated animate__fadeInRight animate_50ms answer_class_<?=$row['id']?>" id="answer_<?=$row['id']?>_A" onclick="ch('A','<?=$row['id']?>','<?=$_SESSION['user_exam']['id']?>');" style="margin-left: -55px;"> <input type="radio" name="stp_1_select_option" value="<?=$row['option_a']?>" class="check"> <label for="opt_1"><?=$row['option_a']?></label> </li> </div> </div> <div class="row"> <div class="col-md-1"> <li style="background-color: #011f41;"> <label style="padding-left: 12px; color:white;" for="opt_1">B.</label> </li> </div> <div class="col-md-11"> <li class="step_1 ps-5 rounded-pill animate__animated animate__fadeInRight animate_100ms answer_class_<?=$row['id']?>" id="answer_<?=$row['id']?>_B" onclick="ch('B','<?=$row['id']?>','<?=$_SESSION['user_exam']['id']?>');" style="margin-left: -55px;"> <input type="radio" name="stp_1_select_option" value="<?=$row['option_b']?>" class="check"> <label for="opt_2"><?=$row['option_b']?></label> </li> </div> </div> <div class="row"> <div class="col-md-1"> <li style="background-color: #011f41;"> <label style="padding-left: 12px; color:white;" for="opt_1">C.</label> </li> </div> <div class="col-md-11"> <li class="step_1 ps-5 rounded-pill animate__animated animate__fadeInRight animate_150ms answer_class_<?=$row['id']?>" id="answer_<?=$row['id']?>_C" onclick="ch('C','<?=$row['id']?>','<?=$_SESSION['user_exam']['id']?>');" style="margin-left: -55px;"> <input type="radio" name="stp_1_select_option" value="<?=$row['option_c']?>" class="check"> <label for="opt_3"><?=$row['option_c']?></label> </li> </div> </div> <div class="row"> <div class="col-md-1"> <li style="background-color: #011f41;"> <label style="padding-left: 12px; color:white;" for="opt_1">D.</label> </li> </div> <div class="col-md-11"> <li class="step_1 ps-5 rounded-pill animate__animated animate__fadeInRight animate_200ms answer_class_<?=$row['id']?>" id="answer_<?=$row['id']?>_D" onclick="ch('D','<?=$row['id']?>','<?=$_SESSION['user_exam']['id']?>');" style="margin-left: -55px;"> <input type="radio" name="stp_1_select_option" value="<?=$row['option_d']?>" class="check"> <label for="opt_4"><?=$row['option_d']?></label> </li> </div> </div> </div> </ul> <div id="view_expain_<?=$row['id']?>"> </div> <div class="collapse" id="collapseExample_<?=$row['id']?>" style="margin-left: -7%;"> <div class="card card-body"> <div class="container"> <div class="row"> <div class="col-md-12"> <div style="display: flex;justify-content: center;"> <?php if($row["video_link"]==""){ ?> <img src="../admin/<?=$row['image']?>" alt="Upload the image" class="img-thumbnail"> <?php } else { ?> <iframe class="embed-responsive-item" src="<?=$row["video_link"]?>" allowfullscreen style="width: 70%;height: 287px;"></iframe> <?php } ?> </div> </div> </div> <div class="row"> <div class="col-md-12"> <center><?=nl2br($row['image_name'])?></center> </div> </div> <div class="row"> <div class="col-md-12"> <?=nl2br($row['explanation'])?> </div> </div> </div> </div> </div> </div> <!-- This is form Sunbmit UI--> <!---------- Form Button Start ----------> <div class="form_btn py-5 text-center"> <br> <?php if($question_result[0]['id']==$_GET['question_id']){ ?> <center style="margin-top: 2%;"> <button type="submit" class="f_btn active text-uppercase rounded-pill text-white" style="color: red;" onclick="finalSubmit()">Submit</button> </center> <?php }else { ?> <button type="button" class="f_btn disable text-uppercase rounded-pill text-white" id="prevBtn" onclick="nextPrevSubjects(-1)"><span><i class="fas fa-arrow-left"></i></span> Last Question</button> <a href="subject-test.php?subject_id=<?=$_GET['subject_id']?>&&topics_id=<?=$_GET['topics_id']?>&&standared_id=<?=$_GET['standared_id']?>&&question_id=<?=$row['next_question_id'] ?>" style="background: #0d6efd;" class="f_btn active text-uppercase rounded-pill text-white" >Next Questions <i class="fas fa-arrow-right"></i></a> <?php } ?> </div> <!---------- Form Button End ----------> <!-- Comment option Start here--> <div class="mb-5"> <div class="d-flex row" > <div class="d-flex flex-column col-md-12" > <div class="d-flex flex-row align-items-center text-left comment-top p-2 bg-white border-bottom px-4"> <h1 style="font-size: 25px; color:white;"> Comments </h1> </div> <div class="coment-bottom bg-white p-2 px-4"> <div class="d-flex flex-row add-comment-section mt-4 mb-4"> <?php $user_name = $_SESSION['user_exam']['name']; $first_letter = $user_name[0]; ?> <span style="display: flex;background-color: blue;border-radius: 50%;font-size: 29px;font-weight: 900;color: white;height: 50px;width: 50px;justify-content: center;"> <?= $first_letter ?> </span> <input type="hidden" id="question_id" value="<?=$row['id']?>" class="form-control mr-3" placeholder="Add comment"> <input type="text" onkeyup="comment_box()" id="user_comment_<?=$row['id']?>"> <input type="hidden" id="exam_type" value="3" class="form-control mr-3" placeholder="Add comment"> <input type="hidden" id="user_id" value="<?php if(isset($_SESSION['user_exam'])){ echo $_SESSION['user_exam']['id']; } ?> "> <span class="btn btn-primary" onclick="commentBtn(<?=$row['id']?>)" >Comment</span> </div> <span id="comment_error" ></span> <div id="comment_list_<?=$row['id']?>"> <?php error_log("SELECT tbl_mock_test_comment.*,tbl_mock_test_comment.id AS comment_id,tbl_students.* FROM tbl_mock_test_comment INNER JOIN tbl_students ON tbl_mock_test_comment.user_id = tbl_students.id WHERE tbl_mock_test_comment.exam_type=3 AND tbl_mock_test_comment.status=1 and tbl_mock_test_comment.question_id=".$row['id']." ORDER BY tbl_mock_test_comment.id DESC"); $comment_sql = $pdo->prepare("SELECT tbl_mock_test_comment.*,tbl_mock_test_comment.id AS comment_id,tbl_students.* FROM tbl_mock_test_comment INNER JOIN tbl_students ON tbl_mock_test_comment.user_id = tbl_students.id WHERE tbl_mock_test_comment.exam_type=3 AND tbl_mock_test_comment.status=1 and tbl_mock_test_comment.question_id=? ORDER BY tbl_mock_test_comment.id DESC"); $comment_sql->execute(array($row['id'])); $comment_result = $comment_sql->fetchAll(PDO::FETCH_ASSOC); $comment_total=$comment_sql->rowCount(); if($comment_total>0){ foreach($comment_result as $comment_datas){ $comment_datas['created_at']; $comment_name =$comment_datas['name']; $first_letters = $comment_name[0]; echo '<div class="commented-section mt-2" style="border: 1px solid black;"> <div class="d-flex flex-row align-items-center commented-user"> <span style="width: 25px;height: 25px;margin-top: -16px;background-color: blue;justify-content: center;display: flex;border-radius: 50%;padding-top: 1px;font-size: 15px; padding-left: 1px;font-weight: 900;">'.$first_letters.'</span> <p style="font-size: 13px;" class="mr-2">'.$comment_datas["name"] . ' </p><span class="dot mb-1"></span><span class="mb-1 ml-2" style="margin-left: 10px;margin-left: 10px;margin-top: -11px;font-size: 13px;"> '.date('d-m-Y', strtotime($comment_datas["created_at"])).'</span></div> <div class="comment-text-sm" style="display: flex;margin-top: -18px;margin-left: 32px;font-size: 21px;"><span>'.$comment_datas["comment"] . '</span></div>'; if(isset($session_id) && $session_id==$comment_datas['user_id']){ echo '<span style="padding: 3px;font-size: 12px;margin-bottom: 10px;background-color: black;border: red;" title="Delete Comments" class="btn btn-primary btn-xs active" onclick="deletecommet('.$comment_datas["comment_id"] .')"> <i class="bi bi-trash"></i> </span> '; } echo '</div>'; } }else{ echo '<span> No Comments </span>'; } ?> </div> <div id="ques_id"></div> </div> </div> </div> </div> <!-- Comment option End here--> </div> </form> <?php } } else{ echo '<span style="color:white;"> No Data Founds </span>'; } ?> </div> <div class="col-md-3"> <div class="skippedquiz"> <h4 style="margin-left: 22px;margin-top: 11px;">Questions</h4> <ul class="list-unstyled p-0" style="overflow-y: scroll;max-height: 347px;"> <li class="step_1 ps-5 rounded-pill animate__animated animate__fadeInRight animate_200ms" style="margin-left: -23px;"> <?php $ri=0; for($rd=1;$rd<=$skipped_total;$rd++){ $result_query = $pdo->prepare("SELECT * FROM tbl_subject_result WHERE type=? AND subject_id =? AND topics_id = ? AND standared_id = ? AND question_id=? AND user_id=? AND date=? ORDER BY id DESC "); $result_query->execute(array(1,$_GET['subject_id'],$_GET['topics_id'],$_GET['standared_id'],$skipped_result[$ri]['id'],$exam_session_id,$date)); $result_result = $result_query->fetchAll(PDO::FETCH_ASSOC); $result_total=$result_query->rowCount(); if($result_total>0){ if($result_result[0]['select_option']==$skipped_result[$ri]['correct_answer']){ $style = 'class="right_number"'; $question_title = 'title="Answered Correctly"'; }else{ $style = 'class="wrong_number"'; $question_title = 'title="Answered Wrongly"'; } } else if($skipped_color_total ==0 && $question_id<$skipped_result[$ri]['id']){ $style = 'class="skipped_number"'; $question_title = 'title="Skipped Question"'; } else{ $style = 'class="default_number"'; $question_title = 'title="Question Not Responded"'; } ?> <a href="subject-test.php?subject_id=<?=$_GET['subject_id']?>&&topics_id=<?=$_GET['topics_id']?>&&standared_id=<?=$_GET['standared_id']?>&&question_id=<?=$skipped_result[$ri]['id']?>" ><label id="colour<?=$skipped_result[$ri]['id']?>" <?= $style; $question_title; ?> onclick="quizPosition(<?=$rd?>)" ><?=str_pad($rd,2,"0",STR_PAD_LEFT)?></label></a> <?php $ri++; } ?> <!--<label title="Skipped Question" class="skipped_number" for="opt_4">02</label> <label title="Skipped Question" class="skipped_number" for="opt_4">03</label> <label title="Answered Correctly"class="right_number" for="opt_4">04</label> <label title="Question Not Responded" class="default_number" for="opt_4">05</label> <label title="Answered Correctly"class="right_number" for="opt_4">06</label> <label title="Question Not Responded" class="default_number" for="opt_4">07</label> <label title="Answered Correctly"class="right_number" for="opt_4">08</label> <label title="Skipped Question" class="skipped_number" for="opt_4">09</label> <label title="Skipped Question" class="skipped_number" for="opt_4">10</label> <label title="Skipped Question" class="skipped_number" for="opt_4">11</label> <label title="Skipped Question" class="skipped_number" for="opt_4">12</label> <label title="Skipped Question" class="skipped_number" for="opt_4">13</label> <label title="Question Not Responded" class="default_number" for="opt_4">14</label> <label title="Answered Correctly"class="right_number" for="opt_4">15</label> <label title="Answered Wrongly" class="wrong_number" for="opt_4">16</label> <label title="Answered Wrongly" class="wrong_number" for="opt_4">17</label> <label title="Answered Wrongly" class="wrong_number" for="opt_4">18</label> <label title="Skipped Question" class="skipped_number" for="opt_4">19</label> <label title="Question Not Responded" class="default_number" for="opt_4">20</label> <label title="Answered Correctly"class="right_number" for="opt_4">21</label> <label title="Answered Correctly"class="right_number" for="opt_4">22</label> <label title="Answered Correctly"class="right_number" for="opt_4">23</label> <label title="Answered Correctly"class="right_number" for="opt_4">24</label> <label title="Skipped Question" class="skipped_number" for="opt_4">25</label> <label title="Skipped Question" class="skipped_number" for="opt_4">26</label>--> </li> </ul> <table style="margin-left: 19px;margin-bottom: 11px;"> <tr> <td><span class="badge bg-secondary" style="background-color: orange !important; color: orange;">4</span> Skipped</td> <td style="padding-left: 13px;"><span class="badge bg-secondary" style="background-color: red !important; color: red;">4</span> Wrong </td> </tr> <tr> <td><span class="badge bg-secondary" style="background-color: black !important; color: black;" >4</span> Not Responded</td> <td style="padding-left: 13px;"><span class="badge bg-secondary" style="background-color: green !important; color: green;">4</span> Correct </td> </tr> </table> </div> </div> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js"></script>--> <script> $(document).ready(function(){ <?php if(isset($_GET['question_id'])){ ?> checkingcolor(); <?php } ?> }); function checkingcolor(){ var answer = $("#color_answer_id").val(); var id = $("#color_question_id").val(); var user_id = $("#color_user_id").val(); ch(answer,id,user_id); } function ch(answer,id,user_id){ subject_id =$("#subject_id").val(); topics_id =$("#topics_id").val(); standared_id =$("#standared_id").val(); var chs='answer_class_'+id; $("."+chs).addClass('disabled_ans'); $.ajax({ url: '../api/get-subject-result.php', type: 'post', dataType: 'json', data: {type:'get_subject_question_res',answer:answer,user_id:user_id,id:id, subject_id:subject_id,topics_id:topics_id,standared_id:standared_id}, success: function (response) { console.log(response); if(response['total_mock']>=3){ window.alert('Please Login'); window.location.href='https://tnpsctestbatch.com/login.php'; } if(response['error']){ var btn=`<p> <button class="btn btn-primary" id="view_btn_`+id+`" type="button" data-bs-toggle="collapse" data-bs-target="#collapseExample_`+id+`" aria-expanded="false" aria-controls="collapseExample"> View Explanation </button> </p>`; $('#view_expain_'+id).append(btn); $('#answer_'+id+'_'+answer).css("background","red"); $('#answer_'+id+'_'+answer).css("color","white"); $('#answer_'+id+'_'+response['correct_ans']).css("background","#06b206"); $('#answer_'+id+'_'+response['correct_ans']).css("color","white"); $('#view_btn_'+id).click(); if(answer == response['correct_ans']){ $('#colour'+id).css("background","green"); $('#colour'+id).css("color","white"); }else{ $('#colour'+id).css("background","red"); $('#colour'+id).css("color","white"); } // colur_orange(id,0) }else{ // console.log('else part'); // $('#view_expain_'+id).empty(); // $('#answer_'+id+'_'+response['correct_ans']).css("background","green"); // $('#answer_'+id+'_'+response['correct_ans']).css("color","white"); } } }); } </script> <style> .disabled_ans{ pointer-events:none; opacity:0.7; } </style> <?php include "footer.php";?> <script> function finalSubmit(){ window.location.href="final-exam.php"; } </script> <script> $('#subject_questions').on('submit', function(e){ console.log("Click And Form Working"); alert("submitted"); e.preventDefault(); $('#loading-div').show(); $('#content-div').hide(); var formData = new FormData(this); formData.append('type', 'add_c_title'); $.ajax({ url: 'add-api/add-question-form.php', type: 'post', dataType: 'json', data: formData, cache: false, contentType: false, processData: false, enctype: 'multipart/form-data', success: function (response) { if(response['status']==200){ alert(response['message']); $("#add_shifts .close").click(); $('#shift_add_form').trigger("reset"); emp_datas(); $('#loading-div').hide(); $('#content-div').show(); }else{ alert(response['message']); $('#loading-div').hide(); $('#content-div').show(); } } }); }); </script> <!--Comment options Start Here--> <script> <?php $comment_script = ' var exam_type = $("#exam_type").val(); var user_id = $("#user_id").val(); $.ajax({ url: "../api/comment.php", type: "post", dataType: "json", data: {type:"comment",exam_type:exam_type,user_commet,user_commet,user_id:user_id,questions_id:question_id}, success: function (response) { console.log(response); if(response["status"]=="100"){ var n = ""; $("#user_comment_"+question_id).val(n); commentlist(question_id); }else{ alert(response["message"]); } } });'; ?> function comment_box(){ <?php if(isset($_SESSION['user_exam'])){ }else{?> comment = $("#user_comment").val(); if(comment==""){ $("#comment_error").empty(); }else{ $("#comment_error").empty(); $("#comment_error").append("<a style='color:red;' href='../login.php'> Click Here to Login </a>"); } <?php } ?> } function commentBtn(question_id){ var user_commet = $("#user_comment_"+question_id).val(); if(user_commet!=""){ <?php if(isset($_SESSION['user_exam'])){ echo $comment_script; }else{ echo 'window.alert("Please Login"); window.location.href="https://tnpsctestbatch.com/login.php";'; } ?> } } function deletecommet(id){ var question_id = $("#question_id").val(); $("#comment_list_"+id).empty(); $.ajax({ url: "../api/comment.php", type: "post", dataType: "json", data: {type:"delete_commet",id:id}, success: function (response) { console.log(response); if(response["status"]=="100"){ commentlist(question_id); }else{ alert(response["message"]); } } }); } function commentlist(question_id){ $("#ques_id").text(question_id); $("#comment_list").empty(); $("#comment_list_"+question_id).empty(); $.ajax({ url: "../api/comment.php", type: "post", data: {type:"questions_with_comment", question_id:question_id,exam_type:"3"}, success: function (response) { $("#comment_list_"+question_id).append(response); // console.log("Musthafa: "+response["comments_list"]); // if(response["comments_list"]){ // $("#comment_list").append(response["comments_list"]); // } } }); } $('#subject_questions').on('submit', function(e){ e.preventDefault(); $('#loading-div').show(); $('#content-div').hide(); var formData = new FormData(this); formData.append('type', 'add_c_title'); $.ajax({ url: 'add-api/add-question-form.php', type: 'post', dataType: 'json', data: formData, cache: false, contentType: false, processData: false, enctype: 'multipart/form-data', success: function (response) { if(response['status']==200){ alert(response['message']); $("#add_shifts .close").click(); $('#shift_add_form').trigger("reset"); emp_datas(); $('#loading-div').hide(); $('#content-div').show(); }else{ alert(response['message']); $('#loading-div').hide(); $('#content-div').show(); } } }); }); </script> <!--Comment options End Here--> <script> function quizPosition(position){ console.log('pos'+position); var j=<?=$ques_total?>; for(var k=1;k<=j;k++){ $('#subject_questions_'+k).hide(); } $('#subject_questions_'+position).show(); showTab(position); } </script>