Esempio n. 1
0
def upload_data(user):
    test_id = flask.request.form["test_id"]
    test_name = flask.request.form["test_name"]
    student_id = flask.request.form["user_id"]
    request_id = flask.request.form["post_id"]
    b64_jpeg_image = flask.request.form["image"]

    repository.image_dump.save({
        "test_id": test_id,
        "test_name": test_name,
        "student_id": student_id,
        "b64_jpeg_image": b64_jpeg_image,
    })

    answers = image_processor.process_answers(b64_jpeg_image)
#    repository.save_user_exam(
#        models.UserExam(
#            user_id=student_id,
#            test_id=test_id,
#            test_area=test_name,
#            answers=answers,
#        )
#    )

    return request_id  # TODO add extra data
Esempio n. 2
0
def upload_test():
    from gansht_server import mongo
    student_id = flask.request.args["student_id"]
    test_id = flask.request.args["test_id"]
    data = list(mongo.db.image_dump.find({"student_id": student_id, "test_id": test_id}))
    if not data:
        return "none"
    a = [image_processor.process_answers(x["b64_jpeg_image"]) for x in data]
    return json.dumps(a, indent=4)