def get_context_data(self, **kwargs): displayInConsole(self) # noinspection PyTypeChecker context = super().get_context_data(**kwargs) context['title'] = 'Quiz Result' return context
def form_valid(self, form): displayInConsole(self) result = AnswerResult.create(self.currentProcess, self.QA, form.instance.answer) return FormView.form_valid(self, form)
def getPriorityQuestion(self): displayInConsole(self) if self.quiz_total_result.areAnswersAccounted(): return self.findPriorityQuestion() else: return self.quiz.getNextQuestion(self.current_question)
def getAvailState(self, state): displayInConsole(self) if state == 'visibility': return self.visible_to elif state == 'modification': return self.modified_by
def form_valid(self, form): displayInConsole(self) if self.requestExist(form): return super().form_valid(form) else: return super().form_invalid(form)
def setWeight(self, resultAvail, answerBool): displayInConsole(self) if resultAvail: self.setInitWeight(answerBool) else: self.manageWeight(answerBool)
def isLastQuestion(self): displayInConsole(self) if self.type == 'seq': return self.quiz.isLastQuestion(self.current_question) else: return self.isChoice()
def create(quizTotalResult, qa, answerBool): displayInConsole('AnswerTtl', True) answerTotalResult, resultBool = AnswerTtl.objects.get_or_create( quiz_total_result=quizTotalResult, question=qa) answerTotalResult.setWeight(resultBool, answerBool)
def curPathID(request, target): displayInConsole('', True) if request.path == target: return 'curPage' else: return 'othPage'
def isOwnersFriend(self, user): displayInConsole(self) if self.getOwnersFriends(): return True if user in self.ownersFriends else False else: return False
def get_object(self, queryset=None): displayInConsole(self) obj = SingleObjectMixin.get_object(self, queryset=Quiz.objects.all()) if obj.isAvailableFor(self.request.user, 'visibility'): return obj
def get_context_data(self, **kwargs): displayInConsole(self) context = super(ViewQuestionBase, self).get_context_data(**kwargs) context['title'] = 'Quiz Question' return context
def hasRequests(self): displayInConsole(self) if self.fields['requests'].queryset.count() > 0: return True else: return False
def findPriorityQuestion(self): displayInConsole(self) for answerTotal in self.quiz_total_result.getAnswerResults(): try: return self.choices.get(id=answerTotal.question.id) except: continue
def update(self): displayInConsole(self) if not self.isLastQuestion(): self.nextQuestion() else: self.complete = True self.save()
def checkProfile(request): displayInConsole('', True) if 'profile_id' not in request.session: request.session['profile_id'] = Profile.objects.create(user=None).id # print('[CONSOLE REPORT]Current Session Profile ID:' + str(request.session['profile_id'])) return ''
def question_init(self): displayInConsole(self) self.currentProcess = QuizResult.get(self.request.user, self.kwargs['id'], self.kwargs['type']) self.quiz = Quiz.objects.get(id=self.kwargs['id']) self.QA = self.currentProcess.current_question
def approveRequest(self, curRequest): displayInConsole(self) profile = Profile.objects.get(user=self.request.user) new_friend = curRequest.from_user new_friend_profile = Profile.objects.get(user=new_friend) profile.friends.add(new_friend) new_friend_profile.friends.add(self.request.user)
def get_context_data(self, **kwargs): displayInConsole(self) # noinspection PyTypeChecker context = super().get_context_data(**kwargs) context['title'] = 'Quiz Total' context['answer_results'] = self.object.getAnswerResults() return context
def getOwnersFriends(self): displayInConsole(self) if self.owner != None: self.ownersFriends = Profile.getUserFriends(self.owner) return True else: False
def get_object(self): displayInConsole(self) self.getProfile() if not self.request.user.is_anonymous: self.object = Profile.objects.get(user=self.request.user) return self.object
def form_valid(self, form): displayInConsole(self) quizID = self.kwargs['pk'] form.instance.quiz_id = quizID cur_quiz = Quiz.objects.get(id=quizID) questionCount = QA.objects.filter(quiz=cur_quiz).count() form.instance.number = questionCount + 1 return super(ViewQuestionCreate, self).form_valid(form)
def handleRequest(self, request): displayInConsole(self) curRequest = FriendRequest.objects.get(id=request.POST['requests']) if 'approve' in request.POST: self.approveRequest(curRequest) curRequest.delete()
def get_context_data(self, **kwargs): displayInConsole(self) # context = FormView.get_context_data(self, **kwargs) context = super().get_context_data(**kwargs) context['title'] = 'Quiz' context['quiz'] = self.quiz context['question'] = self.QA.question return context
def dispatch(self, request, *args, **kwargs): displayInConsole(self) del request.session['profile_id'] return LogoutView.dispatch(self, request, *args, **kwargs) #
def isChoice(self): displayInConsole(self) choices = self.getQuestionChoices() if choices.count() != 0: self.choices = choices return False else: return True
def get_context_data(self, **kwargs): displayInConsole(self) context = super().get_context_data(**kwargs) context['title'] = 'Quiz List' if self.request.session.get('redirect_msg'): context['msg'] = self.request.session['redirect_msg'] self.request.session['redirect_msg'] = None return context
def listAvailItems(self): displayInConsole(self) visibleItems = [] for item in ListView.get_queryset(self): if item.isAvailableFor(self.request.user, 'visibility'): visibleItems.append(item.id) return visibleItems
def getRNGPriorityQuestion(self): displayInConsole(self) fitsInRange = False while not fitsInRange: numInRange = random.randint(0, self.getRangeMax()) for choice in self.choices: choiceTotalResult = self.getAnswerTtl().get(question=choice) if QuizTtl.isNumInAnswerRange(choiceTotalResult, numInRange): return choice
def get_context_data(self, **kwargs): displayInConsole(self) context = super().get_context_data(**kwargs) context['quiz'] = self.object context['title'] = 'Quiz Info' if self.object.isAvailableFor(self.request.user, 'modification'): context['form'] = FormQuizQA() return context