Beispiel #1
0
    def validate(self):
        rv = FlaskForm.validate(self)
        if not rv:
            return False

        try:
            participant = Participant.get(
                Participant.Email == self.Email.data.lower().strip())
            print(participant.Name, self.Name.data)
            if participant.Name != self.Name.data.strip():
                self.Name.errors.append(
                    'This name / email combination has already been used, contact [email protected] for help'
                )
                return False
            else:
                return True
        except peewee.DoesNotExist:
            return True
Beispiel #2
0
def create_submission(user_id: UUID, user_role: Role,
                      submission: schemas.Submission):
    is_authorized(user_role, "create_submission")

    question = Question.get(id=submission.question_id)
    if not question:
        raise HTTPException(
            status_code=status.HTTP_404_NOT_FOUND,
            detail=("Question not found : question_id: {}".format(
                submission.question_id)))

    participant = Participant.get(exam=question.exam, user=User[user_id])
    if not participant:
        raise HTTPException(
            status_code=status.HTTP_404_NOT_FOUND,
            detail=("Participant not found : exam_id: {}".format(
                question.exam.id)))

    if len(question.multi_choice) > 0:
        if submission.answer == question.answer:
            marks_obtained = question.marks
            mark = Mark.auto_tick
        else:
            marks_obtained = 0
            mark = Mark.auto_cross

        submission = Submission(answer=submission.answer,
                                question=question,
                                user=User[user_id],
                                marks_obtained=marks_obtained,
                                mark=mark)
    else:
        submission = Submission(answer=submission.answer,
                                question=question,
                                user=User[user_id])

    performance_review(submission)

    return submission.to_dict()
Beispiel #3
0
    def get(self, group_key):
        # confirm participant id in cookie
        c_group_key = ChatTrait.get_group_key(self)
        participant_key = ChatTrait.get_participant_key(self)

        # get group
        group = Group.get(group_key)

        # if participant is none or login to another group, create new participant in group
        if not participant_key:
            participant = Participant()
            participant.store(group.key)
            participant_key = participant.key
            ChatTrait.store_participant_key(self, participant_key)

        if c_group_key:
            if c_group_key != group_key:
                group.participant(Participant.get(participant_key))
                ChatTrait.store_group_key(self, group.key)
        else:
            ChatTrait.store_group_key(self, group.key)

        # return response
        self.render("chat.html", group_name=group.name)
Beispiel #4
0
    def get(self, group_key):
        # confirm participant id in cookie
        c_group_key = ChatTrait.get_group_key(self)
        participant_key = ChatTrait.get_participant_key(self)

        # get group
        group = Group.get(group_key)

        # if participant is none or login to another group, create new participant in group
        if not participant_key:
            participant = Participant()
            participant.store(group.key)
            participant_key = participant.key
            ChatTrait.store_participant_key(self, participant_key)

        if c_group_key:
            if c_group_key != group_key:
                group.participant(Participant.get(participant_key))
                ChatTrait.store_group_key(self, group.key)
        else:
            ChatTrait.store_group_key(self, group.key)

        # return response
        self.render("chat.html", group_name=group.name)
def recipient_to_txt():
    query = Participant.get(name=input('Who do you need the recipient for? ex: Justin: '))
    with open(query.name + '.txt', 'w') as file:
        file.write(query.name + ', you are giving to ' + query.giving_to + "!") 
Beispiel #6
0
def result(name):
    try:
        participant = Participant.get(name=name.title())
        return render_template('result.html', name=participant.name, giving_to=participant.giving_to)
    except:
        return redirect(url_for('index'))