Example #1
0
def manual_check(tag,user_id,index):
    if current_user.if_adm() != 1:
        return redirect(url_for('welcome'))
    
    index=int(index)
    form=MarkForm()
    ques, ids = controller.get_questions(tag)
    limit = len(ques)
    que = ques[index]
    que_id = ids[index]
    if index >= limit-1:
        limit = 0
    answers=controller.get_answer(que_id,user_id)
    full_mark=questions.query.filter_by(id=que_id).first().get_mark()
    if form.validate_on_submit():
        mark = form.Mark.data
        ans=answer.query.filter_by(question_id=que_id,user_id=user_id).first()
        if ans is not None:
            ans.mark=mark
            db.session.commit()
            flash("mark has been uploaded")
        else:
            flash("Can't mark, cause student are not complete the question")
    
    return render_template('manual_check.html', title='manual_check', form=form, question=que, answer=answers, nextindex=str(index+1), lastindex=str(index-1), limit=limit,user_id=user_id,tag=tag,full_mark=full_mark)
Example #2
0
def delete_que(que_id):
    if current_user.if_adm() != 1:
        return redirect(url_for('welcome'))
    mod = questions.query.filter_by(id=que_id).first()
    db.session.delete(mod)
    db.session.commit()
    flash("Question"+str(que_id) + " has been deleted!")
    return redirect(url_for('manage_que'))
Example #3
0
def Upload_question():
    if current_user.if_adm()!=1:
        return redirect(url_for('welcome'))
    form = QuestionForm()
    if form.validate_on_submit():
        tag=form.Tag.data
        mark=form.Mark.data
        que=form.Que.data
        stand_answer=form.Stand_answer.data
        que=questions(tag=tag,mark=mark,content=que,stand_answer=stand_answer)
        db.session.add(que)
        db.session.commit()
        flash("Questions saved!")
    return render_template('Upload_question.html', title='Upload_question', form=form)
Example #4
0
def get_answer():
    if current_user.if_adm() != 1:
        return redirect(url_for('welcome'))
    
    user_selector = []
    userlist = User.query.all()
    for user in userlist:
        user_selector.append((user.get_id(), user.get_user_name()))

    class UserTagForm(FlaskForm):
        pass 
    setattr(UserTagForm, 'tag', SelectField(choices=controller.get_tags()))
    setattr(UserTagForm, 'user', SelectField(choices=user_selector))
    setattr(UserTagForm, 'submit', SubmitField('Get answer'))
    form = UserTagForm()

    if form.is_submitted():
        tag=form.tag.data
        user=form.user.data
        return redirect(url_for('manual_check',user_id=user,tag=tag,index='0'))
        

    return render_template('get_answer.html', title='get_answer', form=form)
Example #5
0
def manage_que():
    if current_user.if_adm() != 1:
        return redirect(url_for('welcome'))
    quelist = questions.query.all()
    return render_template('manage_que.html', title='Manage questions',que_list=quelist)
Example #6
0
def make_admin(user_id):
    if current_user.if_adm() != 1:
        return redirect(url_for('welcome'))
    controller.make_admin(user_id)
    flash("User"+str(user_id)+ " now is admin!")
    return redirect(url_for('User_management'))
Example #7
0
def delete_user(user_id):
    if current_user.if_adm() != 1:
        return redirect(url_for('welcome'))
    controller.delete_user(user_id)
    flash("User"+str(user_id)+ " has been deleted!")
    return redirect(url_for('User_management'))
Example #8
0
def User_management():
    if current_user.if_adm() != 1:
        return redirect(url_for('welcome'))
    users = User.query.all()

    return render_template('User_management.html', title='User_management', Users_list=users)