public ActionResult Submit(string subject, string[] topics)
        {
            ViewBag.subject = subject;
            ViewBag.topics  = topics;

            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you were not logged in. please log in and then try again" }));
            }
            removeCookie("TestId");
            removeCookie("groupName");

            List <string> topicsList = new List <string>();

            topicsList = topics.ToList();
            string ans = ServerWiring.getInstance().getAutoGeneratedQuesstion(Convert.ToInt32(cookie.Value), subject, topicsList);

            if (ans == Replies.SUCCESS)
            {
                return(RedirectToAction("Index", "AnswerQuestion"));
            }
            return(RedirectToAction("Index", "GetQuestion", new { message = ans }));
        }
        public ActionResult Submit(string subject, string[] topics, int numberOfQuestions, string whenToShowAnswer)
        {
            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you were not logged in. please log in and then try again" }));
            }
            ViewBag.subject           = subject;
            ViewBag.topics            = topics;
            ViewBag.numberOfQuestions = numberOfQuestions;
            bool flag = false;

            if (whenToShowAnswer.Equals("AfterEachQuestion"))
            {
                flag = true;
            }
            List <string> topicsList = new List <string>();

            topicsList = topics.ToList();

            string ans = ServerWiring.getInstance().getAutoGeneratedTest(Convert.ToInt32(cookie.Value), subject, topicsList, numberOfQuestions, flag);

            if (ans == Replies.SUCCESS)
            {
                return(RedirectToAction("Index", "AnswerQuestion"));
            }


            return(RedirectToAction("Index", "GetTest", new { message = ans }));
        }
        public ActionResult Submit(string testDetails)
        {
            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you were not logged in. please log in and then try again" }));
            }
            if (testDetails == null)
            {
                return(RedirectToAction("Index", "ManageGroup", new { message = "You must choose at least one test" }));
            }
            ViewBag.testDetails = testDetails;
            String[]   details     = testDetails.Split(',');
            String[]   TestIdArr   = details[0].Split(':');
            String[]   TestIdArr1  = TestIdArr[1].Split(' ');
            int        TestId      = int.Parse(TestIdArr1[1]);
            HttpCookie groupCookie = Request.Cookies["groupName"];

            string ans = ServerWiring.getInstance().saveGroupAndTest(Convert.ToInt32(cookie.Value), groupCookie.Value, TestId);

            if (ans.Equals(Replies.SUCCESS))
            {
                return(RedirectToAction("Index", "SeeTestDetails", new { TestId = TestId }));
            }
            return(RedirectToAction("Index", "AddTestToGroup", ViewBag.group));
        }
Exemple #4
0
        public ActionResult Index()
        {
            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you were not logged in. please log in and then try again" }));
            }
            removeCookie("TestId");
            removeCookie("groupName");
            List <Question>     questions     = ServerWiring.getInstance().getTestQuestions(Convert.ToInt32(cookie.Value));
            List <QuestionData> questionsData = new List <QuestionData>();

            if (questions != null)
            {
                foreach (Question ques in questions)
                {
                    questionsData.Add(new QuestionData(ques));
                }

                return(View(questionsData));
            }
            else
            {
                return(View());
            }
        }
