Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            QuestTest questTest = db.QuestTests.Find(id);

            db.QuestTests.Remove(questTest);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "QuestTestID,FQTestID,FQuesterID,Result,TImeSkip,TestAppearance")] QuestTest questTest)
 {
     if (ModelState.IsValid)
     {
         db.Entry(questTest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FQTestID   = new SelectList(db.QTests, "QTestID", "QTNote", questTest.FQTestID);
     ViewBag.FQuesterID = new SelectList(db.Questers, "QuesterID", "Question", questTest.FQuesterID);
     return(View(questTest));
 }
Ejemplo n.º 3
0
        // GET: QuestTest/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            QuestTest questTest = db.QuestTests.Find(id);

            if (questTest == null)
            {
                return(HttpNotFound());
            }
            return(View(questTest));
        }
Ejemplo n.º 4
0
        // GET: QuestTest/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            QuestTest questTest = db.QuestTests.Find(id);

            if (questTest == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FQTestID   = new SelectList(db.QTests, "QTestID", "QTNote", questTest.FQTestID);
            ViewBag.FQuesterID = new SelectList(db.Questers, "QuesterID", "Question", questTest.FQuesterID);
            return(View(questTest));
        }
Ejemplo n.º 5
0
        // [ValidateAntiForgeryToken]
        public ActionResult Create(int[] TestWordsParameters, string title, int rstatus, int time)  //string Title, bool? TotalTime , bool? Second, DateTime? Time
        {
            //   string name = Request.Form["Title"].ToString();

            QTest test = new QTest();

            if (TestWordsParameters != null)
            {
                test.QTNote = title;

                if (rstatus == 1)
                {
                    test.Score    = time;
                    test.TestTime = true;
                }
                else if (rstatus == 2)
                {
                    test.Score       = time;
                    test.TimePerWord = true;
                }
                for (int j = 0; j < TestWordsParameters.Length; j++)
                {
                    var       r  = TestWordsParameters[j];
                    QuestTest wt = new QuestTest();
                    wt.FQuesterID = r;
                    test.QuestTests.Add(wt);  // parent.childs.Add(child obj)
                }
                test.FQTuserID = userid;

                db.QTests.Add(test);
                db.SaveChanges();
            }

            // ViewBag.FWTUserID = new SelectList(db.Users, "UserID", "Forename", wTest.FWTUserID);
            return(RedirectToAction("Create"));
        }
Ejemplo n.º 6
0
        //public ActionResult Testhome()
        //{
        //    //if (Session["Rem_Time"] == null)
        //    //{
        //    //    Session["Rem_Time"] = DateTime.Now.AddMinutes(0.5).ToString("dd-MM-yyyy h:mm:ss tt");
        //    //}
        //    //ViewBag.Rem_Time = Session["Rem_Time"];

        //    //int testID = ViewBag.TestID;

        //    ViewBag.Message = "Modify this template to jump-start your MVC application.";
        //    return View();


        //}

        // WTest start tomorrow, send data to answer view wothout timer
        public ActionResult Answer(int?id)
        {
            var r = (from t in db.QTests
                     where t.FQTuserID == userid
                     orderby t.QTestID descending
                     select t).First();
            double time   = Convert.ToDouble(r.Score);
            bool   minute = r.TestTime ?? false;
            bool   second = r.TimePerWord ?? false;

            if (minute == true)
            {
                if (Session["EndDate"] == null)
                {
                    Session["EndDate"] = DateTime.Now.AddMinutes(time).ToString("dd-MM-yyyy h:mm:ss tt");
                }
            }
            else if (second == true)
            {
                Session["EndDate"] = DateTime.Now.AddSeconds(time).ToString("dd-MM-yyyy h:mm:ss tt");
            }
            // Session["EndDate"] = DateTime.Now.AddMinutes(minute).ToString("dd-MM-yyyy h:mm:ss tt");

            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
            ViewBag.EndDate = Session["EndDate"];
            int value = id ?? default(int);

            if (value == 1)
            {
                int       wid = fwords[true_count];
                QuestTest wt  = db.QuestTests.Where(t => (t.FQuesterID == wid) && (t.FQTestID == r.QTestID)).FirstOrDefault();
                wt.Result = true;
                db.SaveChanges();
                true_count = true_count + 1;
            }


            // var d = db.WordTests.Where(t => t.FWtestID==1).FirstOrDefault();  // working

            //int turnfirst = 0;
            if (turnfirst == 0)
            {
                v = 0;
                //testid = (from t in db.WTests
                //          orderby t.WTestID descending
                //          select t.WTestID).First();
                Quester w   = new Quester();
                var     IDs = db.QuestTests.Where(t => t.FQTestID == r.QTestID).ToArray().Select(t => t.FQuesterID);

                int index = 0;
                k = IDs.Count();  // k = total no words
                foreach (var c in IDs)
                {
                    w = db.Questers.Find(c);
                    definitions[index] = w.Answer;
                    hint[index]        = w.Hint;
                    wordlist[index]    = w.Question;
                    fwords[index]      = w.QuesterID;
                    index = index + 1;
                }
                turnfirst = 1;
            }
            if (v < k)
            {
                ViewBag.Definition = definitions[v];
                ViewBag.Hint       = hint[v];
                ViewBag.Word       = wordlist[v];
                v = v + 1;
            }
            else
            {
                ViewBag.Status  = "complete";
                ViewBag.EndDate = null;
                return(RedirectToAction("Result", new { id = r.QTestID }));
            }
            return(View());
        }