public async Task <ActionResult> TakeQuiz(Guid?Id) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Evaluation evaluation = await Db.Evaluations.Where(x => x.Id == Id).FirstOrDefaultAsync <Evaluation>(); if (evaluation == null) { return(HttpNotFound()); } EvaluationBL evaluationBL = new EvaluationBL(); if (evaluationBL.UserCanBeEvaluated(evaluation, CurrentUser.Id)) { DateTime dateTime = evaluation.EvaluationUsers.Where(x => x.UserId == CurrentUser.Id).FirstOrDefault().TakenDate; dateTime = dateTime.ToUniversalTime(); TimeZoneInfo estTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Venezuela Standard Time"); dateTime = TimeZoneInfo.ConvertTimeFromUtc(dateTime, estTimeZone); ViewBag.InitialDateTime = DateTime.UtcNow; TimeZoneInfo estTimeZone2 = TimeZoneInfo.FindSystemTimeZoneById("Venezuela Standard Time"); ViewBag.InitialDateTime = TimeZoneInfo.ConvertTimeFromUtc(ViewBag.InitialDateTime, estTimeZone2); await Db.SaveChangesAsync(); return(View("TakeQuiz", evaluationBL.GetQuiz(evaluation, dateTime))); } await Db.SaveChangesAsync(); Flash.Error("Error", "Esta evaluación ya ha sido presentada o Ha ocurrido un error al intentar presentar la evaluación"); return(RedirectToAction("Evaluations")); }
private void btnGrabar_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; if (!ValidarIngreso()) { EvaluationBL objBL_Evaluation = new EvaluationBL(); EvaluationBE objEvaluation = new EvaluationBE(); objEvaluation.IdEvaluation = IdEvaluation; objEvaluation.NameEvaluation = txtDescripcion.Text; objEvaluation.FlagState = true; objEvaluation.Login = Parametros.strUsuarioLogin; objEvaluation.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objEvaluation.IdCompany = Parametros.intEmpresaId; if (pOperacion == Operacion.Nuevo) { objBL_Evaluation.Inserta(objEvaluation); } else { objBL_Evaluation.Actualiza(objEvaluation); } this.Close(); } } catch (Exception ex) { Cursor = Cursors.Default; XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void tlbMenu_DeleteClick() { try { Cursor = Cursors.WaitCursor; if (XtraMessageBox.Show("Be sure to delete the record?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (!ValidarIngreso()) { EvaluationBE objE_Evaluation = new EvaluationBE(); objE_Evaluation.IdEvaluation = int.Parse(gvEvaluation.GetFocusedRowCellValue("IdEvaluation").ToString()); objE_Evaluation.Login = Parametros.strUsuarioLogin; objE_Evaluation.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objE_Evaluation.IdCompany = Parametros.intEmpresaId; EvaluationBL objBL_Evaluation = new EvaluationBL(); objBL_Evaluation.Elimina(objE_Evaluation); XtraMessageBox.Show("The record was successfully deleted.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); Cargar(); } } Cursor = Cursors.Default; } catch (Exception ex) { Cursor = Cursors.Default; XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public async Task <ActionResult> Evaluations() { var evaluationQuery = Db.Users.Where(z => z.Id == CurrentUser.Id || z.EvaluationUsers.Select(c => c.UserId).Contains(CurrentUser.Id)).Select(x => x.Section).SelectMany(y => y.Evaluations); var evaluations = await evaluationQuery.Where(x => x.EvaluationUsers.Select(t => t.Active).Contains(true) || x.LimitDate >= DateTime.Today).ToListAsync(); EvaluationBL evaluationBL = new EvaluationBL(); return(View(evaluationBL.GetEvaluationStudent(evaluations, CurrentUser.Id))); }
void ExportarExcel(string filename) { Excel._Application xlApp; Excel._Workbook xlLibro; Excel._Worksheet xlHoja; Excel.Sheets xlHojas; xlApp = new Excel.Application(); filename = Path.Combine(Directory.GetCurrentDirectory(), "Excel\\Evaluation.xlsx"); xlLibro = xlApp.Workbooks.Open(filename, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); xlHojas = xlLibro.Sheets; xlHoja = (Excel._Worksheet)xlHojas[1]; Cursor.Current = Cursors.WaitCursor; try { int Row = 6; int Secuencia = 1; List <EvaluationBE> lstEvaluation = null; lstEvaluation = new EvaluationBL().ListaTodosActivo(Parametros.intEmpresaId); if (lstEvaluation.Count > 0) { xlHoja.Shapes.AddPicture(Path.Combine(Directory.GetCurrentDirectory(), "Logo.jpg"), Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, 1, 1, 100, 60); foreach (var item in lstEvaluation) { xlHoja.Cells[Row, 1] = item.IdEvaluation; xlHoja.Cells[Row, 2] = item.NameEvaluation; Row = Row + 1; Secuencia = Secuencia + 1; } } xlLibro.SaveAs("C:\\Excel\\Evaluation.xlsx", Excel.XlFileFormat.xlWorkbookDefault, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Excel.XlSaveAsAccessMode.xlExclusive, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); xlLibro.Close(true, Missing.Value, Missing.Value); xlApp.Quit(); Cursor.Current = Cursors.Default; BSUtils.OpenExcel("C:\\Excel\\Evaluation.xlsx"); //XtraMessageBox.Show("It was imported correctly \n The file was generated C:\\Excel\\Evaluation.xlsx", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { xlLibro.Close(false, Missing.Value, Missing.Value); xlApp.Quit(); Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public async Task <ActionResult> TakeQuiz(QuizViewModel quiz) { Evaluation evaluation = await Db.Evaluations.Where(x => x.Id == quiz.Id).FirstOrDefaultAsync(); if (evaluation == null) { return(HttpNotFound()); } EvaluationBL evaluationBL = new EvaluationBL(); try { List <Answer> answers = null; if (quiz.RunoutTime) { quiz.Questions = quiz.Questions.Where(x => x.Options != null).ToList(); answers = quiz.Questions.Select(x => new Answer { QuestionOptionId = x.Options.SelectedAnswer }).ToList(); } if (ModelState.IsValid) { if (evaluationBL.UserCanBeEvaluated(evaluation, CurrentUser.Id, answers)) { evaluationBL.TakeQuiz(evaluation, quiz, CurrentUser.Id); await Db.SaveChangesAsync(); Flash.Success("Ok", "El Quiz ha sido presentado exitosamente"); QuizViewModel reviewedQuiz = evaluationBL.ReviewQuiz(evaluation, CurrentUser.Id); return(View("ReviewQuiz", reviewedQuiz)); } else { await Db.SaveChangesAsync(); Flash.Error("Error", "Ha caducado el tiempo para presentar el quiz"); return(RedirectToAction("Evaluations")); } } else { Flash.Error("Error", "Ha ocurrido un error al intentar presentar la evaluación"); return(RedirectToAction("Evaluations")); } } catch (Exception) { Flash.Error("Error", "Ha ocurrido un error al intentar presentar la evaluación"); return(RedirectToAction("Evaluations")); } }
public async Task <ActionResult> ReviewQuiz(Guid Id) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Evaluation evaluation = await Db.Evaluations.Where(x => x.Id == Id).FirstOrDefaultAsync <Evaluation>(); if (evaluation == null) { return(HttpNotFound()); } EvaluationBL evaluationBL = new EvaluationBL(); QuizViewModel reviewedQuiz = evaluationBL.ReviewQuiz(evaluation, CurrentUser.Id); return(View("ReviewQuiz", reviewedQuiz)); }
private void frmManEvaluationEdit_Load(object sender, EventArgs e) { if (pOperacion == Operacion.Nuevo) { this.Text = "Evaluation - New"; } else if (pOperacion == Operacion.Modificar) { this.Text = "Evaluation - Update"; EvaluationBE objE_Evaluation = null; objE_Evaluation = new EvaluationBL().Selecciona(IdEvaluation); if (objE_Evaluation != null) { txtDescripcion.Text = objE_Evaluation.NameEvaluation.Trim(); } } txtDescripcion.Select(); }
public async Task <ActionResult> ReviewQuiz(string userId, Guid evaluationId) { if (evaluationId == null || String.IsNullOrEmpty(userId)) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Evaluation evaluation = await Db.Evaluations.Where(x => x.Id == evaluationId).FirstOrDefaultAsync <Evaluation>(); if (evaluation == null) { return(HttpNotFound()); } User user = await UserManager.FindByIdAsync(userId); if (user == null) { return(HttpNotFound()); } EvaluationBL evaluationBL = new EvaluationBL(); QuizViewModel reviewedQuiz = evaluationBL.ReviewQuiz(evaluation, userId, true); return(View(reviewedQuiz)); }