/// <summary> /// This Method Load Questions according to category, type for an exam. /// </summary> /// <param name="oCategory"> It takes Category Object </param> /// <param name="oQuestionType"> It takes QuestionType Object </param> /// <param name="oCandidateForExam"> It takes CandidateForExam Object </param> /// <returns> It returns Result Object </returns> public Result LoadQuestionsForACandidateInExamByCategoryAndType(Category oCategory, QuestionType oQuestionType, CandidateForExam oCandidateForExam) { logger.Info("Start LoadQuestionsForACandidateInExamByCategoryAndType CandidateExamProcessDAO+DAO"); Result oResult = new Result(); DAOUtil oDAOUtil = new DAOUtil(); SqlDataReader oSqlDataReader = null; String sSelect = String.Empty; String sChoiceSelect = String.Empty; List<Question> oListQuestion = new List<Question>(); List<CandidateAnswerQuestion> oListCandidateAnswerQuestion = new List<CandidateAnswerQuestion>(); int i = 0; try { //sSelect = "select EX_Question.QuestionID,EX_Question.QuestionText,EX_Question.QuestionCreatorID,EX_Question.QuestionDefaultMark,EX_Question.QuestionCategoryID,EX_Question.QuestionTypeID from EX_QuestionGeneration inner join EX_Question on EX_QuestionGeneration.QuestionID=EX_Question.QuestionID where EX_QuestionGeneration.ExamID='" + oCandidate.CadidateCandidateExam.CandiadteExamExam.ExamID + "' order by EX_Question.QuestionCategoryID, EX_Question.QuestionTypeID asc"; //sSelect = "select EX_Question.QuestionID,EX_Question.QuestionText,EX_Question.QuestionCreatorID,EX_QuestionGeneration.SetupQuestionMark,EX_Question.QuestionCategoryID,EX_Question.QuestionTypeID" //+" from EX_QuestionGeneration inner join EX_Question on EX_QuestionGeneration.QuestionID=EX_Question.QuestionID" //+" where EX_QuestionGeneration.ExamID='" + oCandidate.CadidateCandidateExam.CandiadteExamExam.ExamID + "' order by EX_Question.QuestionCategoryID, EX_Question.QuestionTypeID asc"; sSelect = "select EX_Question.QuestionID,EX_Question.QuestionText," +" EX_Question.QuestionCreatorID,EX_QuestionGeneration.SetupQuestionMark" +" ,EX_Question.QuestionCategoryID,EX_Question.QuestionTypeID" +" from EX_QuestionGeneration inner join EX_Question on EX_QuestionGeneration.QuestionID=EX_Question.QuestionID" +" where EX_QuestionGeneration.ExamID='" + oCandidateForExam.CadidateCandidateExam.CandiadteExamExam.ExamID + "'" +" and EX_Question.QuestionCategoryID='" + oCategory.CategoryID + "'" +" and EX_Question.QuestionTypeID='" + oQuestionType.QuestionTypeID + "'"; oSqlDataReader = oDAOUtil.GetReader(sSelect); while (oSqlDataReader.Read()) { Question oQuestion = new Question(); oQuestion.QuestionID = new Guid(oSqlDataReader["QuestionID"].ToString()); oQuestion.QuestionText = oSqlDataReader["QuestionText"].ToString(); oQuestion.QuestionCreator.SystemUserID = new Guid(oSqlDataReader["QuestionCreatorID"].ToString()); oQuestion.QuestionDefaultMark = float.Parse(oSqlDataReader["SetupQuestionMark"].ToString()); oQuestion.QuestionCategory.CategoryID = int.Parse(oSqlDataReader["QuestionCategoryID"].ToString()); oQuestion.QuestionQuestionType.QuestionTypeID = int.Parse(oSqlDataReader["QuestionTypeID"].ToString()); oListQuestion.Add(oQuestion); } oSqlDataReader.Close(); foreach (Question oQuestionForChoice in oListQuestion) { if (oQuestionForChoice.QuestionQuestionType.QuestionTypeID == 0) { sChoiceSelect = "select ObjectiveAnswer,ObjectiveAnswerIsValid from EX_Objective where ObjectiveQuestionID='" + oQuestionForChoice.QuestionID + "'"; List<Choice> oListChoice = new List<Choice>(); oSqlDataReader = oDAOUtil.GetReader(sChoiceSelect); while (oSqlDataReader.Read()) { //prepare the choices for a particular questtion...... //and populate oListQuestion Choice oChoice = new Choice(); oChoice.ChoiceName = oSqlDataReader["ObjectiveAnswer"].ToString(); //oChoice.ChoiceIsValid = Convert.ToBoolean(oSqlDataReader["ObjectiveAnswerIsValid"].ToString()); oChoice.ChoiceIsValid = false; oListChoice.Add(oChoice); } oSqlDataReader.Close(); oQuestionForChoice.QuestionObjectiveType.ListOfChoices = oListChoice; } } for (i = 0; i < oListQuestion.Count; i++) { CandidateAnswerQuestion oCandidateAnswerQuestion = new CandidateAnswerQuestion(); oCandidateAnswerQuestion.QuestionForCandidateAnswer = oListQuestion[i]; oListCandidateAnswerQuestion.Add(oCandidateAnswerQuestion); } oResult.ResultObject = oListCandidateAnswerQuestion; oResult.ResultMessage = "Load Question for Exam Success..."; oResult.ResultIsSuccess = true; } catch (Exception oEx) { oResult.ResultIsSuccess = false; oResult.ResultMessage = "Exception in Question Load for Exam..."; oResult.ResultException = oEx; logger.Info("Exception LoadQuestionsForACandidateInExamByCategoryAndType CandidateExamProcessDAO+DAO", oEx); } finally { if (oSqlDataReader != null && !oSqlDataReader.IsClosed) { oSqlDataReader.Close(); } } logger.Info("End LoadQuestionsForACandidateInExamByCategoryAndType CandidateExamProcessDAO+DAO"); return oResult; }
/// <summary> /// This method show the questions according to category,type,questionlevel. /// And these questions are shown to setup them for an exam /// </summary> /// <param name="oQuestion"> It takes Question Object </param> /// <param name="oExam"> It takes Exam Object </param> /// <returns> It returns Result Object </returns> public Result QuestionListShowForSetupByQuestionLevel(Question oQuestion, Exam oExam) { logger.Info("Start QuestionListShowForSetupByQuestionLevel QuestionDAO+DAO"); Result oResult = new Result(); DAOUtil oDAOUtil = new DAOUtil(); SqlDataReader oSqlDataReader = null; String sSelect = String.Empty; String sChoiceSelect = String.Empty; List<QuestionSetup> oListQuestionSetup = new List<QuestionSetup>(); try { //sSelect = "select distinct QuestionID,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID," // + " QuestionTypeID,QuestionPossibleAnswerTime,QuestionLabelID,EX_Label.LabelName,EX_Label.LabelPrerequisite" // + " from EX_Question left join EX_Label on EX_Question.QuestionLabelID=EX_Label.LabelID where QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID + // "' and QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "'"; if (oQuestion.QuestionCreator.SystemUserName.ToLower().Equals("administrator")) { //sSelect = "select distinct EX_Question.QuestionID as EntryQuestionID,EX_QuestionGeneration.QuestionID as GeneratedQuestionID,EX_QuestionGeneration.SetupQuestionMark,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID,QuestionTypeID,EX_Question.QuestionPossibleAnswerTime from EX_Question left join EX_QuestionGeneration on EX_Question.QuestionID=EX_QuestionGeneration.QuestionID where EX_Question.QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID + "' and EX_Question.QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "'"; //sSelect = "select distinct QuestionID,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID," + //"QuestionTypeID,QuestionPossibleAnswerTime,QuestionLabelID from EX_Question where QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID + //"' and QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "' and QuestionLabelID='"+oQuestion.QuestionLevel.LevelID+"'"; sSelect = "select distinct QuestionID,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID," + " QuestionTypeID,QuestionPossibleAnswerTime,QuestionLabelID,EX_Label.LabelName,EX_Label.LabelPrerequisite" + " from EX_Question inner join EX_Label on EX_Question.QuestionLabelID=EX_Label.LabelID where QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID + "' and QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "' and QuestionLabelID='" + oQuestion.QuestionLevel.LevelID + "'"; } else { //sSelect = "select distinct EX_Question.QuestionID as EntryQuestionID,EX_QuestionGeneration.QuestionID as GeneratedQuestionID,EX_QuestionGeneration.SetupQuestionMark,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID,QuestionTypeID,EX_Question.QuestionPossibleAnswerTime from EX_Question left join EX_QuestionGeneration on EX_Question.QuestionID=EX_QuestionGeneration.QuestionID where EX_Question.QuestionCreatorID='" + oQuestion.QuestionCreator.SystemUserID + "' and EX_Question.QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID + "' and EX_Question.QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "'"; //sSelect = "select distinct QuestionID,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID," + //"QuestionTypeID,QuestionPossibleAnswerTime,QuestionLabelID from EX_Question where QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID + //"' and QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "' and QuestionLabelID='" + oQuestion.QuestionLevel.LevelID + "'"; sSelect = "select distinct QuestionID,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID," + " QuestionTypeID,QuestionPossibleAnswerTime,QuestionLabelID,EX_Label.LabelName,EX_Label.LabelPrerequisite" + " from EX_Question inner join EX_Label on EX_Question.QuestionLabelID=EX_Label.LabelID where QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID + "' and QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "' and QuestionLabelID='" + oQuestion.QuestionLevel.LevelID + "'"; } oSqlDataReader = oDAOUtil.GetReader(sSelect); while (oSqlDataReader.Read()) { QuestionSetup oPopulatedQuestionSetup = new QuestionSetup(); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionID = new Guid(oSqlDataReader["QuestionID"].ToString()); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionText = oSqlDataReader["QuestionText"].ToString(); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionCreator.SystemUserID = new Guid(oSqlDataReader["QuestionCreatorID"].ToString()); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionDefaultMark = float.Parse(oSqlDataReader["QuestionDefaultMark"].ToString()); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionCategory.CategoryID = int.Parse(oSqlDataReader["QuestionCategoryID"].ToString()); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionQuestionType.QuestionTypeID = int.Parse(oSqlDataReader["QuestionTypeID"].ToString()); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionPossibleAnswerTime = float.Parse(oSqlDataReader["QuestionPossibleAnswerTime"].ToString()); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelID = new Guid(oSqlDataReader["QuestionLabelID"].ToString()); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelName = oSqlDataReader["LabelName"].ToString(); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelDescription = oSqlDataReader["LabelPrerequisite"].ToString(); oPopulatedQuestionSetup.QuestionSetupMark = oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionDefaultMark; oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionIsUsed = false; //if (oSqlDataReader["GeneratedQuestionID"].ToString().Length > 0) //{ // oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionIsUsed = true; //} //if (oSqlDataReader["SetupQuestionMark"].ToString().Length > 0) //{ // oPopulatedQuestionSetup.QuestionSetupMark = float.Parse(oSqlDataReader["SetupQuestionMark"].ToString()); //} oListQuestionSetup.Add(oPopulatedQuestionSetup); } oSqlDataReader.Close(); if (oQuestion.QuestionQuestionType.QuestionTypeID == 0) //enum should be used here { foreach (QuestionSetup oQuestionSetupInList in oListQuestionSetup) { sChoiceSelect = "select ObjectiveAnswer,ObjectiveAnswerIsValid from EX_Objective where ObjectiveQuestionID='" + oQuestionSetupInList.QuestionSetupQuestion.QuestionID + "'"; List<Choice> oListChoice = new List<Choice>(); oSqlDataReader = oDAOUtil.GetReader(sChoiceSelect); while (oSqlDataReader.Read()) { //prepare the choices for a particular questtion...... //and populate oListQuestion Choice oChoice = new Choice(); oChoice.ChoiceName = oSqlDataReader["ObjectiveAnswer"].ToString(); oChoice.ChoiceIsValid = Convert.ToBoolean(oSqlDataReader["ObjectiveAnswerIsValid"].ToString()); oListChoice.Add(oChoice); } oSqlDataReader.Close(); oQuestionSetupInList.QuestionSetupQuestion.QuestionObjectiveType.ListOfChoices = oListChoice; } } foreach (QuestionSetup oQuestionSetupInList in oListQuestionSetup) { sSelect = "select distinct EX_QuestionGeneration.QuestionID as GeneratedQuestionID,EX_QuestionGeneration.SetupQuestionMark from EX_QuestionGeneration where EX_QuestionGeneration.QuestionID='" + oQuestionSetupInList.QuestionSetupQuestion.QuestionID + "' and EX_QuestionGeneration.ExamID='" + oExam.ExamID + "'"; oSqlDataReader = oDAOUtil.GetReader(sSelect); if (oSqlDataReader.HasRows) { oQuestionSetupInList.QuestionSetupQuestion.QuestionIsUsed = true; while (oSqlDataReader.Read()) { if (oSqlDataReader["SetupQuestionMark"].ToString().Length > 0) { oQuestionSetupInList.QuestionSetupMark = float.Parse(oSqlDataReader["SetupQuestionMark"].ToString()); } } } oSqlDataReader.Close(); } oResult.ResultObject = oListQuestionSetup; oResult.ResultMessage = "QuestionListShowForSetupByQuestionLevel Success..."; oResult.ResultIsSuccess = true; } catch (Exception oEx) { oResult.ResultIsSuccess = false; oResult.ResultMessage = "Exception occured during QuestionListShowForSetupByQuestionLevel..."; oResult.ResultException = oEx; logger.Info("Exception QuestionListShowForSetupByQuestionLevel QuestionDAO+DAO", oEx); } finally { if (oSqlDataReader != null && !oSqlDataReader.IsClosed) { oSqlDataReader.Close(); } } logger.Info("End QuestionListShowForSetupByQuestionLevel QuestionDAO+DAO"); return oResult; }
/// <summary> /// This method evaluate objective answers for all candidate of an exam. /// Only the administrator can call this method. /// It evaluates automatically /// </summary> /// <param name="oListCandidateForExamForGrid"> It takes List<CandidateForExam> Object </param> /// <param name="oExam"> It takes Exam Object </param> /// <param name="oSystemUser"> It takes SystemUser Object </param> /// <returns> It returns Result Object </returns> public Result EvaluateObjectiveAnswersForAllCandidateOfAnExma(List<CandidateForExam> oListCandidateForExamForGrid, SystemUser oSystemUser, Exam oExam) { //new CLogger("Start EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Start EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", ELogLevel.Debug); logger.Info("Start EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO"); Result oResult = new Result(); DAOUtil oDAOUtil = new DAOUtil(); SqlDataReader oSqlDataReader = null; String sSelect = String.Empty; try { foreach (CandidateForExam oCandidateForExamInList in oListCandidateForExamForGrid) { List<CandidateAnswerQuestion> oListCandidateAnswerQuestion = new List<CandidateAnswerQuestion>(); oResult = LoadQuestionsForACandidateWhichSetupByAParticularUser(oCandidateForExamInList.CandidateForExamCandidate.CandidateCompositeID, oExam, oSystemUser, true); if (oResult.ResultIsSuccess) { oListCandidateAnswerQuestion = (List<CandidateAnswerQuestion>)oResult.ResultObject; foreach (CandidateAnswerQuestion oCandidateAnswerQuestionInList in oListCandidateAnswerQuestion) { if (oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionQuestionType.QuestionTypeID == 0) { if (oSystemUser.SystemUserName.ToLower().Equals("administrator")) { //sSelect = "select EX_Objective.ObjectiveQuestionID,EX_Objective.ObjectiveAnswer,EX_Objective.ObjectiveAnswerIsValid from EX_Objective inner join EX_Question on EX_Objective.ObjectiveQuestionID = EX_Question.QuestionID inner join EX_QuestionGeneration on EX_Question.QuestionID = EX_QuestionGeneration.QuestionID inner join EX_CandidateExam on EX_CandidateExam.QuestionID=EX_QuestionGeneration.QuestionID where EX_CandidateExam.QuestionID='" + oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionID + "' and EX_CandidateExam.CandidateID='" + oCandidateInList.CandidateCompositeID + "' and EX_CandidateExam.ExamID='" + oExam.ExamID + "' and EX_CandidateExam.QuestionID in (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "' and EX_QuestionGeneration.GeneratorID='" + oSystemUser.SystemUserID + "')"; //sSelect = "select distinct EX_Objective.ObjectiveQuestionID,EX_Objective.ObjectiveAnswer," //+" EX_Objective.ObjectiveAnswerIsValid from EX_Objective inner join EX_Question" //+" on EX_Objective.ObjectiveQuestionID = EX_Question.QuestionID inner join EX_QuestionGeneration" //+" on EX_Question.QuestionID = EX_QuestionGeneration.QuestionID inner join EX_CandidateExam" //+" on EX_CandidateExam.QuestionID=EX_QuestionGeneration.QuestionID" //+" where EX_CandidateExam.QuestionID='" + oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionID + "'" //+" and EX_CandidateExam.CandidateID='" + oCandidateForExamInList.CandidateForExamCandidate.CandidateCompositeID + "'" //+" and EX_CandidateExam.ExamID='" + oExam.ExamID + "' and EX_CandidateExam.QuestionID" //+" in (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration" //+" where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "')"; sSelect = "select EX_Objective.ObjectiveQuestionID,EX_Objective.ObjectiveAnswer," + " EX_Objective.ObjectiveAnswerIsValid from EX_Objective inner join EX_CandidateExam" + " on EX_CandidateExam.QuestionID=EX_Objective.ObjectiveQuestionID" + " where EX_CandidateExam.QuestionID='" + oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionID + "'" + " and EX_CandidateExam.CandidateID='" + oCandidateForExamInList.CandidateForExamCandidate.CandidateCompositeID + "'" + " and EX_CandidateExam.ExamID='" + oExam.ExamID + "' and EX_CandidateExam.QuestionID" + " in (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration" + " where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "')"; } String sCheckValid = String.Empty; String sCheckName = String.Empty; List<Choice> oListChoices = new List<Choice>(); oSqlDataReader = oDAOUtil.GetReader(sSelect); while (oSqlDataReader.Read()) { Choice oChoice = new Choice(); oChoice.ChoiceIsValid = Boolean.Parse(oSqlDataReader["ObjectiveAnswerIsValid"].ToString()); oChoice.ChoiceName = oSqlDataReader["ObjectiveAnswer"].ToString(); oListChoices.Add(oChoice); } oSqlDataReader.Close(); oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionObjectiveType.ListOfChoices = oListChoices; } } oCandidateForExamInList.CadidateCandidateExam.CandidateAnsweredQuestions = oListCandidateAnswerQuestion; } } oResult.ResultObject = oListCandidateForExamForGrid; oResult.ResultMessage = "Objective answers are evaluated for all candidate of this exam..."; oResult.ResultIsSuccess = true; } catch (Exception oEx) { oResult.ResultIsSuccess = false; oResult.ResultException = oEx; oResult.ResultMessage = "Exception occured at evaluation of objective answers for all candidate of this exam..."; logger.Info("Exception EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", oEx); //new CLogger("Exception EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Exception EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", ELogLevel.Debug, oEx); } finally { if (oSqlDataReader!=null && !oSqlDataReader.IsClosed) { oSqlDataReader.Close(); } } //new CLogger("Out EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Out EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", ELogLevel.Debug); ; logger.Info("End EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO"); return oResult; }
public Result LoadAllQuestionsOfAnExam(Exam oSelectedExam) { logger.Info("Start LoadAllQuestionsOfAnExam QuestionDAO+DAO"); Result oResult = new Result(); DAOUtil oDAOUtil = new DAOUtil(); SqlDataReader oSqlDataReader = null; String sSelect = String.Empty; List<QuestionSetup> oListQuestionSetup = new List<QuestionSetup>(); try { sSelect="select distinct EX_QuestionGeneration.ExamID," +" EX_QuestionGeneration.SetupQuestionMark," +" EX_QuestionGeneration.GeneratorID," +" EX_Question.QuestionID," +" EX_Question.QuestionText,EX_Question.QuestionTypeID," +" EX_Question.QuestionPossibleAnswerTime," +" EX_Label.LabelID," +" EX_Label.LabelName," +" EX_Category.CategoryID,EX_Category.CategoryName" +" from EX_QuestionGeneration,EX_Question,EX_Category,EX_Label" +" where EX_Question.QuestionLabelID=EX_Label.LabelID" +" and EX_Question.QuestionCategoryID=EX_Category.CategoryID" +" and EX_Question.QuestionID=EX_QuestionGeneration.QuestionID" +" and EX_QuestionGeneration.ExamID='" + oSelectedExam.ExamID + "'" +" order by EX_Category.CategoryName,EX_Label.LabelName,EX_Question.QuestionTypeID asc"; oSqlDataReader = oDAOUtil.GetReader(sSelect); while (oSqlDataReader.Read()) { QuestionSetup oPopulatedQuestionSetup = new QuestionSetup(); oPopulatedQuestionSetup.QuestionSetupExam.ExamID = new Guid(oSqlDataReader["ExamID"].ToString()); oPopulatedQuestionSetup.QuestionSetupMark = float.Parse(oSqlDataReader["SetupQuestionMark"].ToString()); oPopulatedQuestionSetup.QuestionSetupSystemUser.SystemUserID = new Guid(oSqlDataReader["GeneratorID"].ToString()); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionID = new Guid(oSqlDataReader["QuestionID"].ToString()); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionText = oSqlDataReader["QuestionText"].ToString(); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionQuestionType.QuestionTypeID = int.Parse(oSqlDataReader["QuestionTypeID"].ToString()); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionPossibleAnswerTime = float.Parse(oSqlDataReader["QuestionPossibleAnswerTime"].ToString()); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelID = new Guid(oSqlDataReader["LabelID"].ToString()); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelName = oSqlDataReader["LabelName"].ToString(); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionCategory.CategoryID = int.Parse(oSqlDataReader["CategoryID"].ToString()); oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionCategory.CategoryName = oSqlDataReader["CategoryName"].ToString(); oListQuestionSetup.Add(oPopulatedQuestionSetup); } oSqlDataReader.Close(); foreach (QuestionSetup oQuestionSetupInList in oListQuestionSetup) { if (oQuestionSetupInList.QuestionSetupQuestion.QuestionQuestionType.QuestionTypeID == 0) { sSelect = "select EX_Objective.ObjectiveQuestionID,EX_Objective.ObjectiveAnswer," +" EX_Objective.ObjectiveAnswerIsValid from EX_Objective" + " where EX_Objective.ObjectiveQuestionID = '" + oQuestionSetupInList.QuestionSetupQuestion.QuestionID + "'"; List<Choice> oListChoice = new List<Choice>(); oSqlDataReader = oDAOUtil.GetReader(sSelect); while (oSqlDataReader.Read()) { Choice oChoice = new Choice(); oChoice.ChoiceName = oSqlDataReader["ObjectiveAnswer"].ToString(); oChoice.ChoiceIsValid = Convert.ToBoolean(oSqlDataReader["ObjectiveAnswerIsValid"].ToString()); oListChoice.Add(oChoice); } oSqlDataReader.Close(); oQuestionSetupInList.QuestionSetupQuestion.QuestionObjectiveType.ListOfChoices = oListChoice; } } oResult.ResultObject = oListQuestionSetup; oResult.ResultMessage = "LoadAllQuestionsOfAnExam success..."; oResult.ResultIsSuccess = true; } catch (Exception oEx) { oResult.ResultIsSuccess = false; oResult.ResultMessage = "Exception occured during LoadAllQuestionsOfAnExam..."; oResult.ResultException = oEx; logger.Info("Exception LoadAllQuestionsOfAnExam QuestionDAO+DAO", oEx); } finally { if (oSqlDataReader != null && !oSqlDataReader.IsClosed) { oSqlDataReader.Close(); } } logger.Info("End LoadAllQuestionsOfAnExam QuestionDAO+DAO"); return oResult; }
/// <summary> /// This method Load questions at the time of candidate evaluation, if that system user setup questions. /// The system user can see the questions which are setup by him /// Administrator can always see all questions /// </summary> /// <param name="sCandidateID"> It takes string Object </param> /// <param name="oExam"> It takes Exam Object </param> /// <param name="oSystemUser"> It takes SystemUser Object </param> /// <param name="flagForEvaluation"> It takes Boolean Object.It is only to show the Objective answer Name </param> /// <returns> It returns Result Object </returns> public Result LoadQuestionsForACandidateWhichSetupByAParticularUser(string sCandidateID, Exam oExam, SystemUser oSystemUser, Boolean flagForEvaluation) { //new CLogger("Start LoadQuestionsForACandidateWhichSetupByAParticularUser EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Start LoadQuestionsForACandidateWhichSetupByAParticularUser EvaluateProcessDAO+DAO", ELogLevel.Debug); logger.Info("Start LoadQuestionsForACandidateWhichSetupByAParticularUser EvaluateProcessDAO+DAO"); Result oResult = new Result(); DAOUtil oDAOUtil = new DAOUtil(); SqlDataReader oSqlDataReader = null; String sSelect = String.Empty; String sTempAnswer = String.Empty; String sObtainMark = String.Empty; List<CandidateAnswerQuestion> oListCandidateAnswerQuestion = new List<CandidateAnswerQuestion>(); float f =0f; try { if (oSystemUser.SystemUserName.ToLower().Equals("administrator")) { //sSelect = "select EX_CandidateExam.AnswerStringOrBits from EX_CandidateExam inner join EX_QuestionGeneration on EX_CandidateExam.QuestionID=EX_QuestionGeneration.QuestionID where EX_CandidateExam.CandidateID='" + sCandidateID + "' and EX_CandidateExam.ExamID='"+oExam.ExamID+"' and EX_CandidateExam.QuestionID in (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "')"; //sSelect = "select EX_CandidateExam.AnswerStringOrBits,EX_Question.QuestionID,EX_Question.QuestionText,EX_Question.QuestionDefaultMark,EX_Question.QuestionTypeID,EX_Question.QuestionCategoryID from EX_CandidateExam inner join EX_QuestionGeneration on EX_CandidateExam.QuestionID=EX_QuestionGeneration.QuestionID inner join EX_Question on EX_Question.QuestionID = EX_QuestionGeneration.QuestionID where EX_CandidateExam.CandidateID='" + sCandidateID + "' and EX_CandidateExam.ExamID='" + oExam.ExamID + "' and EX_CandidateExam.QuestionID in (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "') order by EX_Question.QuestionCategoryID,EX_Question.QuestionTypeID asc"; //sSelect = "select distinct EX_CandidateExam.AnswerStringOrBits,EX_CandidateExam.ObtainMark, EX_Question.QuestionID,EX_Question.QuestionText,EX_Question.QuestionDefaultMark,EX_Question.QuestionTypeID,EX_Question.QuestionCategoryID from EX_Question inner join EX_QuestionGeneration on EX_Question.QuestionID = EX_QuestionGeneration.QuestionID inner join EX_CandidateExam on EX_CandidateExam.QuestionID=EX_QuestionGeneration.QuestionID where EX_CandidateExam.CandidateID='" + sCandidateID + "' and EX_CandidateExam.ExamID='" + oExam.ExamID + "' and EX_CandidateExam.QuestionID in (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "') order by EX_Question.QuestionCategoryID,EX_Question.QuestionTypeID asc"; sSelect = "select distinct EX_CandidateExam.AnswerStringOrBits,EX_CandidateExam.ObtainMark," +" EX_CandidateExam.AnswerAttachmentPath, EX_Question.QuestionID," +" EX_Question.QuestionText,EX_QuestionGeneration.SetupQuestionMark," +" EX_Question.QuestionTypeID,EX_Question.QuestionCategoryID" +" from EX_Question inner join EX_QuestionGeneration on" +" EX_Question.QuestionID = EX_QuestionGeneration.QuestionID" +" inner join EX_CandidateExam on EX_CandidateExam.QuestionID=EX_QuestionGeneration.QuestionID" +" where EX_CandidateExam.CandidateID='" + sCandidateID + "'" +" and EX_QuestionGeneration.ExamID='" + oExam.ExamID + "'" +" and EX_CandidateExam.ExamID='" + oExam.ExamID + "' and" +" EX_CandidateExam.QuestionID in" +" (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration" +" where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "')" +" order by EX_Question.QuestionCategoryID,EX_Question.QuestionTypeID asc"; } else { //sSelect = "select EX_CandidateExam.AnswerStringOrBits from EX_CandidateExam inner join EX_QuestionGeneration on EX_CandidateExam.QuestionID=EX_QuestionGeneration.QuestionID where EX_CandidateExam.CandidateID='" + sCandidateID + "' and EX_CandidateExam.ExamID='" + oExam.ExamID + "' and EX_CandidateExam.QuestionID in (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "' and EX_QuestionGeneration.GeneratorID='" + oSystemUser.SystemUserID + "')"; //sSelect = "select EX_CandidateExam.AnswerStringOrBits,EX_Question.QuestionID,EX_Question.QuestionText,EX_Question.QuestionDefaultMark,EX_Question.QuestionTypeID,EX_Question.QuestionCategoryID from EX_CandidateExam inner join EX_QuestionGeneration on EX_CandidateExam.QuestionID=EX_QuestionGeneration.QuestionID inner join EX_Question on EX_Question.QuestionID = EX_QuestionGeneration.QuestionID where EX_CandidateExam.CandidateID='" + sCandidateID + "' and EX_CandidateExam.ExamID='" + oExam.ExamID + "' and EX_CandidateExam.QuestionID in (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "' and EX_QuestionGeneration.GeneratorID='" + oSystemUser.SystemUserID + "') order by EX_Question.QuestionCategoryID,EX_Question.QuestionTypeID asc"; //sSelect = "select distinct EX_CandidateExam.AnswerStringOrBits,EX_CandidateExam.ObtainMark, EX_Question.QuestionID,EX_Question.QuestionText,EX_Question.QuestionDefaultMark,EX_Question.QuestionTypeID,EX_Question.QuestionCategoryID from EX_Question inner join EX_QuestionGeneration on EX_Question.QuestionID = EX_QuestionGeneration.QuestionID inner join EX_CandidateExam on EX_CandidateExam.QuestionID=EX_QuestionGeneration.QuestionID where EX_CandidateExam.CandidateID='" + sCandidateID + "' and EX_CandidateExam.ExamID='" + oExam.ExamID + "' and EX_CandidateExam.QuestionID in (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "' and EX_QuestionGeneration.GeneratorID='" + oSystemUser.SystemUserID + "') order by EX_Question.QuestionCategoryID,EX_Question.QuestionTypeID asc"; sSelect = "select distinct EX_CandidateExam.AnswerStringOrBits,EX_CandidateExam.ObtainMark," +" EX_CandidateExam.AnswerAttachmentPath, EX_Question.QuestionID," +" EX_Question.QuestionText,EX_QuestionGeneration.SetupQuestionMark," +" EX_Question.QuestionTypeID,EX_Question.QuestionCategoryID" +" from EX_Question inner join EX_QuestionGeneration on EX_Question.QuestionID = EX_QuestionGeneration.QuestionID" +" inner join EX_CandidateExam on EX_CandidateExam.QuestionID=EX_QuestionGeneration.QuestionID" +" where EX_CandidateExam.CandidateID='" + sCandidateID + "'" +" and EX_QuestionGeneration.ExamID='" + oExam.ExamID + "'" +" and EX_CandidateExam.ExamID='" + oExam.ExamID + "' and" +" EX_CandidateExam.QuestionID in" +" (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration" +" where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "' and" +" EX_QuestionGeneration.GeneratorID='" + oSystemUser.SystemUserID + "')" +" order by EX_Question.QuestionCategoryID,EX_Question.QuestionTypeID asc"; } oSqlDataReader = oDAOUtil.GetReader(sSelect); while (oSqlDataReader.Read()) { CandidateAnswerQuestion oCandidateAnswerQuestion = new CandidateAnswerQuestion(); sTempAnswer = oSqlDataReader["AnswerStringOrBits"].ToString(); sObtainMark = oSqlDataReader["ObtainMark"].ToString(); if (float.TryParse(sObtainMark, out f)) { oCandidateAnswerQuestion.ObtainMark = float.Parse(sObtainMark); } else { oCandidateAnswerQuestion.ObtainMark = 0f; } oCandidateAnswerQuestion.sAnswerAttachFilePath = oSqlDataReader["AnswerAttachmentPath"].ToString(); oCandidateAnswerQuestion.QuestionForCandidateAnswer.QuestionID = new Guid(oSqlDataReader["QuestionID"].ToString()); oCandidateAnswerQuestion.QuestionForCandidateAnswer.QuestionText = oSqlDataReader["QuestionText"].ToString(); oCandidateAnswerQuestion.QuestionForCandidateAnswer.QuestionDefaultMark = float.Parse(oSqlDataReader["SetupQuestionMark"].ToString()); oCandidateAnswerQuestion.QuestionForCandidateAnswer.QuestionCategory.CategoryID = int.Parse(oSqlDataReader["QuestionCategoryID"].ToString()); //Objective@True:True:False:True: //Descriptive@IQ Des Exam: //DES@IQ String sTempObjective = String.Empty; String sCheck = String.Empty; List<Choice> oListAnswers = new List<Choice>(); int iColonIndex = 0; if (sTempAnswer.IndexOf("Objective@", 0)>=0) { sTempObjective = sTempAnswer.Substring(sTempAnswer.IndexOf("@",0)+1); while (sTempObjective != String.Empty) { iColonIndex = sTempObjective.IndexOf(":"); if(iColonIndex>=0) { sCheck = sTempObjective.Substring(0, iColonIndex); Choice oChoice = new Choice(); oChoice.ChoiceIsValid = Boolean.Parse(sCheck); oListAnswers.Add(oChoice); if (iColonIndex + 1 < sTempObjective.Length) { sTempObjective = sTempObjective.Substring(iColonIndex + 1, sTempObjective.Length - iColonIndex - 1); } else { sTempObjective = String.Empty; } } } oCandidateAnswerQuestion.QuestionForCandidateAnswer.QuestionObjectiveType.ListOfAnswers = oListAnswers; oCandidateAnswerQuestion.QuestionForCandidateAnswer.QuestionQuestionType.QuestionTypeID = 0; } else if (sTempAnswer.IndexOf("Descriptive@", 0)>=0) { oCandidateAnswerQuestion.DescriptiveQuestionAnswerText = sTempAnswer.Substring(sTempAnswer.IndexOf("@",0)+1,sTempAnswer.Length-(sTempAnswer.IndexOf("@",0)+1)-1); oCandidateAnswerQuestion.QuestionForCandidateAnswer.QuestionQuestionType.QuestionTypeID = 1; } oListCandidateAnswerQuestion.Add(oCandidateAnswerQuestion); } oSqlDataReader.Close(); //this is for show the Objective answer Name if (!flagForEvaluation) { foreach (CandidateAnswerQuestion oCandidateAnswerQuestionInList in oListCandidateAnswerQuestion) { if (oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionQuestionType.QuestionTypeID == 0) { if (oSystemUser.SystemUserName.ToLower().Equals("administrator")) { sSelect = "select EX_Objective.ObjectiveQuestionID,EX_Objective.ObjectiveAnswer," + " EX_Objective.ObjectiveAnswerIsValid" + " from EX_Objective where" + " EX_Objective.ObjectiveQuestionID='" + oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionID + "'"; } else { sSelect = "select EX_Objective.ObjectiveQuestionID,EX_Objective.ObjectiveAnswer," + " EX_Objective.ObjectiveAnswerIsValid" + " from EX_Objective where" + " EX_Objective.ObjectiveQuestionID='" + oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionID + "'"; } //String sCheckValid = String.Empty; //String sCheckName = String.Empty; List<Choice> oListChoices = new List<Choice>(); oSqlDataReader = oDAOUtil.GetReader(sSelect); int iChoiceCounter = -1; while (oSqlDataReader.Read()) { iChoiceCounter = iChoiceCounter + 1; Choice oChoice = new Choice(); oChoice.ChoiceIsValid = Boolean.Parse(oSqlDataReader["ObjectiveAnswerIsValid"].ToString()); oListChoices.Add(oChoice); //oChoice.ChoiceName = oSqlDataReader["ObjectiveAnswer"].ToString(); oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionObjectiveType.ListOfAnswers[iChoiceCounter].ChoiceName = oSqlDataReader["ObjectiveAnswer"].ToString(); } oSqlDataReader.Close(); oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionObjectiveType.ListOfChoices = oListChoices; } } } oResult.ResultObject = oListCandidateAnswerQuestion; oResult.ResultMessage = "LoadQuestionsForACandidateWhichSetupByAParticularUser Success..."; oResult.ResultIsSuccess = true; } catch (Exception oEx) { oResult.ResultIsSuccess = false; oResult.ResultException = oEx; oResult.ResultMessage = "LoadQuestionsForACandidateWhichSetupByAParticularUser Exception..."; logger.Info("Exception LoadQuestionsForACandidateWhichSetupByAParticularUser EvaluateProcessDAO+DAO", oEx); //new CLogger("Exception LoadQuestionsForACandidateWhichSetupByAParticularUser EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Exception LoadQuestionsForACandidateWhichSetupByAParticularUser EvaluateProcessDAO+DAO", ELogLevel.Debug, oEx); } finally { if (oSqlDataReader!=null && !oSqlDataReader.IsClosed) { oSqlDataReader.Close(); } } //new CLogger("Out LoadQuestionsForACandidateWhichSetupByAParticularUser EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Out LoadQuestionsForACandidateWhichSetupByAParticularUser EvaluateProcessDAO+DAO", ELogLevel.Debug); ; logger.Info("End LoadQuestionsForACandidateWhichSetupByAParticularUser EvaluateProcessDAO+DAO"); return oResult; }