示例#1
0
def update_task(task_id):
    title = request.form.get("title")
    description = request.form.get("description")
    deadline = request.form.get("deadline")

    task = Task(id=task_id,
                title=title,
                description=description,
                deadline=deadline)

    if task.updateTask(task):
        return "OK", 200

    else:
        return "Error", 400
示例#2
0
def create_task():
    title = request.form.get("title")
    description = request.form.get("description")
    createdAt = request.form.get("createdAt")
    deadline = request.form.get("deadline")
    classId = request.form.get("classId")
    classe = Class().getClassById(classId=classId)
    testId = request.form.get("testId")
    test = db.tests.find_one({"_id": ObjectId(testId)})

    task = Task(title=title,
                description=description,
                createdAt=createdAt,
                deadline=deadline,
                classe=classe,
                test=test)

    if Task().createTask(task):
        return "OK", 200

    else:
        return "Error", 400
示例#3
0
def get_class_student(class_id):
    if "_id" in session:
        classe = Class().getClassById(class_id)
        tasks = Task().getAllTasksByClassId(class_id)
        notices = Notice().getAllNoticesByClassId(class_id)

        participants = []

        result = classe["participants"]

        for item in result:
            participants.append(User().getUserById(str(item)))

        if ObjectId(session["_id"]) in classe["participants"]:
            return render_template("classes/student.html",
                                   participants=participants,
                                   classe=classe,
                                   tasks=tasks,
                                   notices=notices)

    return "error", 400
示例#4
0
def get_class(class_id):
    if "_id" in session:
        classe = Class().getClassById(class_id)
        tasks = Task().getAllTasksByClassId(class_id)
        notices = Notice().getAllNoticesByClassId(class_id)
        invites = Invite().getAllInvitesByClassId(class_id)

        participants = []

        result = classe["participants"]

        for item in result:
            participants.append(User().getUserById(str(item)))

        if str(classe["creator"]["_id"]) == session["_id"]:
            return render_template("classes/classes.html",
                                   participants=participants,
                                   classe=classe,
                                   tasks=tasks,
                                   notices=notices,
                                   invites=invites)

    return "error", 400
示例#5
0
def delete_task(task_id):
    if Task().deleteTask(task_id):
        return "OK", 200
    else:
        return "Error", 400