Skip to content

Commit

Permalink
Adding command for setting group exam period.
Browse files Browse the repository at this point in the history
  • Loading branch information
krulis-martin committed May 26, 2024
1 parent b48ca3f commit b2a934f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
8 changes: 8 additions & 0 deletions recodex/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,14 @@ def set_group_exam_flag(self, group_id, is_exam=True):
return self.post("/groups/{}/exam".format(group_id),
data={"value": is_exam})

def set_group_exam_period(self, group_id, begin, end, strict=None):
data = {"end": end}
if begin is not None:
data["begin"] = begin
if strict is not None:
data["strict"] = strict
return self.post("/groups/{}/examPeriod".format(group_id), data=data)

def get_group_stats(self, group_id):
return self.get("/groups/{}/students/stats".format(group_id))

Expand Down
19 changes: 19 additions & 0 deletions recodex/plugins/groups/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,25 @@ def set_exam(api: ApiClient, group_id, unset):
api.set_group_exam_flag(group_id, not unset)


@cli.command()
@click.argument("group_id")
@click.argument("begin")
@click.argument("end")
@click.option("--strict/--regular", default=None)
@pass_api_client
def set_exam_period(api: ApiClient, group_id, begin, end, strict):
"""
Set/update exam period in a group. Begin/end are unix timestamps.
Begin may be ommitted (in case of update-only) by using '0' as value.
Strict/regular denotes the type of the user locks.
"""
begin = int(begin)
if not begin:
begin = None
end = int(end)
api.set_group_exam_period(group_id, begin, end, strict)


@cli.command()
@click.argument("group_id")
@click.option("--json/--yaml", "useJson", default=False)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='recodex-cli',
version='0.0.30',
version='0.0.31',
description='ReCodEx CLI',
long_description='A command line frontend to the ReCodEx programmer evaluation system',
classifiers=[
Expand Down

0 comments on commit b2a934f

Please sign in to comment.