Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/EjercitarWeb/WebContent/iniciar_curso.jsp
blob: da1248daee55c3b73f396f297dd437ec4fdad3a2 (plain)
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
185
186
187
188
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Iniciar Curso</title>
	<!-- Styles -->
	<link rel="stylesheet" href="css/themes/smoothness/jquery-ui-1.10.4.css" />
	<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css" />
	<link rel="stylesheet" href="css/ejercitar-base.css" />
	<link rel="stylesheet" href="css/jquery.multiselect.css" />
	<style type="text/css">
		.table {
			margin-bottom: 0px;
		}
	</style>
	<!-- Scripts -->
	<script type="text/javascript" src="js/smoothness/jquery-1.10.2.js"></script>
	<script type="text/javascript" src="js/smoothness/jquery-ui-1.10.4.custom.js"></script>
	<script type="text/javascript" src="lib/bootstrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="js/jquery.validate.min.js"></script>
	<script type="text/javascript" src="js/validaciones.js"></script>
	<script type="text/javascript" src="js/multiselect/jquery.multiselect.min.js"></script>
	<script type="text/javascript" src="js/multiselect/jquery.multiselect.es.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#accordion").accordion({
				collapsible: true,
				heightStyle: "fill",
				header: "h3"
			});
		 });
		$(function() {
			$("#accordion-resizer").resizable({
				resize: function() {
					$("#accordion").accordion( "refresh" );
				}
			});
		});
	</script>

	<script type="text/javascript">
		var totalsValue = {};

		/* Calcula el total de pesos para los temas */
		function totalTemas(dato) {
			var total = 0;
			var datoInt = parseInt(dato);
			for (var i = 0; i < datoInt; i++) {
				var id = "peso_"+i;
				num = $("#" + id).val();
				num = !num? 0 : num;
				total = parseFloat(total) + parseFloat(num);
			}
	 		$("#td-total-temas").text(total);
			if (total !=  100) {
				$("#h-temas").removeClass("text-success");
				$("#h-temas").addClass('text-danger');
				$("#tr-total-temas").attr('class', 'danger');
			} else if (total == 100) {
				$("#h-temas").removeClass("text-danger");
				$("#h-temas").addClass('text-success');
				$("#tr-total-temas").attr('class', 'success');
			}
	 		totalsValue['td-total-temas'] = total;
			validateFormFn();
		}		
		/* Calcula el total de pesos para los conceptos */
		function totalConceptos(dato, id_tema) {
			total = 0;
			var datoInt = parseInt(dato);
			for (var i = 0; i < datoInt; i++) {
				var id = "cpeso_" + i + "_t_" + id_tema;
				num = $("#" + id).val();
				num = !num? 0 : num;
				total = parseFloat(total) + parseFloat(num);
			}
			$("#td-total-concepto-" + id_tema).text(total);
			if (total !=  100) {
				$("#h-concepto-" + id_tema).removeClass("text-success");
				$("#h-concepto-" + id_tema).addClass('text-danger');
				$("#tr-total-concepto-" + id_tema).attr('class', 'danger');
			} else if (total == 100) {
				$("#h-concepto-" + id_tema).removeClass("text-danger");
				$("#h-concepto-" + id_tema).addClass('text-success');
				$("#tr-total-concepto-" + id_tema).attr('class', 'success');
			}
	 		totalsValue['td-total-concepto-' + id_tema] = total;
			validateFormFn();
		}

		function validateFormFn() {
			var isValid = true;
			$.each(totalsValue, function(idTotal, value) {
				if (isValid) {
					isValid = value == 100;
				}
				return isValid;
			});
			if (isValid) {
				$("#btn-comenzar").removeAttr("disabled");
			} else {
				$("#btn-comenzar").attr("disabled", "disabled");
			}
		}
	</script>
</head>
<body class="e-body">
	<%@page import="java.util.List" import="model.Tema" import="model.Concepto" import="model.Asignatura"%>
	<div class="container e-viewport">
		<div class="row e-panel-header">
			<div class="e-logo"></div>
		</div>
		<div class="row e-panel-center">
			<div class="e-panel-bd panel panel-primary">
				<div class="panel-heading">Iniciar Curso</div>
				<div class="panel-body">
					<form class="form-horizontal" role="form" method="post" name="form">
						<div id="accordion">
							<%List<Tema> temaList = (List<Tema>) request.getAttribute("lista_temas");%>
							<h3 class="text-danger" id="h-temas" style="font-weight: bold;">Temas</h3>
							<table class="table table-condensed">
								<thead>
									<tr>
										<th>Tema</th>
										<th>Peso</th>
									</tr>
								</thead>
								<tbody>
									<% int cont = 0; %>
									<%for (Tema tema: temaList) {%>
										<tr>
											<td style="vertical-align: middle;"><%= tema.getNombre() %></td>
											<td><input class="form-control" type="text" name="peso_<%=cont %>" id="peso_<%=cont %>" onChange='totalTemas(<%=temaList.size() %>)' value="0"></td>
										</tr>
						 				<% cont = cont + 1; %>
									<%}%>
									<tr class="danger" id="tr-total-temas" style="font-weight: bold;">
										<td style="vertical-align: middle;">Total</td>
										<td id="td-total-temas" style="vertical-align: middle;">0</td>
									</tr>
								</tbody>
							</table>
							<script type="text/javascript">totalsValue['td-total-temas'] = 0;</script>
							<%int cant_tema = 0;%>
							<%for (Tema tema: temaList) {%>
								<%int cant_concepto = 0;%>
								<h3 class="text-danger" id="h-concepto-<%=cant_tema%>" style="font-weight: bold;">Tema: <%= tema.getNombre() %></h3>
								<table class="table table-condensed">
									<thead>
										<tr>
											<th>Concepto</th>
											<th>Peso</th>
										</tr>
									</thead>
									<tbody>
										<%for (Concepto concepto: tema.getConceptoList()) {%>
											<tr>
												<td style="vertical-align: middle;"><%= concepto.getNombre()%></td>
												<td><input class="form-control" type="text" name="cpeso_<%=cant_concepto %>_t_<%=cant_tema%>"  id="cpeso_<%=cant_concepto %>_t_<%=cant_tema%>" onChange='totalConceptos(<%=tema.getConceptoList().size() %>,<%=cant_tema%>)' value="0"></td>
											</tr>
											<%cant_concepto = cant_concepto + 1;%>
										<%}%>
										<tr class="danger" id="tr-total-concepto-<%=cant_tema %>" style="font-weight: bold;">
											<td style="vertical-align: middle;">Total</td>
											<td id="td-total-concepto-<%=cant_tema%>">0</td>
										</tr>
									</tbody>
								</table>
								<script type="text/javascript">totalsValue['td-total-concepto-<%=cant_tema%>'] = 0;</script>
								<%cant_tema = cant_tema + 1;%>
							<%}%>
						</div>
						<button id="btn-comenzar" class="btn btn-default btn-primary" style="margin-top: 10px;" type="submit" name="Submit" disabled="disabled">
					    	<span class="e-button-text">Comenzar</span>
				    	</button>
					</form>
				</div>
			</div>
		</div>
		<div class="row e-panel-footer">
			<span>Ejercitar: Un Modelo de aprendizaje asistido por computadora</span>
			<span>Cecilia Godoy - Samuel Reyes. Ingeniería en Informática</span>
			<span>Facultad Politécnica - Universidad Nacional de Asunción</span>
		</div>
	</div>
</body>
</html>