From b2a934fb7e5de2c706ecb33a9e12e807fd9a88fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kruli=C5=A1?= Date: Sun, 26 May 2024 17:17:10 +0200 Subject: [PATCH] Adding command for setting group exam period. --- recodex/api.py | 8 ++++++++ recodex/plugins/groups/cli.py | 19 +++++++++++++++++++ setup.py | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/recodex/api.py b/recodex/api.py index caf5f25..fc74100 100644 --- a/recodex/api.py +++ b/recodex/api.py @@ -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)) diff --git a/recodex/plugins/groups/cli.py b/recodex/plugins/groups/cli.py index 55cb8d2..508ce73 100644 --- a/recodex/plugins/groups/cli.py +++ b/recodex/plugins/groups/cli.py @@ -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) diff --git a/setup.py b/setup.py index 4a8a942..2e7ee31 100644 --- a/setup.py +++ b/setup.py @@ -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=[