public void BindData() { if (CurrentMember != null) { try { MembershipManager mgr = new MembershipManager(); CurrentMember = mgr.QuizResults_FillMember(CurrentMember); savedQuiz = CurrentMember.CompletedQuizes.Where(i => i.QuizID == Sitecore.Context.Item.ID.ToGuid()).FirstOrDefault<Quiz>(); } catch { } } ObjChecklistArticle = new ChecklistArticlePageItem(Sitecore.Context.Item); if (ObjChecklistArticle != null) { PageUrl = ObjChecklistArticle.GetUrl(); if (ObjChecklistArticle.ShowPromotionalControl.Checked == true) { sbSidebarPromo.Visible = true; } else { sbSidebarPromo.Visible = false; } // Create the checklist from base object if (ObjChecklistArticle.InnerItem.GetChildren() != null) { //Get HeaderItems for Header Repeater List<HeaderCheckboxItem> AllHeaders = ChecklistArticlePageItem.GetAllHeaderItem(ObjChecklistArticle); if (AllHeaders != null) { rptHeaderChkbox.DataSource = AllHeaders; rptHeaderChkbox.DataBind(); } } } }
private void SetUpQuestionsTracker() { Quiz savedQuiz = null; if (CurrentMember != null) { try { MembershipManager mgr = new MembershipManager(); CurrentMember = mgr.QuizResults_FillMember(CurrentMember); savedQuiz = CurrentMember.CompletedQuizes.Where(i => i.QuizID == Sitecore.Context.Item.ID.ToGuid()).FirstOrDefault<Quiz>(); } catch { } } Dictionary<string, QuestionAnswer> answeredQuestions = new Dictionary<string, QuestionAnswer>(); foreach (Item i in Pages) { foreach (Item j in i.Children) { QuizItem potentialPreviousAnswer = null; if (savedQuiz != null) potentialPreviousAnswer = savedQuiz.MemberAnswers.Where(k => k.QuestionId == j.ID.ToGuid()).FirstOrDefault(); if (j.IsOfType(AssessmentTrueFalseItem.TemplateId) || j.IsOfType(AssessmentMultipleChoiceItem.TemplateId)) { string answerValue = ""; if (potentialPreviousAnswer != null) answerValue = potentialPreviousAnswer.AnswerValue; answeredQuestions.Add(j.ID.ToString(), new QuestionAnswer(j, answerValue)); } } } Session["AnsweredQuestions"] = answeredQuestions; }
protected void btnQuizReader_Click(object sender, EventArgs e) { Member m = new Member(); m.MemberId = Guid.Parse("93e4c02c-3d3d-4ccd-95a3-180bb513e543"); //throw away user MembershipManager mgr = new MembershipManager(); //to load up quizes and all of their answer values m = mgr.QuizResults_FillMember(m); Quiz quiz = new Quiz(); quiz.QuizID = Guid.NewGuid(); quiz.MemberAnswers.Add(new QuizItem(Guid.Parse("93e4c02c-3d3d-4ccd-95a3-180bb513e333"),"JUNKANSWER1")); quiz.MemberAnswers.Add(new QuizItem(Guid.Parse("93e4c02c-3d3d-4ccd-95a3-180bb513e444"), "JUNKANSWER2")); //to save a quiz to the db mgr.QuizResults_SaveToDb(m.MemberId, quiz); }