kattis2canvas 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kattis2canvas/__init__.py +1 -1
- kattis2canvas/cli.py +24 -18
- {kattis2canvas-0.1.1.dist-info → kattis2canvas-0.1.3.dist-info}/METADATA +1 -1
- kattis2canvas-0.1.3.dist-info/RECORD +8 -0
- kattis2canvas-0.1.1.dist-info/RECORD +0 -8
- {kattis2canvas-0.1.1.dist-info → kattis2canvas-0.1.3.dist-info}/WHEEL +0 -0
- {kattis2canvas-0.1.1.dist-info → kattis2canvas-0.1.3.dist-info}/entry_points.txt +0 -0
- {kattis2canvas-0.1.1.dist-info → kattis2canvas-0.1.3.dist-info}/top_level.txt +0 -0
kattis2canvas/__init__.py
CHANGED
kattis2canvas/cli.py
CHANGED
|
@@ -306,7 +306,8 @@ def get_courses(canvas: Canvas, name: str, is_active=True, is_finished=False) ->
|
|
|
306
306
|
@click.option("--dryrun/--no-dryrun", default=True, help="show planned actions, do not make them happen.")
|
|
307
307
|
@click.option("--force/--no-force", default=False, help="force an update of an assignment if it already exists.")
|
|
308
308
|
@click.option("--add-to-module", help="the module to add the assignment to.")
|
|
309
|
-
|
|
309
|
+
@click.option("--assignment-group", default="kattis", help="the canvas assignment group to use (default: kattis).")
|
|
310
|
+
def course2canvas(offering, canvas_course, dryrun, force, add_to_module, assignment_group):
|
|
310
311
|
"""
|
|
311
312
|
create assignments in canvas for all the assignments in kattis.
|
|
312
313
|
"""
|
|
@@ -321,18 +322,18 @@ def course2canvas(offering, canvas_course, dryrun, force, add_to_module):
|
|
|
321
322
|
canvas = Canvas(config.canvas_url, config.canvas_token)
|
|
322
323
|
course = get_course(canvas, canvas_course)
|
|
323
324
|
|
|
324
|
-
|
|
325
|
+
canvas_group = None
|
|
325
326
|
for ag in course.get_assignment_groups():
|
|
326
|
-
if ag.name ==
|
|
327
|
-
|
|
327
|
+
if ag.name == assignment_group:
|
|
328
|
+
canvas_group = ag
|
|
328
329
|
break
|
|
329
|
-
if not
|
|
330
|
+
if not canvas_group:
|
|
330
331
|
# create assignment group if not present on canvas
|
|
331
332
|
if dryrun:
|
|
332
|
-
info(f"would create assignment group {
|
|
333
|
+
info(f"would create assignment group '{assignment_group}'.")
|
|
333
334
|
else:
|
|
334
|
-
|
|
335
|
-
info(f"created assignment group {
|
|
335
|
+
canvas_group = course.create_assignment_group(name=assignment_group)
|
|
336
|
+
info(f"created assignment group {canvas_group}.")
|
|
336
337
|
|
|
337
338
|
if add_to_module:
|
|
338
339
|
modules = {m.name: m for m in course.get_modules()}
|
|
@@ -350,7 +351,11 @@ def course2canvas(offering, canvas_course, dryrun, force, add_to_module):
|
|
|
350
351
|
add_to_module.edit(module=args)
|
|
351
352
|
info(f"published module {add_to_module}.")
|
|
352
353
|
|
|
353
|
-
|
|
354
|
+
# In dryrun mode without existing group, get all assignments; otherwise filter by group
|
|
355
|
+
if canvas_group:
|
|
356
|
+
canvas_assignments = {a.name: a for a in course.get_assignments(assignment_group_id=canvas_group.id)}
|
|
357
|
+
else:
|
|
358
|
+
canvas_assignments = {}
|
|
354
359
|
|
|
355
360
|
# make sure assignments are in place
|
|
356
361
|
sorted_assignments = list(get_assignments(offerings[0]))
|
|
@@ -364,7 +369,7 @@ def course2canvas(offering, canvas_course, dryrun, force, add_to_module):
|
|
|
364
369
|
info(f"would update {assignment.title}.")
|
|
365
370
|
else:
|
|
366
371
|
canvas_assignments[assignment.title].edit(assignment={
|
|
367
|
-
'assignment_group_id':
|
|
372
|
+
'assignment_group_id': canvas_group.id,
|
|
368
373
|
'name': assignment.title,
|
|
369
374
|
'description': f'Solve the problems found at <a href="{assignment.url}">{assignment.url}</a>. {description}',
|
|
370
375
|
'points_possible': 100,
|
|
@@ -382,7 +387,7 @@ def course2canvas(offering, canvas_course, dryrun, force, add_to_module):
|
|
|
382
387
|
continue
|
|
383
388
|
else:
|
|
384
389
|
canvas_assignments[assignment.title] = course.create_assignment({
|
|
385
|
-
'assignment_group_id':
|
|
390
|
+
'assignment_group_id': canvas_group.id,
|
|
386
391
|
'name': assignment.title,
|
|
387
392
|
'description': f'Solve the problems found at <a href="{assignment.url}">{assignment.url}</a>. {description}',
|
|
388
393
|
'points_possible': 100,
|
|
@@ -464,7 +469,8 @@ def kattislinks(canvas_course):
|
|
|
464
469
|
@click.argument("offering")
|
|
465
470
|
@click.argument("canvas_course")
|
|
466
471
|
@click.option("--dryrun/--no-dryrun", default=True, help="show planned actions, do not make them happen.")
|
|
467
|
-
|
|
472
|
+
@click.option("--assignment-group", default="kattis", help="the canvas assignment group to use (default: kattis).")
|
|
473
|
+
def submissions2canvas(offering, canvas_course, dryrun, assignment_group):
|
|
468
474
|
"""
|
|
469
475
|
mirror summary of submission from kattis into canvas as a submission comment.
|
|
470
476
|
"""
|
|
@@ -488,17 +494,17 @@ def submissions2canvas(offering, canvas_course, dryrun):
|
|
|
488
494
|
else:
|
|
489
495
|
warn(f"kattis link missing for {link.canvas_user.name} {link.canvas_user.email}.")
|
|
490
496
|
|
|
491
|
-
|
|
497
|
+
canvas_group = None
|
|
492
498
|
for ag in course.get_assignment_groups():
|
|
493
|
-
if ag.name ==
|
|
494
|
-
|
|
499
|
+
if ag.name == assignment_group:
|
|
500
|
+
canvas_group = ag
|
|
495
501
|
break
|
|
496
502
|
|
|
497
|
-
if not
|
|
498
|
-
error(f"no
|
|
503
|
+
if not canvas_group:
|
|
504
|
+
error(f"no '{assignment_group}' assignment group in {canvas_course}")
|
|
499
505
|
exit(4)
|
|
500
506
|
|
|
501
|
-
assignments = {a.name: a for a in course.get_assignments(assignment_group_id=
|
|
507
|
+
assignments = {a.name: a for a in course.get_assignments(assignment_group_id=canvas_group.id)}
|
|
502
508
|
|
|
503
509
|
for assignment in get_assignments(offerings[0]):
|
|
504
510
|
if assignment.title.replace("-late", "") not in assignments:
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
kattis2canvas/__init__.py,sha256=MqIjN6muURlNetfg6Sc2rjbVxZqvW_PE8v8H4n1MuYk,109
|
|
2
|
+
kattis2canvas/__main__.py,sha256=GGdT4J5WJQ5MvnJ7m-VX_noR8DGaYXclhjDUIFjW5SY,120
|
|
3
|
+
kattis2canvas/cli.py,sha256=qH2X4GNapfWuKAQN-25_PhRgAZgFLERtrgDbbq8LU2g,24296
|
|
4
|
+
kattis2canvas-0.1.3.dist-info/METADATA,sha256=7kIWlf7eybKvd9pWsWbs8NO7joWOp8FQzKABREbmseQ,7081
|
|
5
|
+
kattis2canvas-0.1.3.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
6
|
+
kattis2canvas-0.1.3.dist-info/entry_points.txt,sha256=V7GPrZNe7aIcu6f_dNo_pCjkuqBQxRzKAQZCNxl9DYg,56
|
|
7
|
+
kattis2canvas-0.1.3.dist-info/top_level.txt,sha256=ZoThmon7y1CR0sTAZndaF2rloBK8xz10mGyz5PUbtCo,14
|
|
8
|
+
kattis2canvas-0.1.3.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
kattis2canvas/__init__.py,sha256=YHEMoJHVGxUquVQlxRXMuxH6dXsyXfAsAyF47okk8IA,109
|
|
2
|
-
kattis2canvas/__main__.py,sha256=GGdT4J5WJQ5MvnJ7m-VX_noR8DGaYXclhjDUIFjW5SY,120
|
|
3
|
-
kattis2canvas/cli.py,sha256=gkKqVVkM0f5aGl-9giLLAGhBJYAcgLDvCXmPq4rEMtY,23825
|
|
4
|
-
kattis2canvas-0.1.1.dist-info/METADATA,sha256=LE_S_E7mkpoz6mq5DGrWuxsr6fEbYcCvc2jzwV-d7S4,7081
|
|
5
|
-
kattis2canvas-0.1.1.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
6
|
-
kattis2canvas-0.1.1.dist-info/entry_points.txt,sha256=V7GPrZNe7aIcu6f_dNo_pCjkuqBQxRzKAQZCNxl9DYg,56
|
|
7
|
-
kattis2canvas-0.1.1.dist-info/top_level.txt,sha256=ZoThmon7y1CR0sTAZndaF2rloBK8xz10mGyz5PUbtCo,14
|
|
8
|
-
kattis2canvas-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|