Ejemplo n.º 1
0
        public async Task <IActionResult> PutTblQuestions([FromRoute] long id, [FromBody] TblQuestions tblQuestions)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tblQuestions.FldQuestionsId)
            {
                return(BadRequest());
            }

            _context.Entry(tblQuestions).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TblQuestionsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        protected void CreateQuestionId()
        {
            var q = new TblQuestions();
            ServerModel.DB.Insert(q);

            _id = q.ID;
        }
Ejemplo n.º 3
0
        public static TblUserAnswers GetUserAnswerForQuestion(TblUsers user, TblQuestions question)
        {
            IList <TblUserAnswers> answers = ServerModel.DB.Query <TblUserAnswers>(new AndCondition(
                                                                                       new CompareCondition <int>(
                                                                                           DataObject.Schema.UserRef,
                                                                                           new ValueCondition <int>(user.ID), COMPARE_KIND.EQUAL),
                                                                                       new CompareCondition <int>(
                                                                                           DataObject.Schema.QuestionRef,
                                                                                           new ValueCondition <int>(question.ID), COMPARE_KIND.EQUAL)));

            TblUserAnswers lastAnswer = null;

            foreach (TblUserAnswers answer in answers)
            {
                if (lastAnswer == null)
                {
                    lastAnswer = answer;
                }
                else
                {
                    if (lastAnswer.Date < answer.Date)
                    {
                        lastAnswer = answer;
                    }
                }
            }

            return(lastAnswer);
        }
Ejemplo n.º 4
0
        public int CreateQuestionId()
        {
            var q = new TblQuestions();
            ServerModel.DB.Insert(q);

            return q.ID;
        }
    public void BuildCompiledQuestionsResult(TblQuestions q, int userId)
    {
        var compiledQuestion = ServerModel.DB.Load <TblCompiledQuestions>((int)q.CompiledQuestionRef);
        var userAnswers      = ServerModel.DB.Load <TblUserAnswers>(ServerModel.DB.LookupIds <TblUserAnswers>(q, null));

        var answersForCurrentUser = new List <TblUserAnswers>();

        if (ServerModel.User.Current != null)
        {
            foreach (var uAns in userAnswers)
            {
                if (uAns.UserRef == userId)
                {
                    answersForCurrentUser.Add(uAns);
                }
            }
        }


        SetHeader(q.TestName, compiledQuestion);

        if (userAnswers.Count != 0)
        {
            SetResults(answersForCurrentUser);
        }
        else
        {
            SetNoResultStatus(q);
        }
    }
Ejemplo n.º 6
0
        private static string FindAnswer(int userId, TblQuestions question)
        {
            var answersForQuestion =
                ServerModel.DB.Load <TblUserAnswers>(ServerModel.DB.LookupIds <TblUserAnswers>(question, null));

            var answers = new List <TblUserAnswers>();

            foreach (var ans in answersForQuestion)
            {
                if (ans.UserRef == userId)
                {
                    answers.Add(ans);
                }
            }

            if (answers.Count > 0)
            {
                var lstUserAnswer = StatisticManager.FindLatestUserAnswer(answers);

                if (lstUserAnswer != null)
                {
                    return(lstUserAnswer.UserAnswer);
                }
            }

            return(string.Empty);
        }
    public void BuildCompiledQuestionsResult(TblQuestions q, int userId)
    {
        var compiledQuestion      = ServerModel.DB.Load <TblCompiledQuestions>((int)q.CompiledQuestionRef);
        var answersForCurrentUser = StudentRecordFinder.GetUserAnswersForQuestion(q, userId);

        SetHeader(q.TestName, compiledQuestion);
        SetTableHeader();

        if (answersForCurrentUser != null && answersForCurrentUser.Count != 0)
        {
            var lastUserAnswer = FindLatestUserAnswer(answersForCurrentUser);
            var compileAnswer  = StudentRecordFinder.GetCompiledAnswersForAnswer(lastUserAnswer);

            if (compileAnswer != null && compileAnswer.Count != 0)
            {
                SetResults(compileAnswer);
            }
            else
            {
                SetNoResultStatus(q);
            }
        }
        else
        {
            SetNoResultStatus(q);
        }
    }
Ejemplo n.º 8
0
    public void BuildCompiledQuestionsResult(TblQuestions q, int userId)
    {
        var compiledQuestion = ServerModel.DB.Load<TblCompiledQuestions>((int)q.CompiledQuestionRef);
        var answersForCurrentUser = StudentRecordFinder.GetUserAnswersForQuestion(q, userId);

        SetHeader(q.TestName, compiledQuestion);
        SetTableHeader();

        if (answersForCurrentUser != null && answersForCurrentUser.Count != 0)
        {
            var lastUserAnswer = FindLatestUserAnswer(answersForCurrentUser);
            var compileAnswer = StudentRecordFinder.GetCompiledAnswersForAnswer(lastUserAnswer);

            if (compileAnswer != null && compileAnswer.Count != 0)
            {
                SetResults(compileAnswer);
            }
            else
            {
                SetNoResultStatus(q);
            }
        }
        else
        {
            SetNoResultStatus(q);
        }
    }
