コード例 #1
0
        // POST: Teacher/DisplayTrueFalseQuestion
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        public ActionResult DisplayTrueFalseQuestion(long ActivityId)
        {
            TrueFalseQuestionData quesData = (TrueFalseQuestionData)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();

            TrueFalseQuestion ques = Adapting.getTrueFalseQuestionFromData(quesData);

            return(View(ques));
        }
コード例 #2
0
        public ActionResult DisplaySubmitedTfQuestion(TrueFalseQuestionResponse tfqr)
        {
            TrueFalseQuestionData tfqData = (TrueFalseQuestionData)rsContext.getActivity(tfqr.ActivityId);

            if (tfqr.Answer)
            {
                tfqData.updateCounters(tfqr.PhoneNumber, "Yes");
                tfqData.AddAnswerToDictionary(tfqData.id, tfqr.PhoneNumber, "Yes", tfqr.RoomId);
            }
            else
            {
                tfqData.updateCounters(tfqr.PhoneNumber, "No");
                tfqData.AddAnswerToDictionary(tfqData.id, tfqr.PhoneNumber, "No", tfqr.RoomId);
            }

            rsContext.SaveChanges();

            if (tfqr.ExpId == -1)
            {
                TempData["alertSuccessMessage"] = Resources.Resources.AnswerSubmitted;
                return(RedirectToAction("StudentLogin", "Account"));
            }
            else
            {
                return(RedirectToAction("Experiment", new { expId = tfqr.ExpId, studentPhone = tfqr.PhoneNumber, studentRoom = tfqr.RoomId, currActivityIndex = tfqr.CurrActivityIndex + 1 }));
            }
        }
コード例 #3
0
ファイル: Adapting.cs プロジェクト: aviadbi1/LabExplorer
        public static TrueFalseQuestionData getTrueFalseQuestionAsData(TrueFalseQuestion tfq)
        {
            TrueFalseQuestionData tfqData = new TrueFalseQuestionData();

            tfqData.ActivityName = tfq.ActivityName;
            tfqData.expID        = tfq.expID;
            tfqData.id           = tfq.id;
            tfqData.RoomId       = tfq.RoomId;

            tfqData.question     = tfq.question;
            tfqData.explaination = tfq.explaination;

            tfqData.correctAnswerBool = tfq.correctAnswerBool;
            tfqData.counterFalse      = tfq.counterFalse;
            tfqData.counterTrue       = tfq.counterTrue;

            tfqData.studentsAnswers = new List <AnswerByPhoneData>();
            if (tfq.studentsAnswers != null)
            {
                foreach (AnswerByPhone abp in tfq.studentsAnswers)
                {
                    tfqData.studentsAnswers.Add(getAnswerByPhoneAsData(abp));
                }
            }
            return(tfqData);
        }
コード例 #4
0
ファイル: Adapting.cs プロジェクト: aviadbi1/LabExplorer
        public static TrueFalseQuestion getTrueFalseQuestionFromData(TrueFalseQuestionData tfqData)
        {
            TrueFalseQuestion tfq = new TrueFalseQuestion();

            tfq.ActivityName   = tfqData.ActivityName;
            tfq.expID          = tfqData.expID;
            tfq.id             = tfqData.id;
            tfq.isMainActivity = tfqData.isMainActivity;
            tfq.RoomId         = tfqData.RoomId;
            tfq.Type           = tfqData.Type;

            tfq.question     = tfqData.question;
            tfq.explaination = tfqData.explaination;

            tfq.correctAnswerBool = tfqData.correctAnswerBool;
            tfq.counterFalse      = tfqData.counterFalse;
            tfq.counterTrue       = tfqData.counterTrue;

            tfq.studentsAnswers = new List <AnswerByPhone>();
            if (tfqData.studentsAnswers != null)
            {
                foreach (AnswerByPhoneData abpData in tfqData.studentsAnswers)
                {
                    tfq.studentsAnswers.Add(getAnswerByPhoneFromData(abpData));
                }
            }
            return(tfq);
        }
コード例 #5
0
        // GET: Student/TrueFalseQuestion
        public ActionResult TrueFalseQuestion(long activityId, string studentPhone, long studentRoom, long expId, int currActivityIndex, int numOfActivities)
        {
            TrueFalseQuestionData tfqData = (TrueFalseQuestionData)rsContext.getActivity(activityId);

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

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

            foreach (AnswerByPhoneData abpData in tfqData.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
            {
                AnswersCount   = tfqData.studentsAnswers.Count,
                CountTrue      = tfqData.counterTrue,
                CountFalse     = tfqData.counterFalse,
                StudentAnswers = studentAnswers
            });

            return(Json(info, JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
        public ActionResult SaveTrueFalseQuestion(TrueFalseQuestion ques)
        {
            TeacherData teacherData = rsContext.getTeacher(User.Identity.Name);

            if (ques.expID == -1)
            {
                ques.RoomId = teacherData.RoomId;
                TrueFalseQuestionData tfqData = Adapting.getTrueFalseQuestionAsData(ques);
                rsContext.addActivity(tfqData);
                rsContext.SaveChanges();
                return(RedirectToDashboard());
            }
            else
            {
                ques.RoomId = 0;
                TrueFalseQuestionData tfqData = Adapting.getTrueFalseQuestionAsData(ques);
                rsContext.addActivity(tfqData);
                ExperimentData experimentData = (ExperimentData)rsContext.getActivity(ques.expID);
                tfqData.experimentOrder = experimentData.activities.Count;
                experimentData.addStep(tfqData);
                rsContext.SaveChanges();
                return(RedirectToAction("EditExperiment", new { ExpID = ques.expID }));
            }
        }