Пример #1
0
#!/usr/bin/python3

from helpers import web
from helpers import session
from helpers import material
from helpers import form
import json

session.sign_in_required()

# A dictionary of all of the users and their info
users = json.loads(open("users.json").read())
user_info = users[session.get_user_id()]
name = user_info["first_name"] + " " + user_info["last_name"]

web.add_body(
    web.center_content("<h4> Profile for " + "<b>" + str(name) + "</b> </h4>"))
web.add_body("<form action='update_profile.py' method='post'>")
web.add_body(
    web.center_content(
        material.new_text_input("Email Address", "email",
                                user_info["email_address"], "email")))
web.add_body(
    web.center_content(
        material.new_text_input("Preferred First Name", "preferred_name",
                                user_info["preferred_name"])))
web.add_body(
    web.center_content(material.new_standard_button("Save Information")))
web.add_body("</form><br><br>")

web.add_body(
    "<form action='update_password.py' method='post' onkeyup='check_passwords()'>"
Пример #2
0
#!/usr/bin/python3

from helpers import web
from helpers import session
from helpers import material
import json



session.sign_in_required()

data = []

all_homeworks = json.loads(open("homeworks.json", "r").read())
my_submissions = json.loads(open("submissions.json", "r").read())[session.get_user_id()]

for homework_id in all_homeworks:
	this_row = [all_homeworks[homework_id]["name"]]
	if homework_id in my_submissions:
		this_row.append("<a href='submissions/" + my_submissions[homework_id]["filename"] + "' target='_blank'>View Submission</a>")
		this_row.append(str(my_submissions[homework_id]["comments"]))
	else:
		this_row.append("No Submission")
		this_row.append("N/A")
	data.append(this_row)

web.add_body("<br><br>" + web.center_content(material.new_table(["Name", "Submission", "Comments"], data)))

web.send_content()
Пример #3
0
def sign_in_required():
	if not is_signed_in():
		web.add_body("<br><br>" + sign_in_card())
		web.send_content()
		exit()
Пример #4
0
#!/usr/bin/python3

from helpers import web
from helpers import session
from helpers import material
import json

session.sign_in_required()

grades = json.loads(open("grades.json").read())

assignments = []
for x in grades[session.get_user_id()]:
    assignments.append([x["name"], str(x["grade"]), str(x["max_points"])])

web.add_body("<br><br>" + web.center_content(
    material.new_table(["Name", "Grade", "Max Grade"], assignments)))

web.send_content()
Пример #5
0
from helpers import web
from helpers import session
from helpers import material
import json
session.sign_in_required()

homework_select =  '<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"><select class="mdl-textfield__input" name="homework_id">'

homeworks = json.loads(open("homeworks.json").read())

for homework_id in homeworks:
	homework_select += '<option value="'+ homework_id +'">'+ str(homeworks[homework_id]["name"]) +'</option>'

homework_select += '</select><label class="mdl-textfield__label">Homework</label></div>'

web.add_body("<br><br><form action='process_submission.py' method='post' enctype='multipart/form-data'>" + web.center_content(
material.new_standard_card("Submit Homework",
homework_select +
"<input type='file' name='homework_file'>" +
"""
<div class="mdl-textfield mdl-js-textfield">
    <textarea class="mdl-textfield__input" type="text" rows= "3" cols='5' name='comments'></textarea>
    <label class="mdl-textfield__label">Comments...</label>
  </div>
"""
, material.new_standard_button("Submit") )) + "</form>")

web.send_content()
# Use the session.get_user_id() function to get the user's username and then their relevant information