コード例 #1
0
        public ActionResult DisplaySubmitedSAQuestion(ShortAnswerQuestionResponse saqr)
        {
            ShortAnswerQuestionData saqData = (ShortAnswerQuestionData)rsContext.getActivity(saqr.ActivityId);

            saqData.AddAnswerToDictionary(saqData.id, saqr.PhoneNumber, saqr.Answer, saqr.RoomId);

            rsContext.SaveChanges();

            if (saqr.ExpId == -1)
            {
                TempData["alertSuccessMessage"] = Resources.Resources.AnswerSubmitted;
                return(RedirectToAction("StudentLogin", "Account"));
            }
            else
            {
                return(RedirectToAction("Experiment", new { expId = saqr.ExpId, studentPhone = saqr.PhoneNumber, studentRoom = saqr.RoomId, currActivityIndex = saqr.CurrActivityIndex + 1 }));
            }
        }
コード例 #2
0
        // GET: Student/ShortAnswerQuestion
        public ActionResult ShortAnswerQuestion(long activityId, string studentPhone, long studentRoom, long expId, int currActivityIndex, int numOfActivities)
        {
            ShortAnswerQuestionData saqData = (ShortAnswerQuestionData)rsContext.getActivity(activityId);

            TempData["Question"]            = saqData.question;
            TempData["studentPhone"]        = studentPhone;
            TempData["studentRoom"]         = studentRoom;
            TempData["activityId"]          = activityId;
            TempData["correctAnswerString"] = saqData.correctAnswerString;
            TempData["expId"]             = expId;
            TempData["currActivityIndex"] = currActivityIndex;
            TempData["numOfActivities"]   = numOfActivities;

            if (currActivityIndex == 0) // first in exp activities
            {
                return(PartialView());
            }
            return(View());
        }
コード例 #3
0
        public ActionResult GetUpdatedModelShortAnswerQuestion(long questionID)
        {
            ShortAnswerQuestionData saqData = (ShortAnswerQuestionData)rsContext.getActivity(questionID);
            var info           = new List <object>();
            var studentAnswers = new List <Object>();

            foreach (AnswerByPhoneData abpData in saqData.studentsAnswers)
            {
                StudentData studentData = rsContext.getStudent(abpData.Phone, abpData.RoomID);
                studentAnswers.Add(new { Phone = abpData.Phone, Answer = abpData.Answer, FirstName = studentData.FirstName, LastName = studentData.LastName });
            }

            info.Add(new
            {
                StudentAnswers = studentAnswers
            });

            return(Json(info, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        //POST: Teacher/DisplayShortAnswerQuestion
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        public ActionResult DisplayShortAnswerQuestion(long ActivityId)
        {
            ShortAnswerQuestionData quesData    = (ShortAnswerQuestionData)rsContext.getActivity(ActivityId);
            TeacherData             teacherData = rsContext.getTeacher(User.Identity.Name);

            if (teacherData == null)
            {
                throw new ArgumentNullException(nameof(teacherData));
            }

            //RoomData roomData = teacherData.getRoomData();
            RoomData roomData = rsContext.getRoom(teacherData.RoomId);

            if (roomData == null)
            {
                throw new ArgumentNullException(nameof(roomData));
            }

            roomData.updateCurrentActivityId(quesData.id);
            rsContext.SaveChanges();
            ShortAnswerQuestion ques = Adapting.getShortAnswerQuestionFromData(quesData);

            return(View(ques));
        }
コード例 #5
0
        public ActionResult SaveShortAnswerQuestion(ShortAnswerQuestion ques)
        {
            TeacherData teacherData = rsContext.getTeacher(User.Identity.Name);

            if (ques.expID == -1)
            {
                ques.RoomId = teacherData.RoomId;
                ShortAnswerQuestionData saData = Adapting.getShortAnswerQuestionAsData(ques);
                rsContext.addActivity(saData);
                rsContext.SaveChanges();
                return(RedirectToDashboard());
            }
            else
            {
                ques.RoomId = 0;
                ShortAnswerQuestionData saData = Adapting.getShortAnswerQuestionAsData(ques);
                rsContext.addActivity(saData);
                ExperimentData experimentData = (ExperimentData)rsContext.getActivity(ques.expID);
                saData.experimentOrder = experimentData.activities.Count;
                experimentData.addStep(saData);
                rsContext.SaveChanges();
                return(RedirectToAction("EditExperiment", new { ExpID = ques.expID }));
            }
        }
コード例 #6
0
ファイル: Adapting.cs プロジェクト: aviadbi1/LabExplorer
        public static ShortAnswerQuestion getShortAnswerQuestionFromData(ShortAnswerQuestionData saqData)
        {
            ShortAnswerQuestion saq = new ShortAnswerQuestion();

            saq.ActivityName = saqData.ActivityName;
            saq.expID        = saqData.expID;
            saq.id           = saqData.id;
            saq.RoomId       = saqData.RoomId;

            saq.question     = saqData.question;
            saq.explaination = saqData.explaination;

            saq.correctAnswerString = saqData.correctAnswerString;

            saq.studentsAnswers = new List <AnswerByPhone>();
            if (saqData.studentsAnswers != null)
            {
                foreach (AnswerByPhoneData abpData in saqData.studentsAnswers)
                {
                    saq.studentsAnswers.Add(getAnswerByPhoneFromData(abpData));
                }
            }
            return(saq);
        }