Skip to content

Commit

Permalink
Adding new features (retrieving students by list of IDs and group sta…
Browse files Browse the repository at this point in the history
…ts) and preparing release of 0.0.29
  • Loading branch information
krulis-martin committed May 16, 2024
1 parent c755e8c commit d805b25
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
3 changes: 3 additions & 0 deletions recodex/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ def set_group_exam_flag(self, group_id, is_exam=True):
return self.post("/groups/{}/exam".format(group_id),
data={"value": is_exam})

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

# Assignments and related stuff...

def get_assignment(self, assignment_id):
Expand Down
19 changes: 18 additions & 1 deletion recodex/plugins/groups/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def detail(api: ApiClient, group_id, useJson):
json.dump(group, sys.stdout, sort_keys=True, indent=4)
elif useJson is False:
yaml = YAML(typ="safe")
yaml.dump(group, sys.stdout)
yaml.dump(group, sys.stdout)


@ cli.command()
Expand Down Expand Up @@ -202,3 +202,20 @@ def set_exam(api: ApiClient, group_id, unset):
"""

api.set_group_exam_flag(group_id, not unset)


@ cli.command()
@ click.argument("group_id")
@ click.option("--json/--yaml", "useJson", default=False)
@ pass_api_client
def stats(api: ApiClient, group_id, useJson):
"""
Get students information about solution stats (point summaries)
"""

stats = api.get_group_stats(group_id)
if useJson is True:
json.dump(stats, sys.stdout, sort_keys=True, indent=4)
elif useJson is False:
yaml = YAML(typ="safe")
yaml.dump(stats, sys.stdout)
18 changes: 18 additions & 0 deletions recodex/plugins/users/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@ def get(api: ApiClient, user_id, useJson):
yaml.dump(user, sys.stdout)


@cli.command()
@click.option("--json/--yaml", "useJson", default=True)
@pass_api_client
def get_list(api: ApiClient, useJson):
"""
Get data of multiple users, list of IDs is given on stdin (one ID per line)
"""
ids = map(lambda id: id.strip(), sys.stdin.readlines())
ids = list(filter(lambda id: id, ids))

users = api.get_users_list(ids)
if useJson:
json.dump(users, sys.stdout, sort_keys=True, indent=4)
else:
yaml = YAML(typ="safe")
yaml.dump(users, sys.stdout)


@cli.command()
@click.option("--json/--yaml", "useJson", default=None, help='Default is CSV.')
@click.option('--only-active', 'onlyActive', is_flag=True, help='Return full records formated into CSV.')
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.28',
version='0.0.29',
description='ReCodEx CLI',
long_description='A command line frontend to the ReCodEx programmer evaluation system',
classifiers=[
Expand Down

0 comments on commit d805b25

Please sign in to comment.