Exemple #1
0
def update_candidate(candidate):
    session_candidate_app.query(Candidate).filter_by(
        id=candidate.id, exam_owner_id=candidate.exam_owner_id).update({
            'email':
            candidate.email,
            'password_hash':
            candidate.password_hash
        })
    session_candidate_app.commit()
Exemple #2
0
def candidate_login(email, exam_config_id, password_hash):
    candidate = session_candidate_app.query(Candidate).filter_by(
        email=email,
        exam_config_id=exam_config_id,
        password_hash=password_hash).first()
    session_candidate_app.commit()
    dt = datetime.utcnow()
    if candidate is not None:
        if candidate.end_time is not None:
            return "C"
        exam_config = session_exam_config_app.query(ExamConfig).\
            filter_by(id=candidate.exam_config_id, exam_owner_id=candidate.exam_owner_id).first()
        session_exam_config_app.commit()
        if exam_config.end_time < dt:
            return "TO"
    return candidate
def prepare_candidate_exam(exam_config_id, candidate_id):
    # validation required exam_owner_id belongs same user
    dt = datetime.utcnow()
    count = session_candidate_exam_app.query(CandidateExam).\
        filter_by(candidate_id=candidate_id, exam_config_id=exam_config_id).count()
    session_candidate_exam_app.commit()
    if count == 0:
        result = session_candidate_exam_app.execute(
            'DELETE from candidate_exam where candidate_id =:val1 and exam_config_id = :val2',
            {'val1': candidate_id, 'val2': exam_config_id})
        result = session_candidate_exam_app.execute(
            'INSERT INTO candidate_exam (exam_questions_id, candidate_id, exam_config_id) SELECT id, :val1, '
            'exam_config_id from exam_questions where exam_config_id = :val2',
            {'val1': candidate_id, 'val2': exam_config_id})

        session_candidate_exam_app.commit()

        session_candidate_app.query(Candidate).filter_by(id=candidate_id, exam_config_id=exam_config_id).update(
            {'start_time': dt})
        session_candidate_app.commit()

    return "success"
def candidate_exam_finish(exam_config_id, candidate_id):
    dt = datetime.utcnow()
    session_candidate_app.query(Candidate).filter_by(id=candidate_id, exam_config_id=exam_config_id).update(
        {'end_time': dt})
    session_candidate_app.commit()
Exemple #5
0
def create_candidate(candidate):
    # validation required exam_owner_id belongs same user
    session_candidate_app.add(candidate)
    session_candidate_app.commit()
Exemple #6
0
def get_candidate_by_eid_cid(candidate_id, exam_config_id):
    candidate = session_candidate_app.query(Candidate).filter_by(
        id=candidate_id, exam_config_id=exam_config_id).first()
    session_candidate_app.commit()
    return candidate
Exemple #7
0
def get_candidate(candidate_id, exam_owner_id):
    candidate = session_candidate_app.query(Candidate).filter_by(
        id=candidate_id, exam_owner_id=exam_owner_id).first()
    session_candidate_app.commit()
    return candidate
Exemple #8
0
def get_candidate_all(exam_owner_id, exam_config_id):
    candidate_all = session_candidate_app.query(Candidate).filter_by(
        exam_owner_id=exam_owner_id, exam_config_id=exam_config_id).all()
    session_candidate_app.commit()
    return candidate_all
Exemple #9
0
def delete_candidate(exam_owner_id, candidate_id):
    candidate = session_candidate_app.query(Candidate).filter_by(
        id=candidate_id, exam_owner_id=exam_owner_id).first()
    session_candidate_app.delete(candidate)
    session_candidate_app.commit()