Skip to content

Commit b2a934f

Browse files
committed
Adding command for setting group exam period.
1 parent b48ca3f commit b2a934f

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

recodex/api.py

+8
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,14 @@ def set_group_exam_flag(self, group_id, is_exam=True):
281281
return self.post("/groups/{}/exam".format(group_id),
282282
data={"value": is_exam})
283283

284+
def set_group_exam_period(self, group_id, begin, end, strict=None):
285+
data = {"end": end}
286+
if begin is not None:
287+
data["begin"] = begin
288+
if strict is not None:
289+
data["strict"] = strict
290+
return self.post("/groups/{}/examPeriod".format(group_id), data=data)
291+
284292
def get_group_stats(self, group_id):
285293
return self.get("/groups/{}/students/stats".format(group_id))
286294

recodex/plugins/groups/cli.py

+19
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,25 @@ def set_exam(api: ApiClient, group_id, unset):
206206
api.set_group_exam_flag(group_id, not unset)
207207

208208

209+
@cli.command()
210+
@click.argument("group_id")
211+
@click.argument("begin")
212+
@click.argument("end")
213+
@click.option("--strict/--regular", default=None)
214+
@pass_api_client
215+
def set_exam_period(api: ApiClient, group_id, begin, end, strict):
216+
"""
217+
Set/update exam period in a group. Begin/end are unix timestamps.
218+
Begin may be ommitted (in case of update-only) by using '0' as value.
219+
Strict/regular denotes the type of the user locks.
220+
"""
221+
begin = int(begin)
222+
if not begin:
223+
begin = None
224+
end = int(end)
225+
api.set_group_exam_period(group_id, begin, end, strict)
226+
227+
209228
@cli.command()
210229
@click.argument("group_id")
211230
@click.option("--json/--yaml", "useJson", default=False)

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='recodex-cli',
5-
version='0.0.30',
5+
version='0.0.31',
66
description='ReCodEx CLI',
77
long_description='A command line frontend to the ReCodEx programmer evaluation system',
88
classifiers=[

0 commit comments

Comments
 (0)