Ejemplo n.º 9
0
        public void ChangeDataObjectIDTest()
        {
            var t = new TblQuestions();

            t.IsCompiled = true;
            t.ID         = 5;
        }
Ejemplo n.º 10
0
        protected void CreateQuestionId()
        {
            var q = new TblQuestions();

            ServerModel.DB.Insert(q);

            _id = q.ID;
        }
Ejemplo n.º 11
0
        private static TblUserAnswers GetLastUserAnswerForCompiledQuestion(TblQuestions q, TblUsers u)
        {
            var userAnswers = StudentRecordFinder.GetUserAnswersForQuestion(q, u.ID);

            var compiledAnswers = StudentRecordFinder.ExtractCompiledAnswers(userAnswers);

            return(StatisticManager.FindLatestUserAnswer(compiledAnswers));
        }
Ejemplo n.º 12
0
        public int CreateQuestionId()
        {
            var q = new TblQuestions();

            ServerModel.DB.Insert(q);

            return(q.ID);
        }
Ejemplo n.º 13
0
        public UserResultForQuestion(int userId, TblQuestions question, DateTime?date)
        {
            _date     = date;
            _question = question;
            _answers  = (List <TblUserAnswers>)StudentRecordFinder.GetUserAnswersForQuestion(question, userId);

            _answers.Sort(new UserAnswersComparer());
        }
Ejemplo n.º 14
0
        public void CreateQuestion(TblQuestions question)
        {
            if (question == null)
            {
                throw new System.ArgumentNullException(nameof(question));
            }

            _context.TblQuestions.Add(question);
        }
