-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_result.php
150 lines (129 loc) · 5.39 KB
/
add_result.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
$result_status = "active";
include('path.php');
include($ROOTPATH . '/app/controllers/result.php');
adminOnly();
$students = dispSort(['student', 'name', 'asc'], ['class' => $_SESSION['class_assigned']]);
//echo strlen($_SESSION['class_assigned']);
if (strlen($_SESSION['class_assigned']) > 5){
$subjects = dispSort(['subject_combo', 'subject', 'asc'], ['class' => substr($_SESSION['class_assigned'], 0, 7)] );
} else{
$subjects = dispSort(['subject_combo', 'subject', 'asc'], ['class' => substr($_SESSION['class_assigned'], 0, 2)] );
}
//$req_status = "";
//printD(substr('12sc', 0,2));
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php include("lender/head.php"); ?>
<link rel="stylesheet" href="assets/css/sidenav.css">
<link rel="stylesheet" href="assets/css/user.css">
<script src="assets/js/sidenav.js"></script>
<title>Result Management System</title>
<!--The Script for ajx for student data retrieval-->
<script>
function getStuCode(str){
//console.log(str);
if (str.length == 0) {
document.getElementByClass("txtCode").value = "";
return;
} else {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("txtCode").setAttribute('value', this.responseText);
}
}
xmlhttp.open("GET", "ajx_func.php?q="+str, true);
xmlhttp.send();
}
}
</script>
</head>
<body id="body-pd" >
<?php include("lender/sidebar.php"); ?>
<!--Container Main start-->
<div class="height-100 ">
<h5>Add Subject</h5>
<hr>
<div class="col-lg-6 card">
<div class="card-body">
<form action="add_result.php" class="needs-validation" method="post" novalidate>
<div class="form-group">
<label for="">Student Name</label>
<select name="s_name" id="s_name" class="form-control" onchange="getStuCode(this.value)" required>
<option value="" ></option>
<?php foreach($students as $stu): ?>
<option value="<?php echo $stu['name']; ?>" ><?php echo $stu['name']; ?></option>
<?php endforeach; ?>
</select>
<div class="invalid-feedback">
Student Name is required
</div>
</div>
<br>
<div class="form-group">
<label for="">Student Code</label>
<input type="text" name="s_code" class="form-control disable <?php echo $p_status; ?>" id="txtCode" value="" required readonly>
<div class="invalid-feedback">
The result for this student alredy exists
</div>
</div>
<br>
<table class="table table-hover">
<tr>
<th>Subject</th>
<th>Marks</th>
</tr>
<?php foreach($subjects as $sub): ?>
<tr>
<td><?php echo $sub['subject'] ?><input type="hidden" value="<?php echo $sub['subject'] ?>" name="subject[]" ></td>
<?php $req_stat = selectOne('subject', ['s_structure' => $sub['subject']])?>
<td><input type="number" class="form-control req_stat" name="marks[]" <?php echo $req_stat['status'] ?> >
<div class="invalid-feedback">
<?php echo $sub['subject']?> marks is required
</div>
</td>
</tr>
<?php endforeach; ?>
</table>
<br>
<div class="form-group">
<label for="">SUPW Grade</label>
<input type="text" name="supw" class="form-control " value="<?php echo $supw; ?>" required >
<div class="invalid-feedback">
SUPW grade is required
</div>
</div>
<br>
<button class="form-control p-2 btn-primary" type="submit" name="submit">Submit</button>
</form>
</div>
</div>
</div>
<!--Container Main end-->
<script>
// Example starter JavaScript for disabling form submissions if there are invalid fields
(function () {
'use strict'
// Fetch all the forms we want to apply custom Bootstrap validation styles to
var forms = document.querySelectorAll('.needs-validation')
// Loop over them and prevent submission
Array.prototype.slice.call(forms)
.forEach(function (form) {
form.addEventListener('submit', function (event) {
if (!form.checkValidity()) {
event.preventDefault()
event.stopPropagation()
}
form.classList.add('was-validated')
}, false)
})
})()
</script>
</body>
</html>