Skip to content

Commit

Permalink
I think this works as intended.
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDue committed Sep 20, 2023
1 parent 08bc63b commit 02dce5b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
11 changes: 5 additions & 6 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = [
(pkgs.python310.withPackages(ps: with ps; [
(pkgs.python39.withPackages(ps: with ps; [
ruamel-yaml
(
buildPythonPackage rec {
pname = "canvasapi";
version = "3.2.0";
version = "2.2.0";
src = fetchPypi {
inherit pname version;
sha256 = "7cf97ad1ddc860e250c3453e229897ed1273095ad061c34baf651bf1b0e5a9c7";
sha256 = "5087db773cac9d92f4f4609b3c160dbeeceb636801421808afee2d438bc43f62";
};
doCheck = false;
propagatedBuildInputs = [
pkgs.python3Packages.arrow
pkgs.python3Packages.pytz
pkgs.python3Packages.requests
pkgs.python39Packages.pytz
pkgs.python39Packages.requests
];
}
)
Expand Down
4 changes: 2 additions & 2 deletions staffeli_nt/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def main():
print(f'Error: Missing Canvas token at {path_token}.')
sys.exit(0)

api_key = 'https://absalon.ku.dk/'
api_url = 'https://absalon.ku.dk/'

with open(path_token, 'r') as f:
api_url = f.read().strip()
api_key = f.read().strip()

args = parser.parse_args()
if not hasattr(args, 'main'):
Expand Down
7 changes: 3 additions & 4 deletions staffeli_nt/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def add_subparser(subparsers: argparse._SubParsersAction):
parser.add_argument('course_id', type=str, metavar='INT', help='the course id')
parser.add_argument('path_template', type=str, metavar='TEMPLATE_PATH', help='path to the YAML template')
parser.add_argument('path_destination', type=str, metavar='SUBMISSIONS_PATH', help='destination to submissions folder')
parser.add_argument('--select-section', action='store_false', help='whether section selection is used')
parser.add_argument('--select-section', action='store_true', help='whether section selection is used')
parser.add_argument('--select-ta', type=str, metavar='PATH', help='path to a YAML file with TA distributions')
parser.add_argument('--resub', action='store_false', help='whether only resubmissions should be fetched')
parser.add_argument('--resub', action='store_true', help='whether only resubmissions should be fetched')
parser.set_defaults(main=main)


Expand All @@ -61,7 +61,6 @@ def main(api_url, api_key, args: argparse.Namespace):
path_destination = args.path_destination
select_section = args.select_section
select_ta = args.select_ta # use --select-ta file.yaml

resubmissions_only = args.resub

# sanity check
Expand Down Expand Up @@ -148,7 +147,7 @@ def main(api_url, api_key, args: argparse.Namespace):
# NOTE: This is a terribly hacky solution and should really be rewritten
# collect which attachments to download
# if only fetching resubmissions
if resubmissions_only:
if resubmissions_only:
if hasattr(submission, 'score'):
print(f'Score: {submission.score}')
# If a submission has not yet been graded, submission.score will be None
Expand Down
6 changes: 3 additions & 3 deletions staffeli_nt/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ def get_course(api_url, api_key, course_id):
def add_subparser(subparsers: argparse._SubParsersAction):
parser : argparse.ArgumentParser = subparsers.add_parser(name='info', help='fetch infomation related to a course')
parser.add_argument('course_id', type=str, metavar='INT', help='the course id')
parser.add_argument('--quiet', action='store_false', help='disable verbose output')
parser.add_argument('--debug', action='store_false', help='enable debug printing')
parser.add_argument('--quiet', action='store_true', help='disable verbose output')
parser.add_argument('--debug', action='store_true', help='enable debug printing')
parser.add_argument('--get-ass-dist', metavar='PATH', help=("select an assignment and construct a distribution between available TA's, resulting in a YAML-file suitable for using with the --select-ta flag in download subcommand where the result will be written to PATH"))
parser.add_argument('--ids', action='store_false', help='print kuids and names for a sections')
parser.add_argument('--ids', action='store_true', help='print kuids and names for a sections')
parser.set_defaults(main=main)


Expand Down
8 changes: 4 additions & 4 deletions staffeli_nt/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def add_subparser(subparsers: argparse._SubParsersAction):
parser : argparse.ArgumentParser = subparsers.add_parser(name='upload', help='upload feedback for submissions')
parser.add_argument('path_template', type=str, metavar='TEMPLATE_PATH', help='path to the YAML template')
parser.add_argument('path_submissions', type=str, metavar='SUBMISSIONS_PATH', help='destination to submissions folder')
parser.add_argument('--live', action='store_false', help='upload all feedback for submissions in the directory')
parser.add_argument('--step', action='store_false', help='to review all feedback for submissions in the directory')
parser.add_argument('--warn-missing', action='store_false', help='warn if grades are missing')
parser.add_argument('--write-local', action='store_false', help='writes the feedback locally unless --live is given')
parser.add_argument('--live', action='store_true', help='upload all feedback for submissions in the directory')
parser.add_argument('--step', action='store_true', help='to review all feedback for submissions in the directory')
parser.add_argument('--warn-missing', action='store_true', help='warn if grades are missing')
parser.add_argument('--write-local', action='store_true', help='writes the feedback locally unless --live is given')
parser.set_defaults(main=main)

def main(api_url, api_key, args: argparse.Namespace):
Expand Down
2 changes: 1 addition & 1 deletion staffeli_nt/upload_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def add_subparser(subparsers: argparse._SubParsersAction):
parser.add_argument('path_meta_yml', type=str, metavar='META_PATH', help='YAML file containg meta data related to the submission')
parser.add_argument('path_grade_yml', type=str, metavar='GRADE_PATH', help='YAML file containing the grade')
parser.add_argument('path_feedback', type=str, metavar='FEEDBACK_PATH', help='the path to the text file containing feedback')
parser.add_argument('--live', action='store_false', help='upload feedback for submission')
parser.add_argument('--live', action='store_true', help='upload feedback for submission')
parser.set_defaults(main=main)


Expand Down

0 comments on commit 02dce5b

Please sign in to comment.