Ejemplo n.º 1
0
        private void CheckUjian(int akunId, int soalId)
        {
            var soal           = _soalService.GetDetailSoal(soalId);
            var kunciJawaban   = soal.ListPertanyaan.ToDictionary(x => x.Id, y => y.Jawaban.ToString());
            var listHasilUjian = GetHasilUjian(akunId, soalId);

            for (int i = 0; i < listHasilUjian.Count; i++)
            {
                int pertanyaanId = listHasilUjian[i].PertanyaanId;
                if (listHasilUjian[i].Jawaban == kunciJawaban[pertanyaanId])
                {
                    listHasilUjian[i].IsBenar = true;
                }
                else
                {
                    listHasilUjian[i].IsBenar = false;
                }
            }
            string sqlQuery = @"UPDATE HasilTes SET IsBenar = @IsBenar
                                WHERE AkunPendaftaranId = @AkunPendaftaranId AND PertanyaanId = @PertanyaanId AND SoalId = @SoalId";

            using (var connection = new SqlConnection(_connectionHelper.GetConnectionString()))
            {
                connection.Open();
                connection.Execute(sql: sqlQuery, param: listHasilUjian);
            }
        }
Ejemplo n.º 2
0
        public IActionResult RincianSoalAkademik(int id)
        {
            var soal  = _soalService.GetDetailSoal(id);
            var model = new RincianSoalAkademikModel()
            {
                Id                     = soal.Id,
                JudulSoal              = soal.Judul,
                BatasWaktu             = soal.BatasWaktu,
                JumlahPertanyaan       = soal.JumlahPertanyaan,
                Kategori               = soal.Kategori,
                Deskripsi              = soal.Deskripsi,
                ListPertanyaanAkademik = soal.ListPertanyaan
                                         .Select(x => new CrudPertanyaanAkademikModel()
                {
                    Id      = x.Id,
                    SoalId  = x.SoalId,
                    Isi     = x.Isi,
                    OpsiA   = x.OpsiA,
                    OpsiB   = x.OpsiB,
                    OpsiC   = x.OpsiC,
                    OpsiD   = x.OpsiD,
                    OpsiE   = x.OpsiE,
                    Jawaban = x.Jawaban
                }).ToList()
            };

            return(View(model));
        }
Ejemplo n.º 3
0
        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));
            }
        }