Exemplo n.º 1
0
    def get_context_data(self, **kwargs):
        displayInConsole(self)

        # noinspection PyTypeChecker
        context = super().get_context_data(**kwargs)
        context['title'] = 'Quiz Result'
        return context
Exemplo n.º 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)
Exemplo n.º 3
0
    def getPriorityQuestion(self):
        displayInConsole(self)

        if self.quiz_total_result.areAnswersAccounted():
            return self.findPriorityQuestion()
        else:
            return self.quiz.getNextQuestion(self.current_question)
Exemplo n.º 4
0
    def getAvailState(self, state):
        displayInConsole(self)

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

        if resultAvail:
            self.setInitWeight(answerBool)
        else:
            self.manageWeight(answerBool)
Exemplo n.º 7
0
    def isLastQuestion(self):
        displayInConsole(self)

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

    if request.path == target:
        return 'curPage'
    else:
        return 'othPage'
Exemplo n.º 10
0
    def isOwnersFriend(self, user):
        displayInConsole(self)

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

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

        return context
Exemplo n.º 13
0
 def hasRequests(self):
     displayInConsole(self)
     
     if self.fields['requests'].queryset.count() > 0:
         return True
     else:
         return False
Exemplo n.º 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
Exemplo n.º 15
0
    def update(self):
        displayInConsole(self)

        if not self.isLastQuestion():
            self.nextQuestion()
        else:
            self.complete = True
            self.save()
Exemplo n.º 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 ''
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 20
0
    def getOwnersFriends(self):
        displayInConsole(self)

        if self.owner != None:
            self.ownersFriends = Profile.getUserFriends(self.owner)
            return True
        else:
            False
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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()
Exemplo n.º 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
Exemplo n.º 25
0
    def dispatch(self, request, *args, **kwargs):
        displayInConsole(self)
        
        del request.session['profile_id']
        return LogoutView.dispatch(self, request, *args, **kwargs)
    



#    
Exemplo n.º 26
0
    def isChoice(self):
        displayInConsole(self)

        choices = self.getQuestionChoices()

        if choices.count() != 0:
            self.choices = choices
            return False
        else:
            return True
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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