Exemplo n.º 1
0
def Publish_to_public(Survey_name):
    if AUTHORITY_TEST("STAFF") == False:
        return render_template("INVALID_AUTHORITY.html",
                               a1=current_user.authority,
                               a2="STAFF")
    sp = model.Surveys_Pool()
    s = model.Survey()
    s.Name = Survey_name
    if s.exist() == False:
        flash("can't find survey name")
        return redirect(url_for('Survey_Pool'))
    s = sp.Get(Survey_name)
    sc = model.Student_Course()
    rv = sc.Get(current_user.id, s.Course_Semester)
    if rv == 1 and current_user.authority != "ADMIN":
        flash("You Are Not Enrolled in This Course!!!")
        if current_user.authority == "STAFF":
            return redirect(url_for('index'))
        return redirect(url_for('Survey_Pool'))
    s.publish_to_public()
    sp.Update(s)
    if current_user.authority == "STAFF":
        return redirect(url_for('index'))

    return redirect(url_for('Survey_Pool'))
Exemplo n.º 2
0
def survey_display(Survey_name):

    if AUTHORITY_TEST(
            "STUDENT") == False and current_user.authority != "GUEST":
        return render_template("INVALID_AUTHORITY.html",
                               a1=current_user.authority,
                               a2="STUDENT")

    sp = model.Surveys_Pool()
    s = model.Survey()
    s.Name = Survey_name
    if s.exist() == False:
        return render_template('display_Survey.html', text="Survey not exist")
    s = sp.Get(Survey_name)

    sc = model.Student_Course()
    rv = sc.Get(current_user.id, s.Course_Semester)
    if rv == 1 and current_user.authority != "ADMIN":
        return render_template('display_Survey.html',
                               text="You Are Not Enrolled in This Course!!!")

    if s.survey_open() == False:
        return render_template('display_Survey.html',
                               text="Survey is not opened")

    form = s.create_survey_form()

    if form == False:
        return render_template('display_Survey.html',
                               text="Can not create form!")

    if form.validate_on_submit():
        print(s)
        if s.form_update_answer_attend(form, current_user.id) == False:
            return render_template('display_Survey.html',
                                   form=form,
                                   survey=s,
                                   text="")
        else:
            if sp.Update(s) == False:
                flash("Can not edit Survey in Survey pool!")
                return render_template('display_Survey.html',
                                       form=form,
                                       survey=s,
                                       text="")
            else:
                return render_template(
                    'Thankyou.html', message="Thank you for complete survey! ")

    return render_template('display_Survey.html', form=form, survey=s, text="")
Exemplo n.º 3
0
def index():
    print(current_user.authority)
    print(current_user.id)
    sc = model.Student_Course()
    if current_user.authority == "STAFF" or current_user.authority == "STUDENT" or current_user.authority == "GUEST":
        sp = model.Surveys_Pool()
        sl = sp.Show()
        cl = []
        for s in sl:
            rv = sc.Get(current_user.id, s.Course_Semester)
            if rv == 1 and current_user.authority != "ADMIN":
                continue
            if s.Course_Semester not in cl:
                cl.append(s.Course_Semester)

        cl.sort()
        scl = sc.Show()
        cl2 = []
        for x in scl:
            if x[1] == int(current_user.id):
                cl2.append(x[0])
        cl2.sort()
        for x in cl2:
            if x not in cl:
                cl.append(x)

        if current_user.authority == "STUDENT" or current_user.authority == "GUEST":
            return render_template("student_index.html",
                                   ID=current_user.id,
                                   surveys=sl,
                                   cl=cl)
        else:
            return render_template("staff_index.html",
                                   ID=current_user.id,
                                   surveys=sl,
                                   cl=cl)
    g = model.Guest()
    gl = g.Show()
    return render_template('index.html', guest_list=gl)
Exemplo n.º 4
0
def Review_Survey(Survey_name):
    if AUTHORITY_TEST("STAFF") == False:
        return render_template("INVALID_AUTHORITY.html",
                               a1=current_user.authority,
                               a2="STAFF")
    sp = model.Surveys_Pool()
    s = model.Survey()
    s.Name = Survey_name
    if s.exist() == False:
        return render_template('Review_Survey.html')
    s = sp.Get(Survey_name)
    sc = model.Student_Course()
    rv = sc.Get(current_user.id, s.Course_Semester)
    if rv == 1 and current_user.authority != "ADMIN":
        flash("You are not enroll in this course!!!!!")
        if current_user.authority == "STAFF":
            return redirect(url_for('index'))
        return render_template('Review_Survey.html', )

    form = Optional_Q()
    form.questionlist_init()
    if form.validate_on_submit():
        if s.form_staff_append(form) == False:
            flash("Can not append optional question!")
            return render_template('Review_Survey.html', form=form, survey=s)
        else:
            if s.publish_to_public() == False:
                flash("Can not publish")
                return render_template('Edit_Survey.html', form=form)

            if sp.Update(s) == False:
                flash("Can not edit Survey in Survey pool!")
                return render_template('Edit_Survey.html', form=form)

            return redirect(url_for('Survey_Pool'))
    form.oq_list.data = [oq.Name for oq in s.Optional_Question_list]

    return render_template('Review_Survey.html', form=form, survey=s)
Exemplo n.º 5
0
def Survey_result(Survey_name):
    ct = model.Counter()
    ct2 = model.Counter()
    sp = model.Surveys_Pool()
    s = model.Survey()
    s.Name = Survey_name
    if s.exist() == False:
        return render_template('Survey_result.html')
    s = sp.Get(Survey_name)
    '''
    if AUTHORITY_TEST("STAFF") == False:
        if s.to_public():
            pass
        else:
            return render_template("INVALID_AUTHORITY.html",a1 = current_user.authority,a2 = "STAFF")
    '''
    sc = model.Student_Course()
    rv = sc.Get(current_user.id, s.Course_Semester)
    if current_user.authority == "ADMIN":
        return render_template('Survey_result.html',
                               survey=s,
                               c=ct,
                               c2=ct2,
                               a1=current_user.authority)
    if rv == 1:
        return render_template('display_Survey.html',
                               text="You Are Not Enrolled in This Course!!!")
    if s.survey_open() == False and s.State != "NOT_REVIEWED":
        return render_template('Survey_result.html',
                               survey=s,
                               c=ct,
                               c2=ct2,
                               a1=current_user.authority)
    else:
        return render_template('display_Survey.html',
                               text="Survey result closed")
import model
import database
import csv
cl = model.Course_list()
pw = model.Password()
sc = model.Student_Course()
#admin:12450 password:ADMIN
pw.Create("12450", "ADMIN", "ADMIN")
#course list

with open('courses.csv', 'rt') as r:
    reader = csv.reader(r)
    for line in reader:
        try:
            cl.Create(line[0], line[1])
        except:
            pass
    r.close()
print("update course finsih")

#password
with open('passwords.csv', 'rt') as r:
    reader = csv.reader(r)
    for line in reader:
        try:
            #print("%s"%line)
            x = line[2].upper()
            #print(x)
            pw.Create(line[0], line[1], x)
            #print(line[0])
        except: