Ejemplo n.º 1
0
def question_sheet(clid):
    if 'userinfo' in session:
        if request.method == 'GET':
            response = requests.get('http://localhost:5000/student/question/', json={'clientid': clid})
            questions = deserialize_questions(response.json().get('success'))
            line = [i for i in range(len(questions) - 1)]
            return render_template('questions.html', questionlist=questions, l=line, clid=clid)
        else:
            data = request.form
            response = requests.get('http://localhost:5000/student/question/', json={'clientid': clid})
            questions = deserialize_questions(response.json().get('success'))
            mark = final_calculation(data, questions)
            print(mark)
            line = [i for i in range(len(questions) - 1)]
            return redirect(url_for('final_ans',mark=mark))
    return render_template('student_login.html')
Ejemplo n.º 2
0
def student_login():
    msg = ''
    if request.method == 'POST':
        reqdata = request.form
        if reqdata.get('username') and reqdata.get('password'):
            response = requests.post('http://localhost:5000/student/login/', json={'username': reqdata.get('username'),
                                                                                   'password': reqdata.get('password')})
            resp = response.json()
            if resp.get('success'):
                session['userinfo'] = reqdata.get('username')
                return redirect(url_for('question_sheet', clid=resp.get('success')))
            else:
                msg = resp.get('error')
        else:
            msg = 'Invalid credential..!'
    return render_template('student_login.html', resp=msg)
Ejemplo n.º 3
0
def student_registration():
    msg = ''
    if request.method == 'POST':
        reqdata = request.form
        if reqdata.get('username') and reqdata.get('name') and reqdata.get('email') and reqdata.get('password') and reqdata.get('clid'):
            response = requests.post('http://localhost:5000/student/registration/',
                                     json={'username': reqdata.get('username'),
                                           'fullname': reqdata.get('name'),
                                           'email': reqdata.get('email'),
                                           'password': reqdata.get('password'),
                                           'employer id': reqdata.get('clid')})
            resp = response.json()
            if resp.get('success'):
                msg = resp.get('success')
            else:
                msg = resp.get('error')
        else:
            msg = 'Invalid credential..!'
    return render_template('student.html', resp=msg)
Ejemplo n.º 4
0
def student_logout():
    if 'userinfo' in session:
        session.pop('userinfo')
    return render_template('student_login.html')
Ejemplo n.º 5
0
def final_ans(mark):
    if 'userinfo' in session:
        return render_template('mark.html', mark=mark)
    return render_template('student_login.html')