Example #1
0
def request_new_problem_hint_hook():

    @log_action
    def hint(pid, source):
        return None

    source = request.args.get("source")
    pid = request.args.get("pid")

    if pid is None:
        return WebError("Please supply a pid.")
    if source is None:
        return WebError("You have to supply the source of the hint.")

    tid = api.user.get_team()["tid"]
    if pid not in api.problem.get_unlocked_pids(tid):
        return WebError("Your team hasn't unlocked this problem yet!")

    hint(pid, source)
    ret = WebSuccess("New hint unlocked!")
    ret.data = api.problem.request_hint(pid=pid,tid=tid)
    return ret
Example #2
0
def get_memeber_information_hook(gid=None):
    gid = request.args.get("gid")
    if not api.group.is_owner_of_group(gid):
        return WebError("You do not own that group!")

    return WebSuccess(data=api.group.get_member_information(gid=gid))
Example #3
0
def problem_reviews_hook():
    return WebSuccess(data=api.problem_feedback.get_reviewed_pids())
Example #4
0
def get_solved_problems_hook():
    return WebSuccess(api.problem.get_solved_problems(api.user.get_user()['tid']))
Example #5
0
def get_all_users_hook():
    users = api.user.get_all_users()
    if users is None:
        return WebError("There was an error query users from the database.")
    return WebSuccess(data=users)
Example #6
0
def get_team_score_progression():
    category = request.form.get("category", None)

    tid = api.user.get_team()["tid"]

    return WebSuccess(data=[api.stats.get_score_progression(tid=tid, category=category)])
Example #7
0
def team_information_hook():
    return WebSuccess(data=api.team.get_team_information())
Example #8
0
def login_hook():
    username = request.form.get('username')
    password = request.form.get('password')
    api.auth.login(username, password)
    return WebSuccess(message="Successfully logged in as " + username, data={'teacher': api.user.is_teacher()})
Example #9
0
def get_shell_servers():
    return WebSuccess(data=api.shell_servers.get_servers())
Example #10
0
def get_problem():
    submission_data = {p["name"]:api.stats.get_problem_submission_stats(pid=p["pid"]) \
                       for p in api.problem.get_all_problems(show_disabled=True)}
    return WebSuccess(data=submission_data)
Example #11
0
def change_settings():
    data = bson.json_util.loads(request.form["json"])
    api.config.change_settings(data)
    # Update Flask app settings (necessary for email to work)
    api.app.config_app()
    return WebSuccess("Settings updated")
Example #12
0
def get_settings():
    return WebSuccess(data=api.config.get_settings())
Example #13
0
def get_top_teams_score_progressions_hook():
    return WebSuccess(data=api.stats.get_top_teams_score_progressions())
Example #14
0
def update_extdata_hook():
    """
    Sets user extdata via HTTP form. Takes in any key-value pairs.
    """
    api.user.update_extdata(api.common.flat_multi(request.form))
    return WebSuccess("Your Extdata has been successfully updated.")
Example #15
0
def get_extdata_hook():
    """
    Return user extdata, or empty JSON object if unset.
    """
    user = api.user.get_user(uid=None)
    return WebSuccess(data=user['extdata'])
Example #16
0
def reset_password_hook():
    username = request.args.get("username", None)

    api.utilities.request_password_reset(username)
    return WebSuccess("A password reset link has been sent to the email address provided during registration.")
Example #17
0
def add_shell_server():
    params = api.common.flat_multi(request.form)
    api.shell_servers.add_server(params)
    return WebSuccess("Shell server added.")
Example #18
0
def logout_hook():
    if api.auth.is_logged_in():
        api.auth.logout()
        return WebSuccess("Successfully logged out.")
    else:
        return WebError("You do not appear to be logged in.")
Example #19
0
def problem_reviews_hook():
    uid = api.user.get_user()['uid']
    return WebSuccess(data=api.problem_feedback.get_problem_feedback(uid=uid))
Example #20
0
def get_team_score_hook():
    score = api.stats.get_score(tid=api.user.get_user()['tid'])
    if score is not None:
        return WebSuccess(data={'score': score})
    return WebError("There was an error retrieving your score.")
Example #21
0
def load_problems():
    data = json.loads(request.form.get("competition_data", ""))

    api.problem.load_published(data)
    return WebSuccess("Inserted {} problems.".format(len(data["problems"])))
Example #22
0
def get_all_problems_hook():
    problems = api.problem.get_all_problems()
    if problems is None:
        return WebError("There was an error querying problems from the database.")
    return WebSuccess(data=problems)
Example #23
0
def get_time():
    return WebSuccess(data=int(datetime.utcnow().timestamp()))
Example #24
0
def get_unlocked_problems_hook():
    return WebSuccess(data=api.problem.get_unlocked_problems(api.user.get_user()['tid']))
Example #25
0
def get_shell_account_hook():
    return WebSuccess(data=api.team.get_shell_account())
Example #26
0
def get_single_problem_hook(pid):
    problem_info = api.problem.get_problem(pid, tid=api.user.get_user()['tid'])
    return WebSuccess(data=problem_info)
Example #27
0
def create_user_hook():
    new_uid = api.user.create_user_request(api.common.flat_multi(request.form))
    session['uid'] = new_uid
    return WebSuccess("User '{}' registered successfully!".format(request.form["username"]))
Example #28
0
def get_group_list_hook():
    return WebSuccess(data=api.team.get_groups())
Example #29
0
def update_password_hook():
    api.user.update_password_request(api.common.flat_multi(request.form), check_current=True)
    return WebSuccess("Your password has been successfully updated!")
Example #30
0
def disable_account_hook():
    api.user.disable_account_request(api.common.flat_multi(request.form), check_current=True)
    return WebSuccess("Your have successfully disabled your account!")
Example #31
0
def shell_servers_hook():
    servers = [{
        "host": server['host'],
        "protocol": server['protocol']
    } for server in api.shell_servers.get_servers()]
    return WebSuccess(data=servers)