Exemple #5
0
        public ActionResult Submit(string testName, int[] QuestionData)
        {
            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you were not logged in. please log in and then try again" }));
            }

            List <int> questionsIdsList = new List <int>();

            if (QuestionData == null)
            {
                return(RedirectToAction("Index", "CreateTest", new { message = "Select at least one question" }));
            }
            questionsIdsList = QuestionData.ToList();

            ViewBag.testName         = testName;
            ViewData["QuestionData"] = QuestionData;


            string ans = ServerWiring.getInstance().createTest(Convert.ToInt32(cookie.Value), questionsIdsList, testName);

            if (ans.Equals(Replies.SUCCESS))
            {
                return(RedirectToAction("Index", "ManageGroup", new { message = "The test was successfully created" }));
            }
            ViewBag.message = ans;
            return(View());
        }
        // GET: GroupStatistics
        public ActionResult Index(string groupName, string message)
        {
            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you are not logged in. please log in and then try again" }));
            }
            if (Request.Cookies["TestId"] != null)
            {
                var c = new HttpCookie("TestId");
                c.Expires = DateTime.Now.AddDays(-1);
                Response.Cookies.Add(c);
            }
            if (message != null)
            {
                ViewBag.message = message;
            }



            string name              = ServerWiring.getInstance().getUserName(Convert.ToInt32(cookie.Value));
            string group_name        = groupName.Substring(0, groupName.LastIndexOf(GroupsMembers.CREATED_BY));
            GroupStatisticsData data = getData(Convert.ToInt32(cookie.Value), groupName);

            if (!data.message.Equals(Replies.SUCCESS))
            {
                return(RedirectToAction("Index", "Main", new { message = data.message }));
            }
            return(View(data));
        }
        public ActionResult Submit(string subject, string[] topics, HttpPostedFileBase[] imgs, string freeText)
        {
            ViewBag.subject    = subject;
            ViewData["topics"] = topics;
            ViewBag.freeText   = freeText;

            ViewData["imgs"] = imgs;
            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you were not logged in. please log in and then try again" }));
            }
            removeCookie("TestId");
            removeCookie("groupName");
            List <byte[]> allImgs = new List <byte[]>();

            foreach (HttpPostedFileBase img in imgs)
            {
                MemoryStream target = new MemoryStream();
                img.InputStream.CopyTo(target);
                byte[] dataImg = target.ToArray();
                allImgs.Add(dataImg);
            }

            string ans = ServerWiring.getInstance().createQuestion(Convert.ToInt32(cookie.Value), subject, topics.ToList(), allImgs, freeText);

            if (ans == Replies.SUCCESS)
            {
                return(RedirectToAction("Index", "Administration", new { message = "Question added successfully" }));
            }

            return(RedirectToAction("Index", "CreateQuestion", new { message = ans }));
        }
        public ActionResult Submit(string subject, string[] topics)
        {
            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you were not logged in. please log in and then try again" }));
            }
            List <string> topicsList = new List <string>();

            topicsList = topics.ToList();

            ViewBag.subject    = subject;
            ViewData["topics"] = topics;


            string ans = ServerWiring.getInstance().createTest(Convert.ToInt32(cookie.Value), subject, topicsList);

            if (ans == Replies.SUCCESS)
            {
                return(RedirectToAction("Index", "SelectQuestions"));
            }


            return(RedirectToAction("Index", "CreateTest", new { message = ans }));
        }
        // GET: ShowAnswers
        public ActionResult Index(bool hasMoreQuestions)
        {
            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you were not logged in. please log in and then try again" }));
            }
            removeCookie("TestId");
            removeCookie("groupName");
            Tuple <string, List <Question> > q = ServerWiring.getInstance().getAnsweres(Convert.ToInt32(cookie.Value));

            List <ShowAnswersData> questions = new List <ShowAnswersData>();

            foreach (Question ques in q.Item2)
            {
                questions.Add(new ShowAnswersData(ques));
            }


            //ViewBag["images"] = pics;
            string next;

            if (hasMoreQuestions)
            {
                next = "Main";
            }
            else
            {
                next = "AnswerQuestion";
            }
            ViewData["next"] = next;
            return(View(questions));
        }
Exemple #10
0
 public QuestionData(Question q)
 {
     dignosis = ServerWiring.getInstance().getQuestionDiagnoses(q.QuestionId);
     pics     = ServerWiring.getInstance().getQuestionImages(q.QuestionId);
     qID      = q.QuestionId;
     text     = q.text;
     level    = q.level;
 }
Exemple #11
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            ServerWiring.initServer(new FakeMedTrainDBContext(1));
            IServer a = ServerWiring.getInstance();

            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
