Esempio n. 1
0
    public bool InsertAnswer(string strToken, Result_Answer objAnswer)
    {
        var NewAnswer = new Result_Answer();

        if (ValidAuth(strToken) == true)
        {
            NewAnswer = objAnswer;
            NewAnswer.InsertResultAnswer();
        }

        return(true);
    }
Esempio n. 2
0
    public Question GetNextQuestion(string strToken, int intResultID)
    {
        Question objReturnQuestion = new Question();

        if (ValidAuth(strToken) == true)
        {
            //Get Questions
            List <int> QuestionIDs    = new List <int>(); //All questions by Exam
            List <int> AllQuestionIDs = new List <int>(); //All questions answered

            int QuestiontoReturn;                         //questionID to return

            var objResult = new Result();
            objResult.ResultID = intResultID;
            objResult.SelectResultByID();

            QuestionIDs = GetListOfQuestion(strToken, objResult.ExamID);

            //Get Answered Questions

            //Get AnswerIDs
            var objAnsweredQuestions = new Result_Answer();
            objAnsweredQuestions.ResultID = intResultID;
            List <int> AllResultAnswerIDs = new List <int>();
            AllResultAnswerIDs = objAnsweredQuestions.SelectAnswerByResultID();

            //Get QuestionIDs

            foreach (int p in AllResultAnswerIDs)
            {
                var objAnswers = new Answer();
                objAnswers.AnswerID = p;

                objAnswers.SelectAnswerByID();

                AllQuestionIDs.Add(objAnswers.QuestionID);
            }


            foreach (int q in QuestionIDs) //if question not answered use next one
            {
                if (AllQuestionIDs.Contains(q) == false)
                {
                    QuestiontoReturn             = q;
                    objReturnQuestion.QuestionID = QuestiontoReturn;
                    objReturnQuestion.SelectQuestionByID();
                }
            }
        }

        return(objReturnQuestion);
    }