public FileResult DownloadFile(int id, UploadQuestion obj) { obj.GetFiles(id); string filepath = Server.MapPath("~/QuestionFiles/" + obj.FilePath); return(File(filepath, "application/pdf", obj.FileName + ".pdf")); }
public ActionResult Upload(UploadQuestion notice) { notice.FileName = Path.GetFileNameWithoutExtension(notice.Files.FileName); notice.FilePath = notice.FileName + System.IO.Path.GetExtension(notice.Files.FileName); string fileName = "~/QuestionFiles/" + notice.FileName + System.IO.Path.GetExtension(notice.Files.FileName); notice.Files.SaveAs(Server.MapPath(fileName)); try { if (ModelState.IsValid) { if (notice.publishNotice()) { ViewBag.Message = "Publish successfully"; ModelState.Clear(); } else { ViewBag.Message = "Sorry! try again."; } return(View()); } return(View()); } catch { return(View()); } }
public ActionResult Notice() { UploadQuestion notice = new UploadQuestion(); notice.Data = notice.viewNotices(); return(View(notice)); }
public bool AddNewQuestion(string world, string chap, string difficulty, UploadQuestion question) { if (world != null && chap != null && difficulty != null && question != null) { return(true); } return(false); }
public void AddNewQuestion(string world, string chap, string difficulty, UploadQuestion question) { string UniqueKey = Random.Range(0, 10000).ToString() + System.DateTime.Now.Minute.ToString() + System.DateTime.Now.Second.ToString(); string json = JsonUtility.ToJson(question); mDatabaseRef.Child("question").Child(world).Child(chap).Child(difficulty).Child(UniqueKey).SetRawJsonValueAsync(json); }
public void AddNewQuestion(string world, string chap, string difficulty, UploadQuestion question) { Debug.Log("Add new question into database"); Debug.Log("Call Question manager to add data"); crudQuestion.AddNewQuestion(world, chap, difficulty, question); Debug.Log("Data Added"); }
public void uploadQuestion(string question, string ans1, string ans2, string ans3, string ans4, string correctAns, string UniqueKey) { this.question.question = question; this.question.ans1 = ans1; this.question.ans2 = ans2; this.question.ans3 = ans3; this.question.ans4 = ans4; this.question.correctAns = correctAns; this.UniqueKey = UniqueKey; }
public void AddNewQuestion(string world, string chap, string difficulty, UploadQuestion question) { Debug.Log("Add new question into database"); Debug.Log("Call Question manager to add data"); bool result = crudQuestion.AddNewQuestion(world, chap, difficulty, question); if (result != false) { Debug.Log("Question Added"); } }
// Delete Question// by subadmin public ActionResult DeleteFile(int id) { try { UploadQuestion notice = new UploadQuestion(); if (notice.deleteFile(id)) { ViewBag.AlertMsg = "Delete Successfully"; } return(RedirectToAction("ViewNotice")); } catch { return(RedirectToAction("ViewNotice"));; } }
public void RandomlyGenerateQuestion(string world) { UploadQuestion newQuestion = new UploadQuestion(); for (int k = 0; k < 20; k++) { int exp = 60; newQuestion.question = "" + exp + "+" + (exp + k) + "=?"; newQuestion.ans1 = (exp * 2 + k - 2).ToString(); newQuestion.ans2 = (exp * 2 + k - 1).ToString(); newQuestion.ans3 = (exp * 2 + k).ToString(); newQuestion.ans4 = (exp * 2 + k + 1).ToString(); newQuestion.correctAns = (exp * 2 + k).ToString(); /* AddNewQuestion(world, "chap1", "easy", newQuestion); * AddNewQuestion(world, "chap1", "normal", newQuestion); * AddNewQuestion(world, "chap1", "hard", newQuestion); * * AddNewQuestion(world, "chap2", "easy", newQuestion); * AddNewQuestion(world, "chap2", "normal", newQuestion); * AddNewQuestion(world, "chap2", "hard", newQuestion); * * AddNewQuestion(world, "chap3", "easy", newQuestion); * AddNewQuestion(world, "chap3", "normal", newQuestion); * AddNewQuestion(world, "chap3", "hard", newQuestion);*/ AddNewQuestion(world, "chap3", "easy", newQuestion); AddNewQuestion(world, "chap3", "normal", newQuestion); AddNewQuestion(world, "chap3", "hard", newQuestion); AddNewQuestion(world, "chap4", "easy", newQuestion); AddNewQuestion(world, "chap4", "normal", newQuestion); AddNewQuestion(world, "chap4", "hard", newQuestion); } }
public void createQuestion() { q = GameObject.Find("InputQuestion").GetComponent <InputField>(); a1 = GameObject.Find("InputAnswer1").GetComponent <InputField>(); a2 = GameObject.Find("InputAnswer2").GetComponent <InputField>(); a3 = GameObject.Find("InputAnswer3").GetComponent <InputField>(); a4 = GameObject.Find("InputAnswer4").GetComponent <InputField>(); correctA = GameObject.Find("CorrectAnswer").GetComponent <InputField>(); dropIndex = dropdown.value; dropValue = dropdown.options[dropIndex].text; question = q.text; sharingQforProf = q.text; ans1 = a1.text; ans2 = a2.text; ans3 = a3.text; ans4 = a4.text; correctAns = correctA.text; bool comp1 = correctAns.Equals(ans1); bool comp2 = correctAns.Equals(ans2); bool comp3 = correctAns.Equals(ans3); bool comp4 = correctAns.Equals(ans4); bool emptyInputQ = question.Equals(""); bool emptyInputA1 = ans1.Equals(""); bool emptyInputA2 = ans2.Equals(""); bool emptyInputA3 = ans3.Equals(""); bool emptyInputA4 = ans4.Equals(""); bool emptyInputCA = correctAns.Equals(""); if (emptyInputQ | emptyInputA1 | emptyInputA2 | emptyInputA3 | emptyInputA4 | emptyInputCA) { Debug.Log("No Input given"); setEmptyText(); } else { if (comp1 == true) { UploadQuestion uploadQuestion = new UploadQuestion(question, ans1, ans2, ans3, ans4, correctAns); crudQuestion.AddNewQuestion(QuestionData.world, chapterString, dropValue, uploadQuestion); setText(); } else if (comp2 == true) { UploadQuestion uploadQuestion = new UploadQuestion(question, ans1, ans2, ans3, ans4, correctAns); crudQuestion.AddNewQuestion(QuestionData.world, chapterString, dropValue, uploadQuestion); setText(); } else if (comp3 == true) { UploadQuestion uploadQuestion = new UploadQuestion(question, ans1, ans2, ans3, ans4, correctAns); crudQuestion.AddNewQuestion(QuestionData.world, chapterString, dropValue, uploadQuestion); setText(); } else if (comp4 == true) { UploadQuestion uploadQuestion = new UploadQuestion(question, ans1, ans2, ans3, ans4, correctAns); crudQuestion.AddNewQuestion(QuestionData.world, chapterString, dropValue, uploadQuestion); setText(); } else { setIncorrectText(); } } }
public ActionResult Notice(UploadQuestion notice) { notice.Data = notice.viewNotices(); return(View(notice)); }