Exemple #12
0
        public ActionResult Submit(string norm, int sure1, string[] diagnosis, int[] sure2)
        {
            HttpCookie questionCookie = Request.Cookies["questionId"];
            HttpCookie userCookie     = Request.Cookies["userId"];

            if (userCookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you were not logged in. please log in and then try again" }));
            }
            List <string> diagnosisList = new List <string>();
            List <int>    sure2List     = new List <int>();

            if (norm.Equals("false"))
            {
                if (diagnosis == null || sure2 == null)
                {
                    return(RedirectToAction("Index", new { message = "if you chosen that the diagnosis is abnormal than you must choose at least one diagnosis" }));
                }
                diagnosisList = diagnosis.ToList();
                sure2List     = sure2.ToList();
            }
            string     ans = "";
            bool       hasMoreQuestions = false;
            HttpCookie testCookie       = Request.Cookies["TestId"];
            HttpCookie groupCookie      = Request.Cookies["groupName"];

            if (groupCookie == null || testCookie == null)
            {
                ans = ServerWiring.getInstance().answerAQuestion(Convert.ToInt32(userCookie.Value), Convert.ToInt32(questionCookie.Value), norm.Equals("true"), sure1, diagnosisList, sure2List, true).Item1;
                hasMoreQuestions = ServerWiring.getInstance().hasMoreQuestions(Convert.ToInt32(userCookie.Value));
            }
            else
            {
                ans = ServerWiring.getInstance().answerAQuestionGroupTest(Convert.ToInt32(userCookie.Value), groupCookie.Value, Convert.ToInt32(testCookie.Value), Convert.ToInt32(questionCookie.Value), norm.Equals("true"), sure1, diagnosisList, sure2List);
                hasMoreQuestions = ServerWiring.getInstance().hasMoreQuestionsGroupTest(Convert.ToInt32(userCookie.Value), groupCookie.Value, Convert.ToInt32(testCookie.Value));
            }
            if (ans.Equals(Replies.SHOW_ANSWER))
            {
                if (hasMoreQuestions)
                {
                    return(RedirectToAction("Index", "ShowAnswers", new { hasMoreQuestions = false }));
                }
                return(RedirectToAction("Index", "ShowAnswers", new { hasMoreQuestions = true }));
            }
            else if (ans.Equals(Replies.SUCCESS))
            {
                double grade = ServerWiring.getInstance().getTestGrade(Convert.ToInt32(userCookie.Value), groupCookie.Value, Convert.ToInt32(testCookie.Value));
                return(RedirectToAction("Index", "Main", new { message = "your grade is " + grade }));
            }
            else
            {
                return(RedirectToAction("index"));
            }
        }
Exemple #13
0
        List <GroupData> getData(int adminId)
        {
            List <GroupData> data = new List <GroupData>();
            Tuple <string, List <string> > groups = ServerWiring.getInstance().getAllAdminsGroups(adminId);

            foreach (string group in groups.Item2)
            {
                data.Add(new GroupData(group));
            }
            return(data);
        }
Exemple #14
0
        public ActionResult Submit(string email)
        {
            string ans = ServerWiring.getInstance().restorePassword(email);

            if (ans.Equals(Replies.SUCCESS))
            {
                return(RedirectToAction("Index", "Login"));
            }
            //ViewBag.errorMessage = ans;
            return(RedirectToAction("Index", "Forgot", new { message = ans }));
        }
        private List <SubjectData> getData()
        {
            List <SubjectData> data     = new List <SubjectData>();
            List <string>      subjects = ServerWiring.getInstance().getAllSubjects();

            foreach (string subject in subjects)
            {
                data.Add(new SubjectData(subject));
            }
            return(data);
        }
Exemple #16
0
        private List <GetQuestionData> getData()
        {
            List <GetQuestionData> data     = new List <GetQuestionData>();
            List <string>          subjects = ServerWiring.getInstance().getAllSubjects();

            foreach (string subject in subjects)
            {
                List <string> list = ServerWiring.getInstance().getSubjectTopicsGetAQuestion(subject);
                data.Add(new GetQuestionData(subject, list));
            }
            return(data);
        }
        List <GetTestData> getData()
        {
            List <GetTestData> data     = new List <GetTestData>();
            List <string>      subjects = ServerWiring.getInstance().getAllSubjects();

            foreach (string subject in subjects)
            {
                List <string> list = ServerWiring.getInstance().getSubjectTopicsGetAQuestion(subject);
                list.Remove(Constants.Topics.NORMAL);
                data.Add(new GetTestData(subject, list));
            }
            return(data);
        }
