コード例 #1
0
        public ActionResult UpdteQuestions(string index)
        {
            //Updating questions with Ajax
            //////////////////////////////

            int indx = Convert.ToInt32(index);

            currentThemeId = indx; ///////////////////////////////////////////////////////////////////////////////////////////

            List <FilterQuestions> data = null;

            using (DiplomeEntities db = new DiplomeEntities())
            {
                data = (from quest in db.AllQuestions
                        join theme in db.Themes
                        on quest.Theme_id equals theme.id
                        where theme.id == indx
                        select new FilterQuestions
                {
                    Id = quest.Id,
                    Theme_Questions = quest.Question
                }).ToList();
            }


            return(PartialView("_question", data));
        }
コード例 #2
0
        public void CreateQuestion(string Id)/////////////////////////////////////////////////////////////////////////////////
        {
            int indx = Convert.ToInt32(Id);

            List <QuestAnswers> data = null;

            using (DiplomeEntities db = new DiplomeEntities())
            {
                data = (from quest in db.AllQuestions
                        join answ in db.AllAnswers
                        on quest.Id equals answ.AllQuest_Id
                        where quest.Id == indx

                        select new QuestAnswers
                {
                    Subject = quest.Question,
                    Questions = answ.Answers,
                    RightId = answ.right_Answ_id
                }).ToList();
            }

            questId = indx; //Question Id

            Session["myquestions"] = data;
        }
コード例 #3
0
        public ActionResult Index(string email, string password)
        {
            //string email = "*****@*****.**";
            //string password = "******";


            List <FilterQuestions> quens    = null;
            List <Lectures>        lections = null;
            List <Themes>          themes   = null;

            using (DiplomeEntities db = new DiplomeEntities())
            {
                if (db.Proffesors.ToList().Exists(prof => prof.Email == email && prof.Password == password))
                {
                    var prof = db.Proffesors.Single(p => p.Email == email);
                    Session["prof"] = prof.Name + " " + prof.Surname;
                    quens           = (from quest in db.AllQuestions
                                       join theme in db.Themes
                                       on quest.Theme_id equals theme.id
                                       join lessn in db.Lessons
                                       on theme.Lesson_id equals lessn.Id
                                       where lessn.Id == prof.Id

                                       select new FilterQuestions
                    {
                        Theme_Questions = quest.Question
                    }).ToList();

                    lections = (from lecture in db.Lessons
                                where lecture.Proffesor_Id == prof.Id
                                select new Lectures {
                        _Lectures = lecture.Lectures, id = lecture.Id
                    }).ToList();

                    themes = (from theme in db.Themes
                              join lecture in db.Lessons
                              on theme.Lesson_id equals lecture.Id
                              where lecture.Proffesor_Id == prof.Id && theme.Lesson_id == lecture.Id

                              select new Themes {
                        _Themes = theme.Lect_themes, id = theme.id
                    }).ToList();

                    Session["lections"] = lections;
                    Session["themes"]   = themes;
                    //Session["date"] = null;

                    return(RedirectToAction("DayStatic"));
                }
                else
                {
                    ModelState.AddModelError("Error", "Wrong login or password");
                }
            }//Calling Dispose method

            return(View("LoginProf"));
        }
コード例 #4
0
        public ActionResult Statistics()
        {
            ////////////////////////////////////////////

            List <StatiscticsModel> statistics   = new List <StatiscticsModel>();
            List <StatisticLists>   studentStats = new List <StatisticLists>();
            List <string>           test;

            using (DiplomeEntities db = new DiplomeEntities())
            {
                statistics = (from stud_answ in db.Stud_Answers
                              join student in db.Students
                              on stud_answ.stud_id equals student.Id
                              //where stud_answ.theme_id == currentThemeId

                              group stud_answ by new { student.Name, student.Surname, stud_answ.answer_data } into gr
                              orderby gr.Key.Name, gr.Key.Surname
                              select new StatiscticsModel {
                    Name = gr.Key.Name + " " + gr.Key.Surname, Percent = gr.Average(g => g.answer_percent), Date = gr.Key.answer_data
                }).ToList();

                test = (from stati in statistics
                        group stati by new { stati.Name } into g
                        select g.Key.Name).ToList();
            }
            foreach (var item in test)
            {
                StatisticLists st = new StatisticLists();
                st.Name = item;
                List <double> percents = (from stati in statistics
                                          where stati.Name == item
                                          select stati.Percent).ToList();
                List <DateTime> datas = (from stati in statistics
                                         where stati.Name == item
                                         select stati.Date).ToList();

                st.Percents = percents;
                st.Datas    = datas;

                studentStats.Add(st);
            }
            var stat = JsonConvert.SerializeObject(studentStats);

            Session["Statistics"] = stat;
            return(View());
        }
