JezK
Edit File: updatemarks_by_student.php
<?php session_start(); include("menuheader.php"); if (!(in_array(4, $access) && in_array(4, $allow))) echo "<script>location.replace('dashboard.php');</script>"; include_once("school_admin_access_app.php"); $fun = new adminaccess(); $school_id = $_SESSION['child']['log_school_id']; //school_id $academic_id = $_SESSION['child']['choosen_academic_id']; // academic_year_id $user_id = $_SESSION['child']['auth_id']; //user_id $details = $fun->get_classes($school_id, $academic_id); $exam_names = $fun->exam_name_details($school_id, $academic_id); if (isset($_GET['classid']) && isset($_GET['sec_id'])) { $sections = $fun->get_sections($_GET['classid'], $academic_id); $students_list = $fun->get_students2($_GET['classid'], $_GET['sec_id'], $school_id, $academic_id); } if (count($students_list) > 0) { foreach ($students_list as $row) { if ($_GET['student_id'] == $row['student_id']) //student_id { $student .= "<option value='{$row['student_id']}' selected>{$row['student_name']}</option>"; } else { $student .= "<option value='{$row['student_id']}' >{$row['student_name']}</option>"; } } } if ($sections) { foreach ($sections as $row) { if ($_GET['sec_id'] == $row['section_id']) { $secs .= "<option value='{$row['section_id']}' selected>{$row['section_name']}</option>"; } else { $secs .= "<option value='{$row['section_id']}' >{$row['section_name']}</option>"; } } } if ($exam_names) { foreach ($exam_names as $row) { if ($_GET['exname_id'] == $row['exam_id']) { $exmnamesss .= "<option value='{$row['exam_id']}' selected>{$row['exam_name']}</option>"; } else { $exmnamesss .= "<option value='{$row['exam_id']}' >{$row['exam_name']}</option>"; } } } if ($details) { foreach ($details as $row) { if ($_GET['classid'] == $row['class_id']) { $classes_list .= "<option value='{$row['class_id']}' selected>{$row['class_name']}</option>"; } else { $classes_list .= "<option value='{$row['class_id']}' >{$row['class_name']}</option>"; } } } if (isset($_GET['classid']) && isset($_GET['exname_id']) && isset($_GET['sec_id']) && isset($_GET['student_id'])) { $subjs = $fun->get_subjects_lists($_GET['classid'], $_GET['sec_id'], $_GET['exname_id'], $_GET['student_id'], $school_id, $academic_id); $grade = $fun->getthisStudentgrade($_GET['classid'], $_GET['sec_id'], $_GET['exname_id'], $_GET['student_id'], $school_id, $academic_id); } ?> <style> #nav { margin: auto; width: 751px !important; padding-left: 0; padding-right: 0; list-style: none; background: #18b88d; } #nav li { display: inline-block; margin: 0 auto; text-align: center; } #nav li a { display: inline-block; padding: 7px 0; text-align: center; text-decoration: none; color: #FFFFFF; margin: auto; } #nav li:hover, li:active { background-color: rgb(54, 120, 102); width: 90px; } #nav li.selected { background: rgb(54, 120, 102); } .table-condensed>thead>tr>th, .table-condensed>tbody>tr>th, .table-condensed>tfoot>tr>th, .table-condensed>thead>tr>td, .table-condensed>tbody>tr>td, .table-condensed>tfoot>tr>td { padding: 3px; } select { width: 62px !important; background-color: #FFF; border: 1px solid #CCC; } table, thead, tr, tbody, th, td { text-align: center; } @media screen and (min-width:1600px) { .media_1600 { margin-left: 54px !important; } .media_16001 { margin-left: 3px !important; } } </style> <body style="overflow-x: hidden;"> <div class="row" style="margin-top: 30px;"> <div class="col-md-9 text-left" style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:24px; margin-left:20px;"><img src="images/exams-black.png" title=" Examinations" style="font-size: 24px;" /> Examinations </div> </div> <br> <div class="menuu"> <ul id="nav" class="margn_auto"> <li style="border-right:1px solid #FFFFFF;width:150px; text-align:center;margin-left:-3px;font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="exam_schedule.php"><img src="images/exam-nemes_white.png" title="Exam Names" style="margin-right:5px;" />Exam Names</a></li> <li style="width:150px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="exam_schedule.php"><img src="images/exam-schedule_white.png" title="Exam Schedule" style="margin-right:5px;" />Exam Schedule</a></li> <li class="selected" style="border-right:1px solid #FFFFFF; width:150px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="marksof_student.php"><img src="images/add-marks_white.png" title="Add Marks" style="margin-right:5px;" />Add Marks</a></li> <li style="border-right:1px solid #FFFFFF; width:150px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="addgrades_tostudent.php"><img src="images/set-grades_white.png" title="Set Grades/Ranks" style="margin-right:5px;" />Set Grades/Ranks</a></li> <li style="width:148px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="Report_card.php"><img src="images/report-card_white.png" title="Report Card" style="margin-right:5px;" />Report Card</a></li> </ul> </div> <div class="row" style="margin-top: 30px;margin-bottom:10px;"> <div class="col-md-9 text-left" style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:20px; margin-left:20px;"> <img src="images/add-marks_Black.png" title="Update Marks Student Wise" style="font-size: 24px;" /> Update Marks Student Wise </div> <div class="col-md-2 text-center" style="float:right;"> <!--<button type="button" onClick="location.href='#'" class="btn btn-default" style="margin-right:20px;font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;" data-toggle="modal" data-target="#pwd </div>Modal"> Upload </button>--> </div> <form class="form-horizontal" style="margin-top:20px; " method="post" action="save_student_marks.php"> <div class="box-body" style="background-color:#fff; padding: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; "> <div class=""> <div class="form-group row col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 col-md-offset-1 text-md-end"> <b style="color:#666666; ">Exam Name</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-select" id="examnames" name="examnames" style="height:29px; width:295px!important;font-size:12px;" tabindex="1"> <option value='0' selected>Select Exam Name</option> <?php echo $exmnamesss; ?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_examname" style="color:#990000;"></div> <!--- end error--> </div> </div> </div> <div class=""> <div class="form-group row col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 col-md-offset-1 text-md-end"> <b style="color:#666666; ">Class</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-select" id="classes" name="classes" style="height:29px; width:295px!important;font-size:12px;" tabindex="2"> <option value='0' selected>Select Class</option> <?php echo $classes_list; ?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_class" style="color:#990000;"></div> <!--- end error--> </div> </div> </div> <div class=""> <div class="form-group row col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 col-md-offset-1 text-md-end"> <b style="color:#666666; ">Section</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-select" id="sections" name="sections" style="height:29px; width:295px!important;font-size:12px;" tabindex="3"> <option value='0' selected>Select Section</option> <?php echo $secs; ?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_section" style="color:#990000;"></div> <!--- end error--> </div> </div> </div> <div class=""> <div class="form-group row col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 col-md-offset-1 text-md-end"> <b style="color:#666666; ">Student </b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-select" id="student" name="stdid" style="height:29px; width:295px!important;font-size:12px;" tabindex="4"> <option value='0' selected>Select Student</option> <?php echo $student; ?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_student" style="color:#990000;"></div> <!--- end error--> </div> </div> </div> <div class=""> <div class="form-group row col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 col-md-offset-1 text-md-end"> <b style="color:#666666; ">Set Grade/Rank</b><span style="color:#FF0000; margin:2px;"></span> </div> <div class="col-md-7"> <input type=" text" class="form-control" id="grade" name="grade" maxlength="10" style="height:29px; width:295px!important;font-size:12px;" value="<?php if ($grade != '0') echo $grade; ?>" tabindex="5"> <!-- if there is an error--> <div class="col-md-10" id="err_grade" style="color:#990000;"></div> <!--- end error--> </div> </div> </div> </div> <!--dynamic content Start--> <div class="row ms-5"> <div class="col-md-10 d-md-flex"> <div class="col-md-2 text-center"><b>Subject Name</b></div> <div class="col-md-2 text-end"><b>Total Marks</b></div> <div class="col-md-2 text-end"><b>Secured Marks</b></div> <div class="col-md-2 text-end"><b>Status</b></div> </div> </div><br /> <?php if ($subjs) { $i = 0; $j = 5; $countmarks = 0; foreach ($subjs as $row) { $i++; $maxtotal = "maxtotal" . $i; $securedmark = "securedmark" . $i; if ($row['marks_secured'] != '') $totmarks = $row['marks_secured']; else $totmarks = 0; $countmarks = $countmarks + $totmarks; $wx = $j + 1; $xx = $j + 2; $xy = $j + 3; $xz = $j + 4; ?> <div class="row ms-5"> <div class="col-md-10 row"> <div class="col-md-2 text-center"> <input type="hidden" name="student[]" value="<?= $row['subject_id'] ?>"> <input type="text" class="time form-control" value="<?= $row['subject_name'] ?>" name="subjects[]" readonly style="width:120px!important; height:25px;margin-left:21px;" tabindex="<?= $wx ?>"><br /><br /> </div> <div class="col-md-2 text-center"> <input type="text" class="time form-control" name="subjmarks[]" id="<?= $maxtotal ?>" value="<?= $row['total_marks'] ?>" style="width:120px!important; height:25px;margin-left:41px;" readonly tabindex="<?= $xx ?>"><br /><br /> </div> <div class="col-md-2 text-center"> <input type="text" class="add_marks form-control" maxlength="5" value="<?= $row['marks_secured'] ?>" onblur="sumofmarks(this.value,'<?= $row['total_marks'] ?>','<?= $securedmark ?>');" name="marks[]" id="<?= $securedmark ?>" tabindex="<?= $xy ?>" style="width:120px!important;height:25px;margin-left:40px;"><br /><br /> <!-- if there is an error--> <div class="col-md-4"></div> <div class="col-md-8 media_1600" id="err_marks<?= $i ?>" style="color: rgb(153, 0, 0);font-size: 12px;margin-top: -15px;text-align: left;margin-left: 35px;width: 179px;"></div> <!--- end error--> </div> <div class="col-md-2 text-center"> <select style="width: 120px!important;margin-left:59px;height:25px;" class="add_status " id="status<?= $row['subject_id'] ?>" name="status[]" tabindex="<?= $xz ?>"> <option value="0" selected>Status</option> <option value="1" <?php if ($row['status'] == '1') { echo 'selected'; } ?>>P</option> <option value="2" <?php if ($row['status'] == '2') { echo 'selected'; } ?>>F</option> </select><br /><br /> <!-- if there is an error--> <div class="col-md-10 media_16001" id="err_status<?= $i ?>" style="color:#990000;display:none; width:250px;font-size:12px;margin-top:-17px;">Please enter Status</div> <!--- end error--> </div> </div> </div> <?php $j = $j + 4; } } ?> <!--dynamic content End--> <div class="col-md-1"></div> </div> <div class="form-group"> <div class="col-md-12" align="center"> <!--< if($subjs) { ?>--> <span style="margin-left:-305px;"><b style="margin-left:-90px;">Total Secured Marks </b><input type="text" id="tsecured" name="tsecured" readonly value="<?= $countmarks; ?>" maxlength="5" style="width:123px;height:25px;margin-left:30px" tabindex="<? if ($_GET[student_id] != '') echo $xz + 1; else echo '6'; ?>"></span><br><br> <button type="submit" onclick="return validation();" class="btn btn-outline-secondary custom-button-width .navbar-right btnclr" tabindex="<? if ($_GET[student_id] != '') echo $xz + 1; else echo '7'; ?>" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px; ">Update</button> <button type="button" onclick="location.href='marksof_student.php'" class="btn btn-outline-secondary custom-button-width .navbar-right btnclr" tabindex="<? if ($_GET[student_id] != '') echo $xz + 1; else echo '8'; ?>" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px; ">Cancel</button> <!--< } ?>--> </div> </div> </form> <script type="text/javascript" language="javascript" src="Excel/media/js/jquery.js"></script> <script type="text/javascript" language="javascript" src="Excel/media/js/jquery.dataTables.js"></script> <script type="text/javascript" language="javascript" src="Excel/js/dataTables.tableTools.js"></script> <script type="text/javascript" language="javascript" src="Excel/examples/resources/syntax/shCore.js"></script> <script type="text/javascript" language="javascript" src="Excel/examples/resources/demo.js"></script> <script type="text/javascript" language="javascript" class="init"> $(document).ready(function() { $('#myTable').dataTable({ dom: 'T<"clear">lfrtip', "oLanguage": { "sSearch": "" }, tableTools: { "aButtons": [ "xls", { "sExtends": "pdf", "sPdfOrientation": "landscape", "sPdfMessage": "Your custom message would go here." }, "print" ] } }); $('div.dataTables_filter input').attr('placeholder', 'Search'); $("#classes").change(function() { $("#err_class").text(""); if ($('#classes').val() == 0) { var section_option = '<option value="0">Select Section</option>'; $("#sections").html(section_option); var student_option = '<option value="0" selected="selected">Select Student</option>'; $("#student").html(student_option); $("#err_class").text("Please select Class"); $("#err_class").show(); return false; } else { var x = $('#classes').val(); $.ajax({ url: "ajaxcalls_app.php", type: "POST", data: "mode=" + "choose_class" + "&data=" + x, success: function(result) { var result2 = eval("(" + result + ")"); var section_option = '<option value="0">Select Section</option>'; for (var i = 0; i < result2.length; i++) { section_option += '<option value="' + result2[i].section_id + '">' + result2[i].section_name + '</option>'; } $("#sections").html(section_option); }, error: function(e) { } }); } }); $("#sections").change(function() { $("#err_section").text(""); if ($("#sections").val() == 0) { var student_option = '<option value="0" selected="selected">Select Student</option>'; $("#student").html(student_option); $("#err_section").text("Please select Section"); $("#err_section").show(); return false; } else { var cls = $("#classes").val(); var sec_id = $("#sections").val(); var stud_id = $("#student").val(); var exam_id = $("#examnames").val(); $.ajax({ url: "ajaxcalls_app.php", type: "POST", data: "mode=" + "students" + "&class_id=" + cls + "§ion_id=" + sec_id, success: function(result) { var result2 = eval("(" + result + ")"); var section_option = '<option value="0" selected="selected">Select Student</option>'; for (var i = 0; i < result2.length; i++) { section_option += '<option value="' + result2[i].student_id + '">' + result2[i].student_name + '</option>'; } $("#student").html(section_option); }, error: function(e) { } }); } }); $("#student").change(function() { $("#err_class").text(""); $("#err_section").text(""); $("#err_examname").text(""); $("#err_student").text(""); if ($("#classes").val() == 0) { $("#err_class").text("Please select Class"); $("#err_class").show(); return false; } else if ($("#sections").val() == 0) { $("#err_section").text("Please select Section"); $("#err_section").show(); return false; } else if ($("#examnames").val() == 0) { $("#err_examname").text("Please select Exam"); $("#err_examname").show(); return false; } else if ($("#student").val() == 0) { $("#err_student").text("Please select Student"); $("#err_student").show(); return false; } else { var cls = $("#classes").val(); var sec_id = $("#sections").val(); var stud_id = $("#student").val(); var exam_id = $("#examnames").val(); window.location.href = "updatemarks_by_student.php?classid=" + cls + "&exname_id=" + exam_id + "&sec_id=" + sec_id + "&student_id=" + stud_id; } }); $("#examnames").change(function() { $("#err_examname").text(""); if ($("#examnames").val() == 0) { $("#err_examname").text("Please select Exam"); $("#err_examname").show(); return false; } else load_data(); }); }); </script> <script> function load_data() { if ($("#classes").val() != 0 && $("#sections").val() != 0 && $("#student").val() != 0 && $("#examnames").val() != 0) { var cls = $("#classes").val(); var sec_id = $("#sections").val(); var stud_id = $("#student").val(); var exam_id = $("#examnames").val(); window.location.href = "updatemarks_by_student.php?classid=" + cls + "&exname_id=" + exam_id + "&sec_id=" + sec_id + "&student_id=" + stud_id; } } //////////////////////////////////////////////// function validation() { $("#err_examname").text(""); $("#err_class").text(""); $("#err_section").text(""); $("#err_subject").text(""); $("#err_student").text(""); $("#err_grade").text(""); var regexp = /^[a-zA-Z0-9-_+ ]+$/; var grd = document.getElementById("grade").value; if (grd != '') { if (!regexp.test(grd)) { $("#err_grade").text("Please enter a valid Grade"); $("#err_grade").show(); return false; } } var letters = /^[A-Za-z0-9+-]+$/; if ($("#examnames").val() == 0) { $("#err_examname").text("Please select Exam"); $("#err_examname").show(); return false; } else if ($("#classes").val() == 0) { $("#err_class").text("Please select Class"); $("#err_class").show(); return false; } else if ($("#sections").val() == 0) { $("#err_section").text("Please select Section"); $("#err_section").show(); return false; } else if ($("#student").val() == 0) { $("#err_student").text("Please select Student"); $("#err_student").show(); return false; } var subjects = document.getElementsByName("subjects[]"); var secumarks = document.getElementsByName("marks[]"); var status = document.getElementsByName("status[]"); var subjmarks = document.getElementsByName("subjmarks[]"); var k = 0; var p = 1; for (var i = 0; i < subjects.length; i++) { if ((secumarks[i].value != "") || (status[i].value != "0")) { $("#err_status" + p).text(''); $("#err_marks" + p).text(''); if (secumarks[i].value == "") { $('#securedmark' + p).focus(); $("#err_marks" + p).text('Please enter Secured Marks'); $("#err_marks" + p).show(); return false; } else if (Number(secumarks[i].value) > Number(subjmarks[i].value)) { alert('Secured marks should be less than or equal to Total marks'); $('#securedmark' + p).focus(); //$("#err_marks"+p).text('Secured marks should be less than or Equal to Total marks'); //$("#err_marks"+p).show(); return false; } else if (status[i].value == "0") { document.getElementById(status[i].id).focus(); $("#err_status" + p).text('Please select Status'); $("#err_status" + p).show(); return false; } } if ((secumarks[i].value != "") && (status[i].value != "0") && (subjmarks[i].value != "")) { k = 1; } p++; } if (k == 0) { alert("Please enter marks for at least one Subject"); return false; } var rank = document.getElementById('grade').value; var gt = $("#tsecured").val(); var re = /[0-9]/ if (gt == "") { alert("Please enter Total Secured Marks"); return false; } else if (!re.test(gt)) { alert("Please enter a valid number for Total Numbers"); $("#tsecured").val(''); return false; } if (rank != "") { if (!letters.test(rank)) { alert('Please enter a valid Grade/Rank'); document.getElementById('grade').value = ""; document.getElementById('grade').focus(); return false; } } } ////////////////////////////////////////////////////// function sumofmarks(value, total_marks, id) { var tot = 0; var id_new = id.replace('securedmark', ""); if (isNaN(value)) { $("#err_marks" + id_new).text('Please enter a valid number for Secured Marks'); $("#err_marks" + id_new).show(); $("#" + id).val(''); $("#" + id).focus(); return false; } else { $(".add_marks").each(function(i) { if (($(this).val() != "") && (!isNaN($(this).val()))) { tot = Number(tot) + Number($(this).val()); } }); $("#tsecured").val(tot); $("#err_marks" + id_new).text(''); } } </script> <script> $(document).ready(function() { $('#myTable').dataTable(); }); </script> </body> </html>