public async Task <bool> InsertAsync(Soal entity, long[] tag) { try { IList <TagSoal> ts = new List <TagSoal>(); foreach (var n in tag) { var s = await _Tag.GetByIdAsync(n); ts.Add(new TagSoal { Tag = s }); } entity.TagSoal = ts; entity.Regdat = DateTime.Now; if (Insert(entity)) { // soalToUser(entity, user); return(true); } return(false); } catch { return(false); } }
public bool Insert(Soal entity, long[] tag) { try { IList <TagSoal> ts = new List <TagSoal>(); foreach (var n in tag) { var s = _Tag.GetById(n); ts.Add(new TagSoal { Tag = s }); } entity.TagSoal = ts; entity.Regdat = DateTime.Now; if (Insert(entity)) { var q = db.Set <TagSoal>(); q.AddRange(entity.TagSoal); db.SaveAllChanges(); // soalToUser(entity, user); return(true); } return(false); } catch { return(false); } }
public bool newInsert(Soal entity, long[] tag, IList <ApplicationUser> user) { try { // var us = db.Set<ApplicationUser>().Find(1); // entity.User = us; IList <TagSoal> ts = new List <TagSoal>(); foreach (var n in tag) { var s = _Tag.GetById(n); ts.Add(new TagSoal { Tag = s }); } entity.TagSoal = ts; entity.Regdat = DateTime.Now; if (Insert(entity)) { SoalToUser(entity, user); return(true); } return(false); } catch { return(false); } }
public void Update(int soalId) { SoalId = soalId; //isi soal Soal soal = Program.factory.GetSoal().GetById(soalId); txtPertanyaan.Text = soal.Soal_Tanya; rbEssay.Checked = soal.Soal_Jenis == "ESSAY" ? true : false; rbMultiple.Checked = !rbEssay.Checked; //isi multiple jika bukan essay if (rbMultiple.Checked) { Pilihans = Program.factory.GetSoalPilihanMultiple().GetBySoalId(soalId); LoadGridPilihan(); } else { txtJawabanEssay.Text = soal.Soal_Jawab; } //isi group GroupTerpilih = Program.factory.GetGroupSoal().GetBySoalId(soalId); LoadGridGroupTerpilih(); }
public bool SoalToUser(Soal soal, IList <ApplicationUser> user) { foreach (var e in user) { db.Set <SoalToUser>().Add(new SoalToUser { User = e, Soal = soal }); } return(true); }
public FormShowQuiz(Group_Soal group, Soal soal, List <Soal_Pilihan_Multiple> multiples) { InitializeComponent(); this.DialogResult = DialogResult.No; this.FormClosing += FormShowQuiz_FormClosing; _group = group; _soal = soal; _soalPilihanMultiples = multiples; Fill(); }
public Soal GetById(int soalId) { Soal result = null; StringBuilder sb = new StringBuilder(); sb.Append(" select * from soal where soal_id = :soal_id "); _conn.Open(); using (_conn) { result = _conn.QueryFirstOrDefault <Soal>(sb.ToString(), new { soal_id = soalId }); } return(result); }
private void cmdSimpan_Click(object sender, EventArgs e) { if (!ValidateBeforeSimpan()) { return; } Soal soal = new Soal(); soal.Soal_Jenis = rbEssay.Checked ? "ESSAY" : "MULTIPLE"; soal.Soal_Tanya = txtPertanyaan.Text.Trim(); soal.Soal_Jawab = rbEssay.Checked ? txtJawabanEssay.Text.Trim() : ""; if (!SoalId.HasValue) { //Insert mode Program.factory.GetSoal().Insert(soal); SoalId = Program.factory.GetBase().GetLastSeq("SOAL").Value; } else { //Update mode soal.Soal_Id = SoalId.Value; Program.factory.GetSoal().Update(soal); } //delete pilihan multi by soalid Program.factory.GetSoalPilihanMultiple().DeleteBySoalId(SoalId.Value); //insert pilihan multi by soalid foreach (var item in Pilihans) { item.soal_id = SoalId.Value; Program.factory.GetSoalPilihanMultiple().Insert(item); } //delete tag group by soalid Program.factory.GetSoalTagGroup().DeleteBySoalId(SoalId.Value); //insert tag group by soalid foreach (var item in GroupTerpilih) { Soal_Tag_Group stg = new Soal_Tag_Group() { soal_id = SoalId.Value, gs_id = item.gs_id }; Program.factory.GetSoalTagGroup().Insert(stg); } Close(); }
public int Insert(Soal soal) { int result = 0; StringBuilder sb = new StringBuilder(); sb.Append(" insert into soal (soal_jenis, soal_tanya, soal_jawab) values (@soal_jenis, @soal_tanya, @soal_jawab) "); _conn.Open(); using (_conn) { result = _conn.Execute(sb.ToString(), new { soal_jenis = soal.Soal_Jenis, soal_tanya = soal.Soal_Tanya, soal_jawab = soal.Soal_Jawab }); } return(result); }
// Use this for initialization void Start() { score.text = "Score : " + poin.ToString(); if (soalList == null || soalList.Count <= 1) { soalList = new List <Soal>(data); Debug.Log(soalList.Count); } int index = Random.Range(0, soalList.Count - 1); current = soalList[Mathf.Clamp(index, 0, data.Length)]; soal.text = current.soal; soalList.RemoveAt(index); // Debug.Log(soalList.Count); }
private void simpan_Click(object sender, RoutedEventArgs e) { //validate if (ValidateValue()) { using (var db = new OcphDbContext()) { var trans = db.BeginTransaction(); try { var soal = new Models.Soal { Level = Level.Easy, Value = soalTxt.Text }; soal.Id = db.Soals.InsertAndGetLastID(soal); if (soal.Id > 0) { foreach (var item in Options) { item.SoalId = soal.Id.Value; item.Id = db.Options.InsertAndGetLastID(item); if (item.Id <= 0) { throw new SystemException("Data Gagal Dapat Disimpan"); } else { soal.AddOption(item); } } trans.Commit(); this.SoalCreated = soal; this.Close(); } } catch (Exception ex) { trans.Rollback(); MessageBox.Show(ex.Message); } } } else { MessageBox.Show("Periksa Kembali Data Anda"); } }
public int Update(Soal soal) { int result = 0; StringBuilder sb = new StringBuilder(); sb.Append(" update soal set soal_jenis=@soal_jenis, soal_tanya=@soal_tanya, soal_jawab=@soal_jawab "); sb.Append(" where soal_id=@soal_id "); _conn.Open(); using (_conn) { result = _conn.Execute(sb.ToString(), new { soal_jenis = soal.Soal_Jenis, soal_tanya = soal.Soal_Tanya, soal_jawab = soal.Soal_Jawab, soal_id = soal.Soal_Id }); } return(result); }
public IActionResult TambahSoalAkademik(KelolaSoalAkademikModel model) { if (!ModelState.IsValid) { TempData["Pesan"] = "Gagal menambah soal, Data tidak valid"; } else { var soalAkademikBaru = new Soal() { Judul = model.SoalAkademik.Judul, BatasWaktu = model.SoalAkademik.BatasWaktu, Kategori = model.SoalAkademik.Kategori, Deskripsi = model.SoalAkademik.Deskripsi, }; _soalService.AddSoal(soalAkademikBaru); TempData["Pesan"] = "Soal berhasil ditambah"; } return(RedirectToAction(nameof(KelolaSoalAkademik))); }
public IActionResult UbahSoalAkademik(KelolaSoalAkademikModel model) { if (!ModelState.IsValid) { TempData["Pesan"] = $"Gagal mengubah soal, Data tidak valid"; } else { var dataBaru = new Soal() { Id = model.SoalAkademik.Id, Judul = model.SoalAkademik.Judul, BatasWaktu = model.SoalAkademik.BatasWaktu, Kategori = model.SoalAkademik.Kategori, Deskripsi = model.SoalAkademik.Deskripsi, }; _soalService.UpdateSoal(dataBaru); TempData["Pesan"] = $"Soal {dataBaru.Judul} berhasil diubah"; } return(RedirectToAction(nameof(KelolaSoalAkademik))); }
public IActionResult TambahSoalWawancara(KelolaSoalWawancaraModel model) { if (!ModelState.IsValid) { TempData["Pesan"] = $"Gagal menambah soal, Data tidak valid"; } else { var soalWawancaraBaru = new Soal() { Judul = model.SoalWawancara.Judul, Kategori = model.SoalWawancara.Kategori, Jalur = model.SoalWawancara.Jalur, Target = model.SoalWawancara.Target, Deskripsi = model.SoalWawancara.Deskripsi, }; _soalService.AddSoal(soalWawancaraBaru); TempData["Pesan"] = "Soal berhasil ditambah"; } return(RedirectToAction(nameof(KelolaSoalWawancara))); }
public IActionResult UbahSoalWawancara(KelolaSoalWawancaraModel model) { if (!ModelState.IsValid) { TempData["Pesan"] = $"Gagal mengubah soal, Data tidak valid"; } else { var dataBaru = new Soal() { Id = model.SoalWawancara.Id, Kategori = model.SoalWawancara.Kategori, Judul = model.SoalWawancara.Judul, Target = model.SoalWawancara.Target, Jalur = model.SoalWawancara.Jalur, Deskripsi = model.SoalWawancara.Deskripsi, }; _soalService.UpdateSoal(dataBaru); TempData["Pesan"] = $"Soal {dataBaru.Judul} berhasil diubah"; } return(RedirectToAction(nameof(KelolaSoalWawancara))); }
public Soal Insert_ReturnObject(Soal entity) { throw new NotImplementedException(); }
void CreateTTS(Soal soal) { BoxTTS temp = null; if (soal.arah == Arah.Horizontal) { if (soal.StartPos.x < width.x) { width.x = soal.StartPos.x; } if ((soal.StartPos.x + (soal.jawaban.Length - 1) > width.y)) { width.y = (soal.StartPos.x + (soal.jawaban.Length - 1)); } } else if (soal.arah == Arah.Vertical) { if (soal.StartPos.y > width.y) { height.y = soal.StartPos.y; } if ((soal.StartPos.y - (soal.jawaban.Length - 1) < height.x)) { height.x = (soal.StartPos.y - (soal.jawaban.Length - 1)); } } for (int i = 0; i < soal.jawaban.Length; i++) { Vector2 pos = new Vector2(soal.StartPos.x + (soal.arah == Arah.Horizontal ? i : 0), soal.StartPos.y - (soal.arah == Arah.Vertical ? i : 0)); RaycastHit2D ray = Physics2D.CircleCast(pos, 0.1f, Vector2.zero, 0); BoxTTS btts = null; if (ray.transform != null) { Debug.DrawRay(ray.transform.position, (soal.arah == Arah.Horizontal ? Vector2.right : Vector2.down) * 0.1f, Color.red, 10); Debug.Log(ray.transform.localPosition); btts = ray.transform.GetComponent <BoxTTS>(); if (btts.boxAnswer != soal.jawaban[i].ToString()) { Debug.LogError("Error : " + soal.id + " answer: (" + soal.jawaban + ") at Value " + i + " must be " + soal.jawaban[i].ToString()); } if (i == 0) { btts.transform.GetChild(2).GetComponent <TextMesh>().text = soal.id.ToString(); GameObject listSoal = Instantiate(listSoalPrefabs, contentListSoal); listSoal.transform.GetChild(0).GetComponent <UnityEngine.UI.Text>().text = soal.id + ". " + (soal.arah == Arah.Horizontal ? "MENDATAR\n\n" : "MENURUN\n\n") + soal.pertanyaan; listSoal.GetComponent <UnityEngine.UI.Button>().onClick.AddListener(() => SetObjSelected(btts, soal.arah)); } } else { GameObject box = Instantiate(boxPrefabs, pos, Quaternion.identity, boxNotSelectedParent); if (i == 0) { box.transform.GetChild(2).GetComponent <TextMesh>().text = soal.id.ToString(); GameObject listSoal = Instantiate(listSoalPrefabs, contentListSoal); listSoal.transform.GetChild(0).GetComponent <UnityEngine.UI.Text>().text = soal.id + ". " + (soal.arah == Arah.Horizontal ? "MENDATAR\n\n" : "MENURUN\n\n") + soal.pertanyaan; listSoal.GetComponent <UnityEngine.UI.Button>().onClick.AddListener(() => SetObjSelected(btts, soal.arah)); } btts = box.GetComponent <BoxTTS>(); } btts.boxAnswer = soal.jawaban[i].ToString(); //btts.soal = soal; if (soal.arah == Arah.Vertical) { //Debug.Log("Done"); btts.soalVertical = soal; btts.prevVertical = temp; if (temp != null) { temp.nextVertical = btts; } } else { btts.soalHorizontal = soal; btts.prevHorizontal = temp; if (temp != null) { temp.nextHorizontal = btts; } } temp = btts; } }
// Filename : GameManager.cs /*public void nextSoal(int i){ * soalke = soalke + i; * SetSoal (soalke); * } * public void prevSoal(int i){ * soalback = nomorSoalDitampilkan - i; * SetSoal (soalback); * }*/ public void SetSoal(int numsoal) { panelSoal.SetActive(true); teksSkor.text = "...."; // menunjuk isi array kumpulan soal indeks ke N // batasi biar tidak muncul exception Index Out Of Range nomorSoalDitampilkan = numsoal; // tampilkan soal Soal soal = paketSoal.kumpulanSoal[nomorSoalDitampilkan]; teksPertanyaan.text = soal.soalPertanyaan; // Sprite gambarSoal = soal.gambarPertanyaan; // apakah soal memiliki gambar? // if (gambarSoal == null) gambarPertanyaan.SetActive(false); // else // { // gambarPertanyaan.GetComponent<Image>().sprite = gambarSoal; // gambarPertanyaan.SetActive(true); // } // set pilihan jawaban yang ditampilkan PilihanJawaban[] pilihanJawaban = soal.pilihanJawaban; for (int i = 0; i < pilihanJawabanButton.Length; i++) { //GameObject teksPilihaJawaban = pilihanJawabanButton [i].GetComponentsInChildren; GameObject teksPilihanJawaban = pilihanJawabanButton[i].transform.Find("TextJawaban").gameObject; // GameObject gambarPilihanJawaban = pilihanJawabanButton[i].transform.Find("GambarJawaban").gameObject; Button button = pilihanJawabanButton[i].GetComponentInChildren <Button>(); button.image.color = Color.white; // apakah ada teks yang perlu ditampilkan? if (pilihanJawaban[i].teks != "") { teksPilihanJawaban.GetComponent <Text>().text = pilihanJawaban[i].teks; teksPilihanJawaban.SetActive(true); } else { teksPilihanJawaban.SetActive(false); } // apakah ada gambar yang perlu ditampilkan? // if (pilihanJawaban[i].gambar) // { // gambarPilihanJawaban.GetComponent<Image>().sprite = pilihanJawaban[i].gambar; // gambarPilihanJawaban.SetActive(true); // } // else gambarPilihanJawaban.SetActive(false); // apakah pemain sudah pernah menjawab soal ini sebelumnya? // jika iya, perlihatkan ia menjawab pilihan yang mana (A / B / C / D) if (jawabanUser[nomorSoalDitampilkan] != Jawaban.Kosong && (int)jawabanUser[nomorSoalDitampilkan] == i + 1) { Color selectedAnswerColor = new Color(0f, 0f, 1f); pilihanJawabanButton[i].GetComponentInChildren <Button>().image.color = selectedAnswerColor; } } }
public Task <bool> DeleteASync(Soal entity) { throw new NotImplementedException(); }
public Task <Soal> Insert_ReturnObjectASync(Soal entity) { throw new NotImplementedException(); }
public bool Delete(Soal entity) { throw new NotImplementedException(); }
public Task <bool> InsertAsync(Soal entity, long[] tag, IList <ApplicationUser> user) { throw new NotImplementedException(); }
public bool Insert(Soal entity) { db.Addnew(entity); db.SaveAllChanges(); return(true); }