コード例 #5
0
        public ActionResult Chart()
        {
            List <string> smartNames  = new List <string>();
            List <string> badNames    = new List <string>();
            List <string> alwaysSmart = new List <string>();

            int answersCount;

            using (DiplomeEntities db = new DiplomeEntities())
            {
                answersCount = db.StudAnswers_live.Select(s => s.Question_Id).Distinct().Count();

                smartNames = (from student in db.Students
                              join stud_answersLive in db.StudAnswers_live
                              on student.Id equals stud_answersLive.Stud_Id
                              where stud_answersLive.Stud_Answer == 1 && stud_answersLive.Question_Id == AdminController.questId
                              select student.Name + " " + student.Surname).ToList();

                badNames = (from student1 in db.Students
                            join stud_answersLive in db.StudAnswers_live
                            on student1.Id equals stud_answersLive.Stud_Id
                            where stud_answersLive.Stud_Answer == 0 && stud_answersLive.Question_Id == AdminController.questId
                            select student1.Name + " " + student1.Surname).ToList();

                alwaysSmart = (from student2 in db.Students
                               join stud_answersLive in db.StudAnswers_live
                               on student2.Id equals stud_answersLive.Stud_Id
                               where  stud_answersLive.Stud_Answer == 1
                               group stud_answersLive by new { stud_answersLive.Stud_Answer, student2.Name, student2.Surname } into g
                               where (g.Sum(p => p.Stud_Answer)) == answersCount
                               select g.Key.Name + "" + g.Key.Surname).ToList();
            }

            var smrtNames = JsonConvert.SerializeObject(smartNames);
            var bdNames   = JsonConvert.SerializeObject(badNames);
            var alwSmart  = JsonConvert.SerializeObject(alwaysSmart);

            return(Json(new[]
            {
                smrtNames,
                bdNames,
                alwSmart
            }));
        }
コード例 #6
0
        public ActionResult _updtTheme(string index)
        {
            //Updating themes with Ajax
            //////////////////////////////

            int           indx   = Convert.ToInt32(index);
            List <Themes> themes = null;

            using (DiplomeEntities db = new DiplomeEntities())
            {
                themes = (from theme in db.Themes
                          join lecture in db.Lessons
                          on theme.Lesson_id equals lecture.Id
                          where theme.Lesson_id == indx

                          select new Themes {
                    _Themes = theme.Lect_themes, id = theme.id
                }).ToList();
            }
            Session["themes"] = themes;
            string indxx = (themes.First(x => x.id == x.id)).id.ToString();

            return(PartialView("_DropDowns", themes));
        }
コード例 #7
0
        public void Answers(string userAnswer, string userId, string rightIndex, string selectedIndex) //Stugel
        {
            string htmlTags = string.Empty;

            int userAnswerr = Convert.ToInt32(userAnswer); // change
            int userID      = Convert.ToInt32(userId);
            int rightindex  = Convert.ToInt32(rightIndex);
            int slctindex   = Convert.ToInt32(selectedIndex);

            StudAnswers_live studAnswLive = new StudAnswers_live()
            {
                Stud_Id = userID, Question_Id = AdminController.questId, Stud_Answer = userAnswerr, Data = DateTime.UtcNow.Date
            };
            Stud_Answers stud_Answers = new Stud_Answers()
            {
                stud_id = userID, theme_id = AdminController.currentThemeId, answer_percent = userAnswerr == 1 ? 100 : 0, answer_data = DateTime.UtcNow.Date
            };

            using (DiplomeEntities db = new DiplomeEntities())
            {
                db.StudAnswers_live.Add(studAnswLive);
                db.Stud_Answers.Add(stud_Answers);
                db.SaveChanges();
            }

            htmlTags += "<div class='col-sm-3 col-xs'> <div class='card card-3'>";
            htmlTags += "<p>Arman Amrazyan</p>";

            #region IF-ELSE
            if (userAnswerr == 1)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (i == rightindex)
                    {
                        htmlTags += "<div class='test test-gr'></div>";
                    }
                    else
                    {
                        htmlTags += "<div class='test'></div>";
                    }
                }
            }
            else
            {
                for (int i = 0; i < 4; i++)
                {
                    if (i == rightindex)
                    {
                        htmlTags += "<div class='test test-gr'></div>";
                        continue;
                    }
                    if (i == slctindex)
                    {
                        htmlTags += "<div class='test test-red'></div>";
                        continue;
                    }
                    htmlTags += "<div class='test'></div>";
                }
            }
            #endregion

            htmlTags += "</div> </div>";
            OnlineStudentAnswersST.StudList.Add(htmlTags);
        }