Exemple #18
0
        TestStatisticsData getData(int adminId, int TestId, string groupName)
        {
            TestStatisticsData data = new TestStatisticsData();
            Tuple <string, List <Tuple <string, int> > > usersGrades = ServerWiring.getInstance().getGrades(adminId, TestId, groupName);

            if (!usersGrades.Item1.Equals(Replies.SUCCESS))
            {
                return(data);
            }

            data.gradesInTest = usersGrades.Item2;
            return(data);
        }
        public ActionResult Submit(string emailReg, string fname, string lname, string passwordReg, string level)
        {
            ViewBag.emailReg = emailReg;
            ViewBag.fname    = fname;
            ViewBag.lname    = lname;

            Tuple <string, int> ans = ServerWiring.getInstance().register(emailReg, passwordReg, convert(level), fname, lname);

            if (ans.Item1.Equals(Replies.SUCCESS))
            {
                return(RedirectToAction("Index", "Login", new { message = "You have successfully registered" }));
            }
            ViewBag.errorMessageReg = ans.Item1;
            return(View("index"));
        }
        public ActionResult Submit(string email, string password)
        {
            ViewBag.email = email;

            Tuple <string, int> ans = ServerWiring.getInstance().login(email, password);

            if (ans.Item1.Equals(Replies.SUCCESS))
            {
                HttpCookie userCookie = new HttpCookie("userId", ans.Item2.ToString());
                Response.SetCookie(userCookie);

                return(RedirectToAction("Index", "Main"));
            }
            ViewBag.errorMessage = ans.Item1;
            return(View("index"));
        }
Exemple #21
0
        public ActionResult Submit(string groupName)
        {
            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you were not logged in. please log in and then try again" }));
            }
            string ans = ServerWiring.getInstance().removeGroup(Convert.ToInt32(cookie.Value), groupName);

            if (ans.Equals(Replies.SUCCESS))
            {
                return(RedirectToAction("Index", "Administration"));
            }
            return(RedirectToAction("Index", "ManageGroup", new { message = ans }));
        }
Exemple #22
0
        // GET: AnswerQuestion
        public ActionResult Index(string message)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            ViewBag.message = message;
            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you were not logged in. please log in and then try again" }));
            }
            Tuple <string, Question> q = null;
            HttpCookie testCookie      = Request.Cookies["TestId"];
            HttpCookie groupCookie     = Request.Cookies["groupName"];

            if (groupCookie == null || testCookie == null)
            {
                q = ServerWiring.getInstance().getNextQuestion(Convert.ToInt32(cookie.Value));
            }
            else
            {
                q = ServerWiring.getInstance().getNextQuestionGroupTest(Convert.ToInt32(cookie.Value), groupCookie.Value, Convert.ToInt32(testCookie.Value));
            }
            if (!q.Item1.Equals(Replies.SUCCESS))
            {
                return(RedirectToAction("Index", "Login", new { message = q.Item1 }));
            }
            HttpCookie questionCookie = new HttpCookie("questionId", q.Item2.QuestionId.ToString());

            Response.SetCookie(questionCookie);
            List <string> topics = ServerWiring.getInstance().getSubjectTopicsGetAQuestion(q.Item2.SubjectId);

            ViewBag.topics = topics;
            if (!q.Item2.text.Equals(""))
            {
                ViewData["text"] = q.Item2.text;
            }

            List <String> lst = ServerWiring.getInstance().getQuestionImages(q.Item2.QuestionId);

            ViewData["Images"] = lst;

            List <string> subject_list = ServerWiring.getInstance().getSubjectTopicsGetAQuestion(q.Item2.SubjectId);

            subject_list.Remove(Constants.Topics.NORMAL);
            ViewData["subjects"] = subject_list;
            return(View());
        }
Exemple #23
0
        public ShowAnswersData(Question q)
        {
            dignosis = ServerWiring.getInstance().getQuestionDiagnoses(q.QuestionId);
            pics     = ServerWiring.getInstance().getQuestionImages(q.QuestionId);


            //question = q;

            /*foreach(Topic t in q.diagnoses)
             * {
             *  dignosis.Add(t.TopicId);
             * }
             * foreach (Image i in q.images)
             * {
             *  pics.Add(i.ImageId);
             * }*/
        }
