/// <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; }
private void Initialization() { this.oExam = new Exam(); this.oQuestion = new Question(); this.oSystemUser = new SystemUser(); }
public Result UpdateQuestion(Question oQuestion) { //new CLogger("Start UpdateQuestion QuestionBO+BO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Start UpdateQuestion QuestionBO+BO", ELogLevel.Debug); Result oResult = new Result(); QuestionDAO oQuestionDAO = new QuestionDAO(); try { oResult = oQuestionDAO.UpdateQuestion(oQuestion); } catch (Exception oEx) { oResult.ResultIsSuccess = false; oResult.ResultMessage = "Exception occured during Question Update.."; oResult.ResultException = oEx; //new CLogger("Exception UpdateQuestion QuestionBO+BO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Exception UpdateQuestion QuestionBO+BO", ELogLevel.Debug, oEx); } //new CLogger("Out UpdateQuestion QuestionBO+BO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Out UpdateQuestion QuestionBO+BO", ELogLevel.Debug); return oResult; }
private void Initialization() { this.oQuestion = new Question(); this.AnswerText = String.Empty; //this.oFileUpload = new FileUpload(); }
public Result QuestionListShowForSetupByQuestionLevel(Question oQuestion, Exam oExam) { Result oResult = new Result(); QuestionDAO oQuestionDAO = new QuestionDAO(); try { oResult = oQuestionDAO.QuestionListShowForSetupByQuestionLevel(oQuestion, oExam); } catch (Exception oEx) { oResult.ResultIsSuccess = false; oResult.ResultMessage = "Exception occured during QuestionListShowForSetupByQuestionLevel.."; oResult.ResultException = oEx; } return oResult; }
public Result QuestionListShowForSetup(Question oQuestion,Exam oExam) { //new CLogger("Start QuestionListShowForSetup QuestionBO+BO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Start QuestionListShowForSetup QuestionBO+BO", ELogLevel.Debug); Result oResult = new Result(); QuestionDAO oQuestionDAO = new QuestionDAO(); try { oResult = oQuestionDAO.QuestionListShowForSetup(oQuestion,oExam); } catch (Exception oEx) { oResult.ResultIsSuccess = false; oResult.ResultMessage = "Exception occured during QuestionListShowForSetup.."; oResult.ResultException = oEx; //new CLogger("Exception QuestionListShowForSetup QuestionBO+BO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Exception QuestionListShowForSetup QuestionBO+BO", ELogLevel.Debug, oEx); } //new CLogger("Out QuestionListShowForSetup QuestionBO+BO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Out QuestionListShowForSetup QuestionBO+BO", ELogLevel.Debug); 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; }
//r /// <summary> /// This method inserts a Question /// </summary> /// <param name="oQuestion"> It takes Question Object </param> /// <returns> It returns Result Object </returns> public Result QuestionEntry(Question oQuestion) { logger.Info("Start QuestionEntry QuestionDAO+DAO"); Result oResult = new Result(); DAOUtil oDAOUtil = new DAOUtil(); String sInsert = String.Empty; List<String> oListInsert = new List<String>(); int i=0; int iBit = 0; try { oQuestion.QuestionID = Guid.NewGuid(); sInsert = "insert into EX_Question(QuestionID,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID,QuestionTypeID,QuestionPossibleAnswerTime,QuestionLabelID) values('" + oQuestion.QuestionID + "','" + oQuestion.QuestionText + "','" + oQuestion.QuestionCreator.SystemUserID + "','" + oQuestion.QuestionDefaultMark + "','" + oQuestion.QuestionCategory.CategoryID + "','" + oQuestion.QuestionQuestionType.QuestionTypeID + "','" + oQuestion.QuestionPossibleAnswerTime+"','"+oQuestion.QuestionLevel.LevelID + "')"; oListInsert.Add(sInsert); if (oQuestion.QuestionQuestionType.QuestionTypeID == 0) { for (i = 0; i < oQuestion.QuestionObjectiveType.ListOfChoices.Count; i++) { iBit = 0; if (oQuestion.QuestionObjectiveType.ListOfChoices[i].ChoiceIsValid) { iBit = 1; } sInsert = "insert into EX_Objective(ObjectiveQuestionID,ObjectiveAnswer,ObjectiveAnswerIsValid) values('" + oQuestion.QuestionID + "','" + oQuestion.QuestionObjectiveType.ListOfChoices[i].ChoiceName + "','" + iBit + "')"; oListInsert.Add(sInsert); } } if (oDAOUtil.ExecuteNonQuery(oListInsert)) { oResult.ResultObject = oQuestion; oResult.ResultMessage = "Question Entry Success..."; oResult.ResultIsSuccess = true; } else { oResult.ResultIsSuccess = false; oResult.ResultMessage = "Question Entry Failed..."; } } catch (Exception oEx) { oResult.ResultIsSuccess = false; oResult.ResultMessage = "Exception occured during Question Entry..."; oResult.ResultException = oEx; logger.Info("Exception QuestionEntry QuestionDAO+DAO", oEx); } logger.Info("End QuestionEntry QuestionDAO+DAO"); return oResult; }
//r /// <summary> /// This method Update a Question /// </summary> /// <param name="oQuestion"> It takes Question Object </param> /// <returns> It returns Result Object </returns> public Result UpdateQuestion(Question oQuestion) { logger.Info("Start UpdateQuestion QuestionDAO+DAO"); Result oResult = new Result(); DAOUtil oDAOUtil = new DAOUtil(); List<String> oListString = new List<String>(); String sString = String.Empty; int iBit = 0; try { sString = "update EX_Question set QuestionDefaultMark='" + oQuestion.QuestionDefaultMark + "',QuestionPossibleAnswerTime='"+oQuestion.QuestionPossibleAnswerTime +"' where QuestionID='" + oQuestion.QuestionID + "'"; oListString.Add(sString); //if (!oQuestion.QuestionIsDescriptive) if (oQuestion.QuestionQuestionType.QuestionTypeID==0) { sString = "delete from EX_Objective where ObjectiveQuestionID='" + oQuestion.QuestionID + "'"; oListString.Add(sString); foreach (Choice oChoice in oQuestion.QuestionObjectiveType.ListOfChoices) { iBit = 0; if (oChoice.ChoiceIsValid) { iBit = 1; } sString = "insert into EX_Objective(ObjectiveQuestionID,ObjectiveAnswer,ObjectiveAnswerIsValid) values('" + oQuestion.QuestionID + "','" + oChoice.ChoiceName + "','" + iBit + "')"; oListString.Add(sString); } } if (oDAOUtil.ExecuteNonQuery(oListString)) { oResult.ResultObject = oQuestion; oResult.ResultMessage = "Question Update Success..."; oResult.ResultIsSuccess = true; } else { oResult.ResultIsSuccess = false; oResult.ResultMessage = "Question Update Failed..."; } } catch (Exception oEx) { oResult.ResultIsSuccess = false; oResult.ResultException = oEx; oResult.ResultMessage = "Exception occured during Question Update..."; logger.Info("Exception UpdateQuestion QuestionDAO+DAO", oEx); } logger.Info("End UpdateQuestion QuestionDAO+DAO"); return oResult; }