예제 #1
0
        public string GetSurveyTestDetail(string pRequest)
        {
            var rd     = new APIResponse <GetSurveyTestDetailRD>();
            var rdData = new GetSurveyTestDetailRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <GetSurveyTestDetailRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                SurveyTestDataAccess surveyTestManager = new SurveyTestDataAccess(loggingSessionInfo);
                rdData.SurveyTestInfo = surveyTestManager.GetQuestionnaireDetail(rp.Parameters.SurveyTestId);
                rd.ResultCode         = 0;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }
        public string SubmitSurveyTest(string pRequest)
        {
            var rd     = new APIResponse <SubmitSurveyTestRD>();
            var rdData = new SubmitSurveyTestRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <SubmitSurveyTestRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                decimal last = 0;
                SurveyTestDataAccess surveyTestManager = new SurveyTestDataAccess(loggingSessionInfo);
                int result = surveyTestManager.SaveAnswerSheet(rp.Parameters.SurveyTestId, rp.UserID, rp.Parameters.AnswerList, out last);
                rdData.IsPassed = result;
                rdData.Score    = last;
                rd.ResultCode   = 0;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }
예제 #3
0
        public string VerifySingleAnswer(string pRequest)
        {
            var rd     = new APIResponse <VerifySingleAnswerRD>();
            var rdData = new VerifySingleAnswerRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <VerifySingleAnswerRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                SurveyTestDataAccess surveyTestManager = new SurveyTestDataAccess(loggingSessionInfo);
                int result = surveyTestManager.VerifySingleAnswer(rp.Parameters.QuestionId, rp.Parameters.Answer);
                rdData.IsCorrect = result;
                rd.ResultCode    = 0;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }
        public string GetLastAnswerSheet(string pRequest)
        {
            var rd     = new APIResponse <GetLastAnswerSheetRD>();
            var rdData = new GetLastAnswerSheetRD();

            var rp = pRequest.DeserializeJSONTo <APIRequest <GetLastAnswerSheetRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                SurveyTestDataAccess surveyTestManager = new SurveyTestDataAccess(loggingSessionInfo);
                MLAnswerSheetEntity  entity            = surveyTestManager.GetAnswerSheet(rp.Parameters.SurveyTestId, rp.UserID);
                if (entity != null)
                {
                    rdData.TestStatus = entity.IsPassed;
                    rdData.Score      = entity.Score;
                    rdData.AnswerList = surveyTestManager.GetAnswerSheetItem(entity.AnswerSheetId, rp.UserID);
                }
                else
                {
                    rdData.TestStatus = -1;
                }
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }