feat: csv export (#50)
This commit is contained in:
parent
d564aff885
commit
3ab340f688
|
@ -35,6 +35,11 @@ class Tea:
|
|||
tea = Tea() # lazy loader
|
||||
|
||||
|
||||
@app.command("export-students", help="export students from canvas to csv file")
|
||||
def export_students_to_csv(output_file: Path) -> None:
|
||||
tea.pot.canvas.export_students_to_csv(output_file)
|
||||
|
||||
|
||||
@app.command(
|
||||
"invite-to-teams", help="invite all canvas students to gitea teams by team name"
|
||||
)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import csv
|
||||
import os
|
||||
import re
|
||||
from glob import glob
|
||||
from pathlib import Path
|
||||
from typing import cast
|
||||
|
||||
from canvasapi import Canvas as PyCanvas
|
||||
|
@ -58,6 +60,13 @@ class Canvas:
|
|||
self.grade_filename = grade_filename
|
||||
logger.debug("Canvas initialized")
|
||||
|
||||
def export_students_to_csv(self, filename: Path) -> None:
|
||||
with open(filename, mode="w", newline="") as file:
|
||||
writer = csv.writer(file)
|
||||
for student in self.students:
|
||||
writer.writerow([student.name, student.sis_id, student.login_id])
|
||||
logger.info(f"Students exported to {filename}")
|
||||
|
||||
def prepare_assignment_dir(
|
||||
self, dir_or_zip_file: str, create_grade_file: bool = True
|
||||
) -> None:
|
||||
|
|
Loading…
Reference in New Issue
Block a user