def get_context(self, **kwargs): context = super(TopBarWidget, self).get_context(**kwargs) context["share_url"] = utils.share_url(self.request) context["share_text"] = utils.share_text(self.request) percent = questions.get_total_score(self.request.session) context["score"] = percent context["slogan"] = utils.get_slogan(percent) return context
def get_context_data(self, **kwargs): context = super(QuizFinishedView, self).get_context_data(**kwargs) if "share" in kwargs or "hash" not in kwargs: context["points"] = questions.get_total_score(self.request.session) context["show_link"] = True else: context["points"] = get_object_or_404( models.Score, hash=kwargs["hash"] ).score return context
def get_context_data(self, **kwargs): context = super(QuizFinishedView, self).get_context_data(**kwargs) context["footer"] = widgets.FooterWidget(links=self.footer_links) answers = questions.get_all_answers(self.request.session) context["answers"] = answers percent = questions.get_total_score(self.request.session) context["score"] = percent context["slogan"] = utils.get_slogan(percent) context["share_url"] = utils.share_url(self.request) context["share_text"] = utils.share_text(self.request) return context
def get_context_data(self, **kwargs): context = super(NavigationView, self).get_context_data(**kwargs) score = questions.get_total_score(self.request.session) context["footer"] = widgets.FooterWidget(links=self.footer_links) context["top_bar"] = widgets.TopBarWidget( title=self.title, title_icon=self.title_icon, title_alt=self.title_alt, back_url=self.back_url, score=score, template=self.top_bar_template, request=self.request ) return context
def get_context_data(self, **kwargs): context = super(DashboardView, self).get_context_data(**kwargs) current_score = questions.get_total_score(self.request.session) if self.request.session.get("score_at_last_visit", 0) < current_score: self.request.session["score_at_last_visit"] = current_score context["top_bar"].score_changed = True context["categories"] = [ ( cat_name, category, constants.Ellipse( questions.get_category_done_share(cat_name, self.request.session) ), ) for cat_name, category in questions.QUESTIONS.items() ] return context
def get_context_data(self, **kwargs): context = super(DashboardView, self).get_context_data(**kwargs) current_score = questions.get_total_score(self.request.session) if self.request.session.get("score_at_last_visit", 0) < current_score: self.request.session["score_at_last_visit"] = current_score context["top_bar"].score_changed = True categories = [] for cat_name, category in questions.QUESTIONS.items(): categories.append(( cat_name, category, questions.get_category_answers(cat_name, self.request.session), )) context["categories"] = categories return context
def save_score(cls, session): score = cls(score=questions.get_total_score(session), hash=uuid.uuid4().hex) score.save() return score
def test_total_score(self): self.assertEqual( questions.get_total_score(self.session), questions.SCORE_CORRECT * 2 + questions.SCORE_WRONG + questions.SCORE_CATEGORY_COMPLETE, )
def test_total_score(self): self.assertEqual(questions.get_total_score(self.session), 31)