コード例 #1
0
        private bool ClassHasHomeworkToCheck(SchoolClass cls)
        {
            foreach (var clsHomework in cls.Homeworks)
            {
                var allAnswersFeedbacked = true;
                foreach (var answer in _answerService.All().Where(a => a.Homework_Id.Equals(clsHomework.Id)).ToList())
                {
                    if (answer.TeacherFeedback.IsNullOrWhiteSpace())
                    {
                        allAnswersFeedbacked = false;
                        break;
                    }
                }

                if (clsHomework.Deadline < DateTime.Now && !allAnswersFeedbacked)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #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"));
            }
        }