Ejemplo n.º 15
0
 public ActionResult Edit(TblQuestions questions)
 {
     db.Entry(questions).State = System.Data.Entity.EntityState.Modified;
     db.Entry(questions).Property(e => e.CreateBy).IsModified   = false;
     db.Entry(questions).Property(e => e.CreateDate).IsModified = false;
     questions.ModifyBy   = FullName;
     questions.ModifyDate = DateTime.Now;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 16
0
        public static string GetCorrectAnswer(int questionId)
        {
            TblQuestions q = GetQuestion(questionId);

            if (ServerModel.User.Current.Islector())
            {
                return(q.CorrectAnswer);
            }

            return(string.Empty);
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> PostTblQuestions([FromBody] TblQuestions tblQuestions)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.TblQuestions.Add(tblQuestions);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTblQuestions", new { id = tblQuestions.FldQuestionsId }, tblQuestions));
        }
Ejemplo n.º 18
0
 public ActionResult Create(TblQuestions questions)
 {
     if (questions.Question != null)
     {
         questions.CreateDate = DateTime.Now;
         questions.CreateBy   = FullName;
         db.TblQuestions.Add(questions);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
Ejemplo n.º 19
0
        public static IList <TblUserAnswers> GetUserAnswersForQuestion(TblQuestions question, int userId)
        {
            var allAnswersForQuestion = GetAnswersForQuestion(question);

            var result = new List <TblUserAnswers>();

            foreach (var a in allAnswersForQuestion)
            {
                if (a.UserRef == userId)
                {
                    result.Add(a);
                }
            }

            return(result);
        }
Ejemplo n.º 20
0
    public void BuildCompiledQuestionsResult(TblQuestions q, int userId)
    {
        var compiledQuestion = ServerModel.DB.Load<TblCompiledQuestions>((int) q.CompiledQuestionRef);
        var userAnswers = ServerModel.DB.Load<TblUserAnswers>(ServerModel.DB.LookupIds<TblUserAnswers>(q, null));
        
        var answersForCurrentUser = new List<TblUserAnswers>();
        
        if (ServerModel.User.Current != null)
        {
            foreach (var uAns in userAnswers)
                if (uAns.UserRef == userId)
                    answersForCurrentUser.Add(uAns);
        }


        SetHeader(q.TestName, compiledQuestion);

        if (userAnswers.Count != 0)
            SetResults(answersForCurrentUser);
        else
            SetNoResultStatus(q);
    }
Ejemplo n.º 21
0
        private static string FindAnswer(int userId, TblQuestions question)
        {
            var answersForQuestion =
                ServerModel.DB.Load<TblUserAnswers>(ServerModel.DB.LookupIds<TblUserAnswers>(question, null));

            var answers = new List<TblUserAnswers>();

            foreach (var ans in answersForQuestion)
            {
                if (ans.UserRef == userId)
                    answers.Add(ans);
            }

            if (answers.Count > 0)
            {
                var lstUserAnswer = StatisticManager.FindLatestUserAnswer(answers);

                if (lstUserAnswer != null)
                    return lstUserAnswer.UserAnswer;
            }

            return string.Empty;
        }
Ejemplo n.º 22
0
        public static TblUserAnswers GetUserAnswerForQuestion(TblUsers user, TblQuestions question)
        {
            IList<TblUserAnswers> answers = ServerModel.DB.Query<TblUserAnswers>(new AndCondition(
                new CompareCondition<int>(
                                     DataObject.Schema.UserRef,
                                     new ValueCondition<int>(user.ID), COMPARE_KIND.EQUAL),
                new CompareCondition<int>(
                                     DataObject.Schema.QuestionRef,
                                     new ValueCondition<int>(question.ID), COMPARE_KIND.EQUAL)));

            TblUserAnswers lastAnswer = null;
            foreach (TblUserAnswers answer in answers)
            {
                if (lastAnswer == null)
                {
                    lastAnswer = answer;
                }
                else
                {
                    if (lastAnswer.Date < answer.Date)
                    {
                        lastAnswer = answer;
                    }
                }
            }

            return lastAnswer;
        }
Ejemplo n.º 23
0
 private void SetNoResultStatus(TblQuestions q)
 {
     _compiledAnswerTable.Visible = false;
     _statusLabel.Visible         = true;
     _statusLabel.Text            = string.Format("You not compile {0} yet", q.TestName);
 }
Ejemplo n.º 24
0
        public static IList<TblUserAnswers> GetAnswersForQuestion(TblQuestions question)
        {
            var allUsersAnswersIdsForQuestion = ServerModel.DB.LookupIds<TblUserAnswers>(question, null);

            return ServerModel.DB.Load<TblUserAnswers>(allUsersAnswersIdsForQuestion);
        }
Ejemplo n.º 25
0
        public static string GetUserAnswer(int questionId, int userId)
        {
            TblQuestions q = GetQuestion(questionId);

            return(FindAnswer(userId, q));
        }
Ejemplo n.º 26
0
        /*
         * public static IList<TblThemes> GetThemesForStage(TblStages stage)
         * {
         *  List<int> themesIds = ServerModel.DB.LookupMany2ManyIds<TblThemes>(stage, null);
         *  return ServerModel.DB.Load<TblThemes>(themesIds);
         * }
         *
         * public static IList<TblStages> GetStagesForCurriculum(TblCurriculums curriculum)
         * {
         *  List<int> stagesIds = ServerModel.DB.LookupIds<TblStages>(curriculum, null);
         *  return ServerModel.DB.Load<TblStages>(stagesIds);
         * }
         *
         * public static IList<TblQuestions> GetQuestionsForPage(int pageId)
         * {
         *  var page = ServerModel.DB.Load<TblPages>(pageId);
         *  var questionsIds = ServerModel.DB.LookupIds<TblQuestions>(page, null);
         *
         *  return ServerModel.DB.Load<TblQuestions>(questionsIds);
         * }
         *
         * public static TblThemes GetThemeForPage(int pageId)
         * {
         *  var page = ServerModel.DB.Load<TblPages>(pageId);
         *  return ServerModel.DB.Load<TblThemes>((int)page.ThemeRef);
         * }
         */
        public static IList <TblUserAnswers> GetAnswersForQuestion(TblQuestions question)
        {
            var allUsersAnswersIdsForQuestion = ServerModel.DB.LookupIds <TblUserAnswers>(question, null);

            return(ServerModel.DB.Load <TblUserAnswers>(allUsersAnswersIdsForQuestion));
        }
Ejemplo n.º 27
0
 public void ChangeDataObjectIDTest()
 {
     var t = new TblQuestions();
     t.IsCompiled = true;
     t.ID = 5;
 }
Ejemplo n.º 28
0
        private static TblUserAnswers GetLastUserAnswerForCompiledQuestion(TblQuestions q, TblUsers u)
        {
            var userAnswers = StudentRecordFinder.GetUserAnswersForQuestion(q, u.ID);

            var compiledAnswers = StudentRecordFinder.ExtractCompiledAnswers(userAnswers);

            return StatisticManager.FindLatestUserAnswer(compiledAnswers);
        }
Ejemplo n.º 29
0
        public static IList<TblUserAnswers> GetUserAnswersForQuestion(TblQuestions question, int userId)
        {
            var allAnswersForQuestion = GetAnswersForQuestion(question);

            var result = new List<TblUserAnswers>();

            foreach (var a in allAnswersForQuestion)
                if (a.UserRef == userId)
                    result.Add(a);

            return result;
        }
Ejemplo n.º 30
0
 private void SetNoResultStatus(TblQuestions q)
 {
     _compiledAnswerTable.Visible = false;
     _statusLabel.Visible = true;
     _statusLabel.Text = string.Format("You not compile {0} yet", q.TestName);
 }