-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotas.php
184 lines (163 loc) · 5.18 KB
/
notas.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
require_once "conex.php";
if (!isset($_SESSION)) session_start();
$nivel_necessario = 2; // e 3 em alguns casos;
if (!isset($_SESSION['UsuarioID']) OR ($_SESSION['UsuarioNivel'] != $nivel_necessario && $_SESSION['UsuarioNivel'] != 3)) {
session_destroy();
header("Location: index.php"); exit;
}
if($_SESSION['UsuarioNivel'] == 3 && !isset($_SESSION['iddisc']) && !isset($_SESSION['idtur'])){
$_SESSION['iddisc'] = $_POST['iddisc'];
$_SESSION['idtur'] = $_POST['idtur'];
}
if(isset($_POST['iddisc'])){
$_SESSION['iddisc'] = $_POST['iddisc'];
}
if($_SESSION['UsuarioNivel'] == 3){
$link = 3;
}else{
$link = 2;
}
$turma = selectTurmaById($_SESSION['idtur']);
$turNotas = selectAluByTurdisc($_SESSION['idtur'],$_SESSION['iddisc']);
?>
<html>
<head>
<title><?=$turma['tur_nome']?> - Notas</title>
<link rel="stylesheet" type="text/css" href="css/estilonotas.css">
<meta charset="utf-8">
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$(function($){
$("#voltar").click(function(){
var linka = "<?php echo($link); ?>";
if(linka==3){
window.location='bturma.php';
}else {
window.location='professores.php';
}
});
});
function JArredonda(valor){ //Aproxima valores decimais para 0.5 ou inteiro dependendo do numero;
number = String(parseFloat(valor).toFixed(1));
alg = number.split(".");
var v = alg[1]/10;
if(v<0.3){
v = 0;
}
if(v>=0.3 && v<0.8){
v = 0.5;
}
if(v>=0.8){
v = 1;
}
if(valor == ""){
return "";
}else{
valor= parseInt(valor) + v;
return valor.toFixed(1);
}
}
function media(id){
var tupla = id.split("-");
var linha = parseInt(tupla[1]);
var cond = 0;
var media = 0;
var valorTemp = document.getElementById(id).value; //Guarda o valor temporario da caixa de texto que está sendo alterada;
document.getElementById(id).value = JArredonda(parseFloat(valorTemp)); //Arredonda o valor da caixa de texto que foi alterada;
for(j=1; j<4; j++){
if(document.getElementById("Mn"+j+"-"+linha).value != ""){ //Laço para calcular a média das 3 notas da tupla em (linha);
media+=parseFloat(document.getElementById("Mn"+j+"-"+linha).value);
//cond+=1;
}
//if(cond == 3){
x = media/3;
if((parseFloat(x) == parseInt(x)) && !isNaN(x)){ //Verifica se o número é inteiro;
document.getElementById("media-"+tupla[1]).value = x.toFixed(1);
}else{
document.getElementById("media-"+tupla[1]).value = JArredonda(x);
}
//}
}
}
var j = 0;
var num = 0;
var trime = 1;
document.addEventListener('keydown',function(e){
var KeyCode = e.keyCode;
var tuplas = <?=$_SESSION['nTuplas'];?>;
if (KeyCode==9) {
event.keyCode=0;
event.returnValue=false;
num+=1;
if(num <= tuplas){
document.getElementById("Mn"+trime+"-"+num).select();
if(num == tuplas){
trime+=1;
num = 0;
}
if(trime == 4){
trime = 1;
}
}
}
});
</script>
</head>
<body>
<header class="header-fixed">
<div class="header-limiter">
<h1><a href="#" style="pointer-events: none;"><img src="img/faetec1.png"></a></h1>
<nav>
<a href="logout.php" class="sair">Sair</a>
</nav>
</div>
<h1 style="padding-left: 55px;"> <?=$turma['tur_nome'] ?> </h1>
</header>
<h2></h2>
<br>
<center>
<div id="corpo">
<form method="post" action="salvarNotas.php" >
<table class="container">
<thead>
<th>Matricula</th>
<th>Aluno</th>
<th>1° Trimestre</th>
<th>2° Trimestre</th>
<th>3° Trimestre</th>
<th>Média Final</th>
</thead>
<tbody>
<?php
$cont = 0;
foreach($turNotas as $notas){
$cont+=1;
echo "<tr>";
?>
<td><input type="text" class="transparente" name="mat-<?=$cont?>" readonly='true' value='<?=$notas[0]?>'></td>
<td><input type="text" class="transparente" readonly='true' value='<?=$notas[1]?>'></td>
<td><input type="text" class="trimestre" name="n1-<?=$cont?>" id="Mn1-<?=$cont?>" onchange="media(this.id)" value='<?=$notas[2]?>' autofocus></td>
<td><input type="text" class="trimestre" name="n2-<?=$cont?>" id="Mn2-<?=$cont?>" onchange="media(this.id)" value='<?=$notas[3]?>'></td>
<td><input type="text" class="trimestre" name="n3-<?=$cont?>" id="Mn3-<?=$cont?>" onchange="media(this.id)" value='<?=$notas[4]?>'></td>
<td><input type="text" class="transparente" readonly='true' id="media-<?=$cont?>" value='<?=$notas[5]?>'></td>
<?php echo "</tr>";
}
?>
</tbody>
</table>
<br>
<td><input type="button" id="voltar" value="Voltar"></td>
<td><input type="submit" class="btn" value="Salvar"></td>
</form>
</div>
</center>
<footer class="footer-distributed">
<div class="footer-center">
<center><img src="img/logo1.png"></center>
<br>
<center><p class="footer-company-name">Octa © 2017</p></center>
</div>
</footer>
</body>
</html>