public IActionResult JawabSoalAkademik(JawabSoalAkademikModel model) { int akunId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)); var jawaban = new HasilTes() { AkunPendaftaranId = akunId, SoalId = model.SoalId, PertanyaanId = model.PertanyaanId, Jawaban = model.JawabanCalonSiswa }; _ujianService.SaveAnswerAkademik(jawaban); return(RedirectToAction("JawabSoalAkademik", "Ujian", new { soalId = model.SoalId, qid = model.Tujuan })); }
public IActionResult SelesaiUjianAkademik(JawabSoalAkademikModel model) { int akunId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)); var jawaban = new HasilTes() { AkunPendaftaranId = akunId, SoalId = model.SoalId, PertanyaanId = model.PertanyaanId, Jawaban = model.JawabanCalonSiswa }; _ujianService.SaveAnswerAkademik(jawaban); _ujianService.FinishUjianAkademik(akunId, model.SoalId); return(View()); }
public IActionResult JawabSoalAkademik(int soalId, int?qid) { int akunId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)); bool?isDone = _ujianService.IsDone(akunId, soalId); if (isDone == null) { return(RedirectToAction(nameof(Index))); } else if ((bool)isDone) { return(RedirectToAction(nameof(SelesaiUjianAkademik))); } else { var detailUjian = _ujianService.GetUjian(akunId, soalId); var listPertanyaan = _soalPenerimaanService.GetDetailSoal(soalId).ListPertanyaan.ToList(); int pertanyaanIndex; if (qid == null) { pertanyaanIndex = 0; } else { pertanyaanIndex = listPertanyaan.FindIndex(x => x.Id == qid); } var pertanyaan = listPertanyaan[pertanyaanIndex]; var model = new JawabSoalAkademikModel() { NoPertanyaan = pertanyaanIndex + 1, MapPertanyaan = listPertanyaan.Select(x => x.Id).ToList(), BatasWaktu = detailUjian.WaktuBerakhir, PertanyaanId = pertanyaan.Id, SoalId = pertanyaan.SoalId, OpsiA = pertanyaan.OpsiA, OpsiB = pertanyaan.OpsiB, OpsiC = pertanyaan.OpsiC, OpsiD = pertanyaan.OpsiD, OpsiE = pertanyaan.OpsiE, Pertanyaan = pertanyaan.Isi, NextId = (pertanyaanIndex + 1) < listPertanyaan.Count ? listPertanyaan[pertanyaanIndex + 1].Id : -1, PrevId = (pertanyaanIndex - 1) > -1 ? listPertanyaan[pertanyaanIndex - 1].Id : -1, JawabanCalonSiswa = _ujianService.GetAnswerAkademik(akunId, soalId, pertanyaan.Id) }; return(View(model)); } }