예제 #1
0
    def get_context_data(self, **kwargs):
        displayInConsole(self)

        # noinspection PyTypeChecker
        context = super().get_context_data(**kwargs)
        context['title'] = 'Quiz Result'
        return context
예제 #2
0
    def form_valid(self, form):
        displayInConsole(self)

        result = AnswerResult.create(self.currentProcess, self.QA,
                                     form.instance.answer)

        return FormView.form_valid(self, form)
예제 #3
0
    def getPriorityQuestion(self):
        displayInConsole(self)

        if self.quiz_total_result.areAnswersAccounted():
            return self.findPriorityQuestion()
        else:
            return self.quiz.getNextQuestion(self.current_question)
예제 #4
0
    def getAvailState(self, state):
        displayInConsole(self)

        if state == 'visibility':
            return self.visible_to
        elif state == 'modification':
            return self.modified_by
예제 #5
0
 def form_valid(self, form):
     displayInConsole(self)
     
     if self.requestExist(form):
         return super().form_valid(form)
     else:
         return super().form_invalid(form)
예제 #6
0
    def setWeight(self, resultAvail, answerBool):
        displayInConsole(self)

        if resultAvail:
            self.setInitWeight(answerBool)
        else:
            self.manageWeight(answerBool)
예제 #7
0
    def isLastQuestion(self):
        displayInConsole(self)

        if self.type == 'seq':
            return self.quiz.isLastQuestion(self.current_question)
        else:
            return self.isChoice()
예제 #8
0
    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)
예제 #9
0
def curPathID(request, target):
    displayInConsole('', True)

    if request.path == target:
        return 'curPage'
    else:
        return 'othPage'
예제 #10
0
    def isOwnersFriend(self, user):
        displayInConsole(self)

        if self.getOwnersFriends():
            return True if user in self.ownersFriends else False
        else:
            return False
예제 #11
0
    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
예제 #12
0
    def get_context_data(self, **kwargs):
        displayInConsole(self)

        context = super(ViewQuestionBase, self).get_context_data(**kwargs)
        context['title'] = 'Quiz Question'

        return context
예제 #13
0
 def hasRequests(self):
     displayInConsole(self)
     
     if self.fields['requests'].queryset.count() > 0:
         return True
     else:
         return False
예제 #14
0
    def findPriorityQuestion(self):
        displayInConsole(self)

        for answerTotal in self.quiz_total_result.getAnswerResults():
            try:
                return self.choices.get(id=answerTotal.question.id)
            except:
                continue
예제 #15
0
    def update(self):
        displayInConsole(self)

        if not self.isLastQuestion():
            self.nextQuestion()
        else:
            self.complete = True
            self.save()
예제 #16
0
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 ''
예제 #17
0
    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
예제 #18
0
 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)
예제 #19
0
    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
예제 #20
0
    def getOwnersFriends(self):
        displayInConsole(self)

        if self.owner != None:
            self.ownersFriends = Profile.getUserFriends(self.owner)
            return True
        else:
            False
예제 #21
0
    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
예제 #22
0
    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)
예제 #23
0
 def handleRequest(self, request):
     displayInConsole(self)
     
     curRequest = FriendRequest.objects.get(id=request.POST['requests'])
     
     if 'approve' in request.POST:
         self.approveRequest(curRequest)
     
     curRequest.delete()
예제 #24
0
    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
예제 #25
0
    def dispatch(self, request, *args, **kwargs):
        displayInConsole(self)
        
        del request.session['profile_id']
        return LogoutView.dispatch(self, request, *args, **kwargs)
    



#    
예제 #26
0
    def isChoice(self):
        displayInConsole(self)

        choices = self.getQuestionChoices()

        if choices.count() != 0:
            self.choices = choices
            return False
        else:
            return True
예제 #27
0
    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
예제 #28
0
    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
예제 #29
0
    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
예제 #30
0
    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