Ejemplo n.º 1
0
        public JsonResult <ResultUi> GetExamTest(long fieldid, long gradeid, long booknameid, long lessonid, long topicid, int hardness)
        {
            ResultUi resultUi;

            try
            {
                var ans   = new DataPackUi();
                var exams = _examTestRepository.GetAllExamTest(fieldid, gradeid, booknameid, lessonid, topicid, hardness);

                //generating long random()
                long LongRandom(long min, long max, Random rand)
                {
                    long result = rand.Next((Int32)(min >> 32), (Int32)(max >> 32));

                    result = (result << 32);
                    result = result | (long)rand.Next((Int32)min, (Int32)max);
                    return(result);
                }
                long maxi = -1;
                foreach (var e in exams)
                {
                    if (e.Id > maxi)
                    {
                        maxi = e.Id;
                    }
                }
                long id = LongRandom(0, maxi, new Random());

                var questions = _examTestQuestionRepository.GetExamTestQuestion(id);
                ans.MyData = questions;
                resultUi   = new ResultUi {
                    Value = ans, Msg = "Success"
                };
                return(Json(resultUi));
            }
            catch (Exception ex)
            {
                resultUi = new ResultUi {
                    Value = "", Msg = "Fail", Exception = ex.Message
                };
                return(Json(resultUi));
            }
        }
Ejemplo n.º 2
0
        public JsonResult <ResultUi> GetAllActiveBookNamesByGradeId(long gradeId) //OK
        {
            ResultUi resultUi;

            try
            {
                var ans       = new DataPackUi();
                var bookNames = _bookNameRepository.GetAllActiveBookNamesByGradeId(gradeId);
                ans.MyData = bookNames;
                resultUi   = new ResultUi {
                    Value = ans, Msg = "Success"
                };
                return(Json(resultUi));
            }
            catch (Exception ex)
            {
                resultUi = new ResultUi {
                    Value = "", Msg = "Fail", Exception = ex.Message
                };
                return(Json(resultUi));
            }
        }
Ejemplo n.º 3
0
        public JsonResult <ResultUi> GetAllActiveTopicsByLessonId(long lessonId)
        {
            ResultUi resultUi;

            try
            {
                var ans    = new DataPackUi();
                var topics = _topicRepository.GetAllActiveTopicsByLessonId(lessonId);
                ans.MyData = topics;
                resultUi   = new ResultUi {
                    Value = ans, Msg = "Success"
                };
                return(Json(resultUi));
            }
            catch (Exception ex)
            {
                resultUi = new ResultUi {
                    Value = "", Msg = "Fail", Exception = ex.Message
                };
                return(Json(resultUi));
            }
        }
Ejemplo n.º 4
0
        public JsonResult <ResultUi> GetAllActiveFields() // OK
        {
            ResultUi resultUi;

            try
            {
                var ans    = new DataPackUi();
                var fields = _fieldRepository.GetAllActiveFields();
                ans.MyData = fields;
                resultUi   = new ResultUi {
                    Value = ans, Msg = "Success"
                };
                return(Json(resultUi));
            }
            catch (Exception ex)
            {
                resultUi = new ResultUi {
                    Value = "", Msg = "Fail", Exception = ex.Message
                };
                return(Json(resultUi));
            }
        }