示例#1
0
 private void InitializQuestions()
 {
     foreach (var hw in _homeworkService.All().Include(x => x.Questions))
     {
         if (hw.Text != null && hw.Text.Name.Equals(Session["HomeworkText"]))
         {
             foreach (var hwQuestion in hw.Questions)
             {
                 TempData[hwQuestion.Id + "_homework"] += "מספר שאלה: " + hwQuestion.Question_Number + "\n";
                 TempData[hwQuestion.Id + "_homework"] += "שאלה: \n" + hwQuestion.Content + "\n\n";
             }
         }
     }
 }
示例#2
0
        public ActionResult ChooseAction(string textName)
        {
            try
            {
                Session["textName"] = textName;
                string[] tmpStringArray = textName.Split(' ');
                if (tmpStringArray[0].Equals("לסיפור"))
                {
                    textName = "";
                    int i;
                    for (i = 1; i < tmpStringArray.Count(); i++)
                    {
                        if (i == tmpStringArray.Count() - 1)
                        {
                            textName = textName + tmpStringArray[i];
                        }
                        else
                        {
                            textName = textName + tmpStringArray[i] + " ";
                        }
                    }
                }


                Session["title"]         = textName;
                Session["WithQuestion?"] = "Without";
                string textContent = _textService.All().Where(x => x.Name == textName).FirstOrDefault().Content;
                string userid      = User.Identity.GetUserId();

                foreach (var std in _studentService.All().Include(x => x.Homeworks))
                {
                    if (std.ApplicationUserId.Equals(userid))
                    {
                        student = std;
                        break;
                    }
                }

                Text text = _textService.All().Where(x => x.Name == textName).FirstOrDefault();
                Session["notificationFlag"] = "false";
                foreach (var hw in student.Homeworks)
                {
                    if (hw.Text_Id == text.Id)
                    {
                        Session["notificationFlag"] = "true";
                    }
                }


                //take care the flags that go to text view, ui for questions, set background to corrrect with flags..

                Homework tmphw = _homeworkService.All().Where(x => x.Text.Id == text.Id).ToList().FirstOrDefault();
                Session["TextContent"] = getWordDefinitionsForText(textContent);
                if (tmphw != null && tmphw.Text_Id == text.Id && _answerService.All().Where(x => x.Homework_Id == tmphw.Id && x.Student_Id == student.Id).Count() > 0 || student.Homeworks.Contains(tmphw))
                {
                    Session["NoHomeWork"] = "1";
                    return(View("TextView"));
                }

                Session["NoHomeWork"] = "0";

                return(View("TextView"));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index"));
            }
        }