protected void Page_Load(object sender, EventArgs e) { ECurso curso = (ECurso)Session[Constantes.CURSO_SELECCIONADO_PARA_EDITAR_TEMAS]; if (curso == null) { Response.Redirect("~/Vistas/Home.aspx"); } ETema tema = (ETema)Session[Constantes.TEMA_SELECCIONADO]; Session["existenciaExamen"] = false; if (tema != null) { etiquetaCrearTema.Text = "Editar tema"; cajaTitulo.Text = tema.Titulo; GestionExamen gestorExamenes = new GestionExamen(); EExamen examen = gestorExamenes.GetExamen(tema); bool existenciaExamen = false; if (examen != null) { existenciaExamen = true; } Session["existenciaExamen"] = existenciaExamen; } }
public EEjecucionExamen GetEjecucion(EUsuario usuario, ETema tema) { EExamen examen = GetExamen(tema); EEjecucionExamen ejecucion = GetEjecucion(examen, usuario); return(ejecucion); }
public ETema GetTema(EEjecucionExamen ejecucion) { GestionExamen gestorExamenes = new GestionExamen(); EExamen examen = gestorExamenes.GetExamen(ejecucion.IdExamen); ETema tema = GetTema(examen.IdTema); return(tema); }
public List <EUsuario> GetUsuariosExamen(ETema tema) { EExamen examen = db.TablaExamenes.Where(x => x.IdTema == tema.Id).First(); List <EEjecucionExamen> ejecuciones = db.TablaEjecucionExamen.Where(x => x.IdExamen == examen.Id).ToList(); List <EUsuario> usuarios = new List <EUsuario>(); foreach (EEjecucionExamen ejecucion in ejecuciones) { usuarios.Add(GetUsuario(ejecucion.NombreUsuario)); } return(usuarios); }
public List <ETema> GetTemasConExamen(ECurso curso) { List <ETema> temas = db.TablaTemas.Where(x => x.IdCurso == curso.Id).OrderBy(x => x.Id).ToList(); List <ETema> temasConExamen = new List <ETema>(); foreach (ETema tema in temas) { EExamen examen = db.TablaExamenes.Where(x => x.IdTema == tema.Id).FirstOrDefault(); if (examen != null) { temasConExamen.Add(tema); } } return(temasConExamen); }
public List <ETema> GetTemasExamenResueltos(EUsuario usuario, ECurso curso) { List <ETema> temasConExamen = GetTemasConExamen(curso); List <ETema> temas = new List <ETema>(); foreach (ETema tema in temasConExamen) { GestionExamen gestorExamenes = new GestionExamen(); EExamen examen = gestorExamenes.GetExamen(tema); EEjecucionExamen ejecucion = db.TablaEjecucionExamen.Where(x => x.IdExamen == examen.Id && x.NombreUsuario.Equals(usuario.NombreDeUsuario)).FirstOrDefault(); if (ejecucion != null) { temas.Add(tema); } } return(temas); }
protected void Page_Load(object sender, EventArgs e) { usuario = (EUsuario)Session[Constantes.USUARIO_LOGEADO]; ECurso curso = (ECurso)Session[Constantes.CURSO_SELECCIONADO]; if (usuario == null) { Response.Redirect("~/Vistas/Home.aspx"); } else if (usuario != null && usuario.Rol.Equals(Constantes.ROL_ADMIN)) { Response.Redirect("~/Vistas/Home.aspx"); } else { ETema tema = (ETema)Session[Constantes.TEMA_SELECCIONADO]; if (tema == null) { Response.Redirect("~/Vistas/Home.aspx"); } etiquetaTitulo.Text = tema.Titulo; LiteralControl informacion = new LiteralControl(); informacion.Text = tema.Informacion; panelContenido.Controls.Add(informacion); GestionExamen gestorExamenes = new GestionExamen(); EExamen examen = (EExamen)gestorExamenes.GetExamen(tema); Session[Constantes.EXAMEN_A_REALIZAR] = examen; if (examen != null) { if (!usuario.NombreDeUsuario.Equals(curso.Creador)) { if (gestorExamenes.GetEjecucion(examen, (EUsuario)Session[Constantes.USUARIO_LOGEADO]) != null) { Label etiquetaExamenRealizado = new Label(); etiquetaExamenRealizado.Text = "Ya ha realizado el examen"; panelExamen.Controls.Add(etiquetaExamenRealizado); } else { if (examen != null) { if (DateTime.Now < examen.FechaFin) { ASP.controles_examenes_elaboracionexamen_ascx examenARealizar = new ASP.controles_examenes_elaboracionexamen_ascx(); panelExamen.Controls.Add(examenARealizar); } else { Label etiquetaTiempo = new Label(); etiquetaTiempo.Text = "Ya pasó la fecha y hora establecidas para realizar el examen"; panelExamen.Controls.Add(etiquetaTiempo); } } } } } } }
public void ResponderExamen(EExamen examen, EUsuario usuario, string respuestas) { EEjecucionExamen ejecucion = new EEjecucionExamen(); ejecucion.NombreUsuario = usuario.NombreDeUsuario; ejecucion.IdExamen = examen.Id; ejecucion.FechaEjecucion = System.DateTime.Now; ejecucion.Respuestas = respuestas; List <int> notas = new List <int>(); List <EPregunta> preguntas = GetPreguntas(examen); JArray respuestasExamenJson = JArray.Parse(respuestas); foreach (EPregunta pregunta in preguntas) { JArray respuestasPreguntaJson = (JArray)respuestasExamenJson[preguntas.IndexOf(pregunta)]["Respuestas"]; if (respuestasPreguntaJson.Count == 0) { notas.Add(0); } else { if (pregunta.TipoPregunta.Equals("Múltiple con única respuesta")) { int indiceRespuesta = Int32.Parse(respuestasPreguntaJson[0].ToString()); List <ERespuesta> respuestasPregunta = GetRespuestas(pregunta); ERespuesta respuestaCorrecta = respuestasPregunta.Where(x => x.Estado == true).First(); int indiceRespuestaCorrecta = respuestasPregunta.IndexOf(respuestaCorrecta); if (indiceRespuesta == indiceRespuestaCorrecta) { notas.Add(50); } else { notas.Add(0); } } else if (pregunta.TipoPregunta.Equals("Múltiple con múltiple respuesta")) { List <int> indicesRespuestas = new List <int>(); foreach (JToken respuesta in respuestasPreguntaJson) { indicesRespuestas.Add(Int32.Parse(respuesta.ToString())); } List <ERespuesta> respuestasPregunta = GetRespuestas(pregunta); List <ERespuesta> respuestasCorrectas = respuestasPregunta.Where(x => x.Estado == true).ToList(); List <int> indicesRespuestasCorrectas = new List <int>(); foreach (ERespuesta respuesta in respuestasCorrectas) { if (respuesta.Estado) { indicesRespuestasCorrectas.Add(respuestasCorrectas.IndexOf(respuesta)); } } List <int> subNotas = new List <int>(); foreach (ERespuesta respuesta in respuestasCorrectas) { subNotas.Add(0); } foreach (int indice in indicesRespuestas) { if (indicesRespuestasCorrectas.Contains(indice)) { int posicionIndice = indicesRespuestasCorrectas.IndexOf(indice); subNotas[posicionIndice] = 50; } } int nota = (int)subNotas.Average(); notas.Add(nota); } else { notas.Add(-1); } } } string notasJson = JsonConvert.SerializeObject(notas); ejecucion.Calificacion = notasJson; Base.Insertar(ejecucion); }
public EExamen GetExamen(ETema tema) { EExamen examen = db.TablaExamenes.Where(x => x.IdTema == tema.Id).FirstOrDefault(); return(examen); }
public EExamen GetExamen(int id) { EExamen examen = db.TablaExamenes.Where(x => x.Id == id).First(); return(examen); }
public List <EPregunta> GetPreguntas(EExamen examen) { List <EPregunta> preguntas = db.TablaPreguntas.Where(x => x.IdExamen == examen.Id).OrderBy(x => x.Id).ToList(); return(preguntas); }
public EEjecucionExamen GetEjecucion(EExamen examen, EUsuario usuario) { EEjecucionExamen ejecucion = db.TablaEjecucionExamen.Where(x => x.IdExamen == examen.Id && x.NombreUsuario.Equals(usuario.NombreDeUsuario)).FirstOrDefault(); return(ejecucion); }
public void EnviarExamen(string examen, string fecha, string hora, string minuto, string tituloTema, string contenidoTema, int idCurso) { ETema tema = new ETema(); contenidoTema = contenidoTema.Replace("\n\n", ""); contenidoTema = contenidoTema.Replace("\n", ""); tema.IdCurso = idCurso; tema.Titulo = tituloTema; tema.Informacion = contenidoTema; Base.Insertar(tema); EExamen examenCreado = new EExamen(); examenCreado.IdTema = tema.Id; int dia = Int32.Parse(fecha.Split('/')[0]); int mes = Int32.Parse(fecha.Split('/')[1]); int anio = Int32.Parse(fecha.Split('/')[2]); DateTime fechaFinalizacion = new DateTime(anio, mes, dia, Int32.Parse(hora), Int32.Parse(minuto), 0); examenCreado.FechaFin = fechaFinalizacion; Base.Insertar(examenCreado); JArray preguntasJson = JArray.Parse(examen); foreach (JToken preguntaJson in preguntasJson) { EPregunta pregunta = new EPregunta(); pregunta.IdExamen = examenCreado.Id; pregunta.TipoPregunta = preguntaJson["tipoPregunta"].ToString(); pregunta.Pregunta = preguntaJson["pregunta"].ToString(); pregunta.Porcentaje = Int32.Parse(preguntaJson["porcentaje"].ToString()); Base.Insertar(pregunta); if (pregunta.TipoPregunta.Equals("Múltiple con única respuesta")) { List <JToken> respuestasJson = preguntaJson["respuestas"].ToList(); int indiceRespuestaCorrecta = Int32.Parse(preguntaJson["respuestaMarcada"].ToString()); foreach (JToken respuestaJson in respuestasJson) { ERespuesta respuesta = new ERespuesta(); respuesta.IdPregunta = pregunta.Id; respuesta.Respuesta = respuestaJson.ToString(); if (respuestasJson.IndexOf(respuestaJson) == indiceRespuestaCorrecta) { respuesta.Estado = true; } else { respuesta.Estado = false; } Base.Insertar(respuesta); } } if (pregunta.TipoPregunta.Equals("Múltiple con múltiple respuesta")) { List <JToken> respuestasJson = preguntaJson["respuestas"].ToList(); List <JToken> indicesRespuestasMarcadasJson = preguntaJson["respuestasMarcadas"].ToList(); List <int> indicesRespuestasMarcadas = new List <int>(); foreach (JToken indiceRespuestaMarcadaJson in indicesRespuestasMarcadasJson) { indicesRespuestasMarcadas.Add(Int32.Parse(indiceRespuestaMarcadaJson.ToString())); } foreach (JToken respuestaJson in respuestasJson) { ERespuesta respuesta = new ERespuesta(); respuesta.IdPregunta = pregunta.Id; respuesta.Respuesta = respuestaJson.ToString(); if (indicesRespuestasMarcadas.Contains(respuestasJson.IndexOf(respuestaJson))) { respuesta.Estado = true; } else { respuesta.Estado = false; } Base.Insertar(respuesta); } } } }
protected void Page_Load(object sender, EventArgs e) { bool isCalificando = (bool)Session[Constantes.CALIFICACION_EXAMEN]; usuario = (EUsuario)Session[Constantes.USUARIO_SELECCIONADO]; GestionExamen gestorExamenes = new GestionExamen(); tema = (ETema)Session[Constantes.TEMA_SELECCIONADO_PARA_CALIFICAR_EXAMEN]; EExamen examen = gestorExamenes.GetExamen(tema); ejecucion = gestorExamenes.GetEjecucion(examen, usuario); bool isExamenCalificado = gestorExamenes.IsExamenCalificado(ejecucion); if (!isCalificando || isExamenCalificado) { botonCalificar.Visible = false; } JArray respuestasExamenJson = JArray.Parse(ejecucion.Respuestas); preguntas = gestorExamenes.GetPreguntas(examen); int minutos = examen.FechaFin.Minute; string textoMinutos = minutos.ToString(); if (minutos < 10) { textoMinutos = textoMinutos.Insert(0, "0"); } etiquetaFecha.Text = "Fecha límite " + examen.FechaFin.Day + "/" + examen.FechaFin.Month + "/" + examen.FechaFin.Year + " a las " + examen.FechaFin.Hour + ":" + textoMinutos; foreach (EPregunta pregunta in preguntas) { Panel panelPregunta = new Panel(); Table tablaPregunta = new Table(); tablaPregunta.BackColor = Color.FromArgb(195, 201, 209); tablaPregunta.Width = Unit.Percentage(60); tablaPregunta.Style.Add("border-radius", "10px"); if (pregunta.TipoPregunta.Equals("Múltiple con única respuesta")) { List <ERespuesta> respuestas = gestorExamenes.GetRespuestas(pregunta); TableRow filaPregunta = new TableRow(); TableCell celdaPregunta = new TableCell(); Label textoPregunta = new Label(); textoPregunta.Text = pregunta.Pregunta; celdaPregunta.Controls.Add(textoPregunta); celdaPregunta.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaPregunta.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaPregunta.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaPregunta.Cells.Add(celdaPregunta); tablaPregunta.Rows.Add(filaPregunta); int indicePregunta = preguntas.IndexOf(pregunta); JToken respuestaPreguntaJson = respuestasExamenJson[indicePregunta]["Respuestas"]; int indiceRespuestaMarcada; if (respuestaPreguntaJson[0].ToString() == "") { indiceRespuestaMarcada = -1; } else { indiceRespuestaMarcada = Int32.Parse(respuestaPreguntaJson[0].ToString()); } ERespuesta respuestaCorrecta = respuestas.Where(x => x.Estado == true).First(); int indiceRespuestaCorrecta = respuestas.IndexOf(respuestaCorrecta); foreach (ERespuesta respuesta in respuestas) { TableRow fila = new TableRow(); TableCell celda = new TableCell(); Button botonMarcar = new Button(); botonMarcar.Width = 16; botonMarcar.Height = 16; botonMarcar.Enabled = false; System.Web.UI.WebControls.Image indicadorCorrecto = null; if (respuestas.IndexOf(respuesta) == indiceRespuestaMarcada) { botonMarcar.BackColor = Color.Black; indicadorCorrecto = new System.Web.UI.WebControls.Image(); indicadorCorrecto.Width = 16; indicadorCorrecto.Height = 16; if (indiceRespuestaCorrecta == indiceRespuestaMarcada) { indicadorCorrecto.ImageUrl = "Correcto.png"; } else { indicadorCorrecto.ImageUrl = "Incorrecto.png"; } } Label textoRespuesta = new Label(); textoRespuesta.Text = respuesta.Respuesta; celda.Controls.Add(botonMarcar); celda.Controls.Add(textoRespuesta); if (indicadorCorrecto != null) { celda.Controls.Add(indicadorCorrecto); } celda.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celda.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celda.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); fila.Cells.Add(celda); tablaPregunta.Rows.Add(fila); } TableRow filaRespuestaCorrecta = new TableRow(); TableCell celdaRespuestaCorrecta = new TableCell(); Label textoRespuestaCorrecta = new Label(); textoRespuestaCorrecta.Text = "Respuesta correcta: " + respuestaCorrecta.Respuesta; celdaRespuestaCorrecta.Controls.Add(textoRespuestaCorrecta); celdaRespuestaCorrecta.Controls.Add(textoRespuestaCorrecta); celdaRespuestaCorrecta.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaRespuestaCorrecta.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaRespuestaCorrecta.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaRespuestaCorrecta.Cells.Add(celdaRespuestaCorrecta); tablaPregunta.Rows.Add(filaRespuestaCorrecta); TableRow filaPorcentaje = new TableRow(); TableCell celdaPorcentaje = new TableCell(); Label textoPorcentaje = new Label(); textoPorcentaje.Text = "Porcentaje: " + pregunta.Porcentaje + "%"; celdaPorcentaje.Controls.Add(textoPorcentaje); celdaPorcentaje.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaPorcentaje.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaPorcentaje.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaPorcentaje.Cells.Add(celdaPorcentaje); tablaPregunta.Rows.Add(filaPorcentaje); TableRow filaNota = new TableRow(); TableCell celdaNota = new TableCell(); Label textoNota = new Label(); JArray notasJson = JArray.Parse(ejecucion.Calificacion); JToken notaJson = notasJson[indicePregunta]; textoNota.Text = "Nota: " + notaJson.ToString(); celdaNota.Controls.Add(textoNota); celdaNota.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaNota.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaNota.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaNota.Cells.Add(celdaNota); tablaPregunta.Rows.Add(filaNota); } else if (pregunta.TipoPregunta.Equals("Múltiple con múltiple respuesta")) { List <ERespuesta> respuestas = gestorExamenes.GetRespuestas(pregunta); TableRow filaPregunta = new TableRow(); TableCell celdaPregunta = new TableCell(); Label textoPregunta = new Label(); textoPregunta.Text = pregunta.Pregunta; celdaPregunta.Controls.Add(textoPregunta); celdaPregunta.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaPregunta.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaPregunta.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaPregunta.Cells.Add(celdaPregunta); tablaPregunta.Rows.Add(filaPregunta); int indicePregunta = preguntas.IndexOf(pregunta); JToken respuestasPreguntasJson = respuestasExamenJson[indicePregunta]["Respuestas"]; List <int> indicesRespuestasMarcadas = new List <int>(); foreach (JToken respuestaPreguntaJson in respuestasPreguntasJson) { indicesRespuestasMarcadas.Add(Int32.Parse(respuestaPreguntaJson.ToString())); } List <ERespuesta> respuestasCorrectas = respuestas.Where(x => x.Estado == true).ToList(); List <int> indicesRespuestasCorrectas = new List <int>(); foreach (ERespuesta respuesta in respuestasCorrectas) { indicesRespuestasCorrectas.Add(respuestas.IndexOf(respuesta)); } foreach (ERespuesta respuesta in respuestas) { TableRow fila = new TableRow(); TableCell celda = new TableCell(); CheckBox checkBox = new CheckBox(); checkBox.Enabled = false; System.Web.UI.WebControls.Image indicadorCorrecto = null; if (indicesRespuestasMarcadas.Contains(respuestas.IndexOf(respuesta))) { checkBox.Checked = true; indicadorCorrecto = new System.Web.UI.WebControls.Image(); indicadorCorrecto.Width = 16; indicadorCorrecto.Height = 16; if (indicesRespuestasCorrectas.Contains(respuestas.IndexOf(respuesta))) { indicadorCorrecto.ImageUrl = "Correcto.png"; } else { indicadorCorrecto.ImageUrl = "Incorrecto.png"; } } Label textoRespuesta = new Label(); textoRespuesta.Text = respuesta.Respuesta; celda.Controls.Add(checkBox); celda.Controls.Add(textoRespuesta); if (indicadorCorrecto != null) { celda.Controls.Add(indicadorCorrecto); } celda.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celda.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celda.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); fila.Cells.Add(celda); tablaPregunta.Rows.Add(fila); } TableRow filaRespuestasCorrectas = new TableRow(); TableCell celdaRespuestasCorrectas = new TableCell(); Label textoRespuestasCorrectas = new Label(); string respuestasCorrectasString = ""; foreach (ERespuesta respuesta in respuestasCorrectas) { respuestasCorrectasString += respuesta.Respuesta + ", "; } respuestasCorrectasString = respuestasCorrectasString.Substring(0, respuestasCorrectasString.Length - 2); textoRespuestasCorrectas.Text = "Respuestas correctas: " + respuestasCorrectasString; celdaRespuestasCorrectas.Controls.Add(textoRespuestasCorrectas); celdaRespuestasCorrectas.Controls.Add(textoRespuestasCorrectas); celdaRespuestasCorrectas.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaRespuestasCorrectas.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaRespuestasCorrectas.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaRespuestasCorrectas.Cells.Add(celdaRespuestasCorrectas); tablaPregunta.Rows.Add(filaRespuestasCorrectas); TableRow filaPorcentaje = new TableRow(); TableCell celdaPorcentaje = new TableCell(); Label textoPorcentaje = new Label(); textoPorcentaje.Text = "Porcentaje: " + pregunta.Porcentaje + "%"; celdaPorcentaje.Controls.Add(textoPorcentaje); celdaPorcentaje.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaPorcentaje.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaPorcentaje.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaPorcentaje.Cells.Add(celdaPorcentaje); tablaPregunta.Rows.Add(filaPorcentaje); TableRow filaNota = new TableRow(); TableCell celdaNota = new TableCell(); Label textoNota = new Label(); JArray notasJson = JArray.Parse(ejecucion.Calificacion); JToken notaJson = notasJson[indicePregunta]; textoNota.Text = "Nota: " + notaJson.ToString(); celdaNota.Controls.Add(textoNota); celdaNota.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaNota.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaNota.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaNota.Cells.Add(celdaNota); tablaPregunta.Rows.Add(filaNota); } else if (pregunta.TipoPregunta.Equals("Abierta")) { TableRow filaPregunta = new TableRow(); TableCell celdaPregunta = new TableCell(); Label textoPregunta = new Label(); textoPregunta.Text = pregunta.Pregunta; celdaPregunta.Controls.Add(textoPregunta); celdaPregunta.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaPregunta.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaPregunta.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaPregunta.Cells.Add(celdaPregunta); tablaPregunta.Rows.Add(filaPregunta); TextBox campoRespuesta = new TextBox(); campoRespuesta.TextMode = TextBoxMode.MultiLine; campoRespuesta.Style.Add(HtmlTextWriterStyle.Width, "95%"); campoRespuesta.Style.Add(HtmlTextWriterStyle.Height, "100px"); campoRespuesta.Enabled = false; JArray respuestasJsonExamen = JArray.Parse(ejecucion.Respuestas); JToken respuestasJsonPregunta = respuestasJsonExamen[preguntas.IndexOf(pregunta)]; campoRespuesta.Text = respuestasJsonPregunta["Respuestas"][0].ToString(); TableRow filaCampo = new TableRow(); TableCell celdaCampo = new TableCell(); celdaCampo.Controls.Add(campoRespuesta); celdaCampo.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaCampo.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaCampo.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaCampo.Controls.Add(celdaCampo); tablaPregunta.Rows.Add(filaCampo); TableRow filaPorcentaje = new TableRow(); TableCell celdaPorcentaje = new TableCell(); Label textoPorcentaje = new Label(); textoPorcentaje.Text = "Porcentaje: " + pregunta.Porcentaje + "%"; celdaPorcentaje.Controls.Add(textoPorcentaje); celdaPorcentaje.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaPorcentaje.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaPorcentaje.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaPorcentaje.Cells.Add(celdaPorcentaje); tablaPregunta.Rows.Add(filaPorcentaje); TableRow filaNota = new TableRow(); TableCell celdaNota = new TableCell(); DropDownList desplegableNota = new DropDownList(); ListItem itemInicial = new ListItem(); itemInicial.Value = "Nota"; itemInicial.Text = itemInicial.Value; desplegableNota.Items.Add(itemInicial); for (int nota = 0; nota <= 50; nota++) { ListItem item = new ListItem(); item.Value = nota.ToString(); item.Text = item.Value; desplegableNota.Items.Add(item); } JArray notasJson = JArray.Parse(ejecucion.Calificacion); JToken notaJson = notasJson[preguntas.IndexOf(pregunta)]; int notaPregunta = Int32.Parse(notaJson.ToString()); Label textoNota = new Label(); textoNota.Text = "Nota: " + notaJson.ToString(); if (notaPregunta == -1) { celdaNota.Controls.Add(desplegableNota); desplegablesNotas.Add(desplegableNota); } else { celdaNota.Controls.Add(textoNota); } celdaNota.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaNota.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaNota.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaNota.Cells.Add(celdaNota); if (isCalificando && !isExamenCalificado) { tablaPregunta.Rows.Add(filaNota); } } else { TableRow filaPregunta = new TableRow(); TableCell celdaPregunta = new TableCell(); Label textoPregunta = new Label(); textoPregunta.Text = pregunta.Pregunta; celdaPregunta.Controls.Add(textoPregunta); celdaPregunta.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaPregunta.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaPregunta.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaPregunta.Cells.Add(celdaPregunta); tablaPregunta.Rows.Add(filaPregunta); TableRow filaArchivo = new TableRow(); TableCell celdaArchivo = new TableCell(); LinkButton hiperEnlaceArchivo = new LinkButton(); JArray respuestasJsonExamen = JArray.Parse(ejecucion.Respuestas); JToken respuestasJsonPregunta = respuestasJsonExamen[preguntas.IndexOf(pregunta)]; JArray notasJson = JArray.Parse(ejecucion.Calificacion); JToken notaJson = notasJson[preguntas.IndexOf(pregunta)]; int notaPregunta = Int32.Parse(notaJson.ToString()); if (notaPregunta == -1) { hiperEnlaceArchivo.Text = respuestasJsonPregunta["Respuestas"][0].ToString(); hiperEnlaceArchivo.Click += new EventHandler(VerArchivo); celdaArchivo.Controls.Add(hiperEnlaceArchivo); celdaArchivo.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaArchivo.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaArchivo.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaArchivo.Cells.Add(celdaArchivo); tablaPregunta.Rows.Add(filaArchivo); } TableRow filaPorcentaje = new TableRow(); TableCell celdaPorcentaje = new TableCell(); Label textoPorcentaje = new Label(); textoPorcentaje.Text = "Porcentaje: " + pregunta.Porcentaje + "%"; celdaPorcentaje.Controls.Add(textoPorcentaje); celdaPorcentaje.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaPorcentaje.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaPorcentaje.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaPorcentaje.Cells.Add(celdaPorcentaje); tablaPregunta.Rows.Add(filaPorcentaje); TableRow filaNota = new TableRow(); TableCell celdaNota = new TableCell(); DropDownList desplegableNota = new DropDownList(); ListItem itemInicial = new ListItem(); itemInicial.Value = "Nota"; itemInicial.Text = itemInicial.Value; desplegableNota.Items.Add(itemInicial); for (int nota = 0; nota <= 50; nota++) { ListItem item = new ListItem(); item.Value = nota.ToString(); item.Text = item.Value; desplegableNota.Items.Add(item); } Label textoNota = new Label(); textoNota.Text = "Nota: " + notaJson.ToString(); if (notaPregunta == -1) { celdaNota.Controls.Add(desplegableNota); desplegablesNotas.Add(desplegableNota); } else { celdaNota.Controls.Add(textoNota); } celdaNota.Style.Add(HtmlTextWriterStyle.PaddingLeft, "3%"); celdaNota.Style.Add(HtmlTextWriterStyle.PaddingTop, "1%"); celdaNota.Style.Add(HtmlTextWriterStyle.PaddingBottom, "1%"); filaNota.Cells.Add(celdaNota); if (isCalificando && !isExamenCalificado) { tablaPregunta.Rows.Add(filaNota); } } panelPregunta.Controls.Add(tablaPregunta); Literal saltoDeLinea = new Literal(); saltoDeLinea.Text = "<br>"; panelContenido.Controls.Add(panelPregunta); panelContenido.Controls.Add(saltoDeLinea); } etiquetaNota.Text = "Nota: " + GetNotaPonderada(); }