public AssessmentData GetAssessmentForEvaluation(int assessmentId, int userid) { AssessmentData assessmentData = new AssessmentData(); List <QuestionPaperData> listQuestionPaper = new List <QuestionPaperData>(); IDatabaseHelper objSqlADOHelper = new SqlADOHelper(); SqlParameter[] paramArray = new SqlParameter[3]; paramArray[0] = RepositoryUtility.AddSQLParameter("@AssessmentId", SqlDbType.VarChar, ParameterDirection.Input, assessmentId); paramArray[1] = RepositoryUtility.AddSQLParameter("@UserId", SqlDbType.VarChar, ParameterDirection.Input, userid); paramArray[2] = RepositoryUtility.AddSQLParameter("@responsemessage", SqlDbType.VarChar, ParameterDirection.Output, null, 500); var dt = objSqlADOHelper.GetData(paramArray, StoredProcedureNameConstants.SPGetQuestionPaperForEvaluate); var stringReader = new System.IO.StringReader(Convert.ToString(dt.Rows[0].ItemArray[1])); var serializer = new XmlSerializer(typeof(List <QuestionPaperData>)); listQuestionPaper = serializer.Deserialize(stringReader) as List <QuestionPaperData>; assessmentData.QuestionPaper = listQuestionPaper; assessmentData.QuestionPaperId = Convert.ToInt32(dt.Rows[0].ItemArray[0]); return(assessmentData); }
public ActionResult Index1(AssessmentData examResult) { UpdateSubmittedQandAns(examResult); AssessmentData que = GetAssessmentQuestionsByPageNumber(examResult.PageNumber, examResult.TotalPages); return(View("Exam", que)); }
public IActionResult Index() { HttpContext.Session.Clear(); HttpContext.Session.Set(Constants.SubmittedQuestions, subQandA); int pageNumber = 1; decimal totalPages = GetTotalNumberOfPages(originalQandAns.Count); AssessmentData examData = GetAssessmentQuestionsByPageNumber(pageNumber, totalPages); examData.Timer = originalQandAns.Count * 30; return(View("Exam", examData)); }
private void UpdateSubmittedQandAns(AssessmentData examResult) { List <Assignment> toBeSubmitted = HttpContext.Session.Get <Assignment>(Constants.SubmittedQuestions); examResult.Exam.ForEach(q => { Assignment sub = toBeSubmitted.Where(origQue => origQue.Question == q.Question).FirstOrDefault(); sub.SelectedAnswer = q.SelectedAnswer; }); HttpContext.Session.Clear(); HttpContext.Session.Set(Constants.SubmittedQuestions, toBeSubmitted); }
private AssessmentData GetAssessmentQuestionsByPageNumber(int pageNumber, decimal maxPageNumber) { AssessmentData assigmentResult = new AssessmentData(); if (pageNumber == maxPageNumber + 1) { List <Assignment> submittedQandAns = HttpContext.Session.Get <Assignment>(Constants.SubmittedQuestions); assigmentResult.Exam = submittedQandAns; assigmentResult.ShowResult = true; assigmentResult.TotalMarks = originalQandAns.Count; foreach (var q in submittedQandAns) { if (q.Answer == q.SelectedAnswer) { assigmentResult.TotalMarksSecured++; } } assigmentResult.Percentage = (assigmentResult.TotalMarksSecured / Convert.ToDecimal(assigmentResult.TotalMarks)) * 100; ComputeStatus(assigmentResult); return(assigmentResult); } int numberOfQuestionsToSkip = (pageNumber - 1) * maxQuestionsToDisplay; List <Assignment> test = new List <Assignment>(); originalQandAns.Skip(numberOfQuestionsToSkip) .Take(maxQuestionsToDisplay) .ToList() .ForEach(q => { Assignment assignment = new Assignment(); assignment.Question = q.Question; assignment.Options = q.Options; test.Add(assignment); }); assigmentResult.Exam = test; assigmentResult.PageNumber = pageNumber; assigmentResult.TotalPages = maxPageNumber; return(assigmentResult); }
private void ComputeStatus(AssessmentData assigmentResult) { if (assigmentResult.Percentage <= 35) { assigmentResult.Status = Status.Poor; } else if (assigmentResult.Percentage <= 50) { assigmentResult.Status = Status.Average; } else if (assigmentResult.Percentage <= 60) { assigmentResult.Status = Status.Good; } else if (assigmentResult.Percentage <= 75) { assigmentResult.Status = Status.Excellent; } else { assigmentResult.Status = Status.Outstanding; } }
public List <AssessmentData> GetAllAssessmentDetails() { List <AssessmentData> listAssessmentData = new List <AssessmentData>(); IDatabaseHelper objSqlADOHelper = new SqlADOHelper(); SqlParameter[] paramArray = new SqlParameter[1]; paramArray[0] = RepositoryUtility.AddSQLParameter("@responsemessage", SqlDbType.VarChar, ParameterDirection.Output, null, 500); var dt = objSqlADOHelper.GetData(paramArray, StoredProcedureNameConstants.SpGetAllAssessments); foreach (DataRow row in dt.Rows) { AssessmentData assessmentData = new AssessmentData(); assessmentData.Id = Convert.ToInt32(row.ItemArray[0]); assessmentData.AssessmentName = Convert.ToString(row.ItemArray[1]); listAssessmentData.Add(assessmentData); } return(listAssessmentData); }
public bool CreateAssessment(AssessmentEntity assessmentEntity) { try { AssessmentData assessmentData = new AssessmentData(); assessmentData.AssessmentName = assessmentEntity.AssessmentName; assessmentData.AssessmentDescription = assessmentEntity.AssessmentDescription; assessmentData.QuestionPaperData = new QuestionpaperDetails(); assessmentData.QuestionPaperData.Id = assessmentEntity.QuestionPaperDetails.Id; assessmentData.StartTime = assessmentEntity.StartTime; assessmentData.EndTime = assessmentEntity.EndTime; assessmentData.CreatedBy = assessmentEntity.CreatedBy; IQuestionPaperRepository questionPaperRepository = DataFactory.DataFactory.CreateQuestionPaperRepositoryInstance(); return(questionPaperRepository.CreateAssessment(assessmentData)); } catch (Exception ex) { return(false); } }
public bool CreateAssessment(AssessmentData assessmentData) { bool isCreationSucess = true; try { IDatabaseHelper objSqlADOHelper = new SqlADOHelper(); SqlParameter[] paramArray = new SqlParameter[7]; paramArray[0] = RepositoryUtility.AddSQLParameter("@AssessmentName", SqlDbType.VarChar, ParameterDirection.Input, assessmentData.AssessmentName); paramArray[1] = RepositoryUtility.AddSQLParameter("@AssessmentDescription", SqlDbType.VarChar, ParameterDirection.Input, assessmentData.AssessmentDescription); paramArray[2] = RepositoryUtility.AddSQLParameter("@QuestionPaperId", SqlDbType.VarChar, ParameterDirection.Input, assessmentData.QuestionPaperData.Id); paramArray[3] = RepositoryUtility.AddSQLParameter("@StartTime", SqlDbType.DateTime, ParameterDirection.Input, assessmentData.StartTime); paramArray[4] = RepositoryUtility.AddSQLParameter("@EndTime", SqlDbType.DateTime, ParameterDirection.Input, assessmentData.EndTime); paramArray[5] = RepositoryUtility.AddSQLParameter("@CreatedBy", SqlDbType.VarChar, ParameterDirection.Input, assessmentData.CreatedBy); paramArray[6] = RepositoryUtility.AddSQLParameter("@responsemessage", SqlDbType.VarChar, ParameterDirection.Output, null, 500); objSqlADOHelper.GetOutputParamValue(paramArray, StoredProcedureNameConstants.SPCreateAssessment); string successMessage = Convert.ToString(paramArray[6].Value); if (successMessage.Equals("Success")) { isCreationSucess = true; } else { isCreationSucess = false; } } catch (Exception ex) { isCreationSucess = false; } return(isCreationSucess); }