Exemple #24
0
        public ActionResult Submit(string userEmail)
        {
            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you were not logged in. please log in and then try again" }));
            }
            ViewBag.userEmail = userEmail;
            string ans = ServerWiring.getInstance().setUserAsAdmin(Convert.ToInt32(cookie.Value), userEmail);

            if (ans.Equals(Replies.SUCCESS))
            {
                return(RedirectToAction("Index", "Administration", new { message = "User added as administrator successfully" }));
            }
            return(RedirectToAction("Index", "SetUserAsAdmin", new { message = ans }));
        }
        private List <GetTestData> getData(int adminId)
        {
            List <GetTestData> data     = new List <GetTestData>();
            List <string>      subjects = ServerWiring.getInstance().getAllSubjects();

            foreach (string subject in subjects)
            {
                Tuple <string, List <Test> > tests = ServerWiring.getInstance().getAllTests(adminId, subject);
                List <string> testStrings          = new List <string>();
                foreach (Test test in tests.Item2)
                {
                    testStrings.Add(test.ToString());
                }
                data.Add(new GetTestData(subject, testStrings));
            }
            return(data);
        }
Exemple #26
0
        List <QuestionData> getData(int adminId)
        {
            List <QuestionData> data = new List <QuestionData>();
            Tuple <string, List <Question> > questions = ServerWiring.getInstance().getAllReleventQuestions(adminId);

            if (questions.Item1 == Replies.SUCCESS)
            {
                foreach (Question q in questions.Item2)
                {
                    data.Add(new QuestionData(q));
                }
                return(data);
            }
            else
            {
                return(data);
            }
        }
Exemple #27
0
        public ActionResult Submit(string subject, string topicName)
        {
            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie == null)
            {
                return(RedirectToAction("Index", "Login", new { message = "you were not logged in. please log in and then try again" }));
            }
            ViewBag.topicName = topicName;
            ViewBag.subject   = subject;
            string ans = ServerWiring.getInstance().addTopic(Convert.ToInt32(cookie.Value), subject, topicName);

            if (ans.Equals(Replies.SUCCESS))
            {
                return(RedirectToAction("Index", "Administration", new { message = "Topic added successfully" }));
            }
            return(RedirectToAction("Index", "AddTopic", new { message = ans }));
        }
        private List <GetTestData> getData(int adminId)
        {
            List <GetTestData>           data        = new List <GetTestData>();
            HttpCookie                   groupCookie = Request.Cookies["groupName"];
            Tuple <string, List <Test> > tests       = ServerWiring.getInstance().getGroupTests(adminId, groupCookie.Value);

            if (!tests.Item1.Equals(Replies.SUCCESS))
            {
                return(data);
            }
            List <string> testStrings = new List <string>();

            foreach (Test test in tests.Item2)
            {
                testStrings.Add(test.ToString());
            }
            data.Add(new GetTestData(groupCookie.Value, testStrings));
            return(data);
        }
        public ActionResult Index(string message)
        {
            if (message != null)
            {
                ViewData["message"] = message;
            }

            removeCookie("TestId");
            removeCookie("groupName");
            HttpCookie cookie = Request.Cookies["userId"];

            if (cookie != null)
            {
                ServerWiring.getInstance().logout(Convert.ToInt32(cookie.Value));
            }
            removeCookie("userId");

            return(View());
        }
        List <QuestionData> getData(int adminId, int TestId)
        {
            List <QuestionData> data           = new List <QuestionData>();
            Tuple <string, List <Question> > t = ServerWiring.getInstance().getTestQuestionsByTestId(adminId, TestId);

            if (!t.Item1.Equals(Replies.SUCCESS))
            {
                return(data);
            }
            List <Question> testQuestions = t.Item2;

            if (testQuestions != null)
            {
                foreach (Question q in testQuestions)
                {
                    data.Add(new QuestionData(q));
                }
            }
            return(data);
        }