Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add caching #60

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/canvaslms/cli/assignments.nw
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The [[assignment]] command lists information about a given assignment.

We outline the module:
<<assignments.py>>=
import argparse
import canvaslms.cli.courses as courses
import canvaslms.hacks.canvasapi
import csv
Expand Down
39 changes: 18 additions & 21 deletions src/canvaslms/cli/submissions.nw
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ submissions_parser = subp.add_parser("submissions",
"<Canvas-user-ID> <grade> <grade date>")
submissions_parser.set_defaults(func=submissions_command)
assignments.add_assignment_option(submissions_parser)
<<set up options for limiting by group or user>>
<<set up options for selecting type of submissions>>
add_submission_options(submissions_parser)
@ Now, that [[submissions_command]] function must take three arguments:
[[config]], [[canvas]] and [[args]].
It must also do the processing for the assignment options using
Expand All @@ -56,24 +55,6 @@ def submissions_command(config, canvas, args):
<<get submissions and print them>>
@

\subsection{Limit by group}

By default, we show all submission in the course.
However, sometimes we're only interested in a group of students.
<<set up options for limiting by group or user>>=
users.add_user_or_group_option(submissions_parser)
@

\subsection{Selecting the type of submissions}

We also want to be able to filter out the type of submissions.
For now, we focus on all or ungraded.
<<set up options for selecting type of submissions>>=
submissions_parser.add_argument("-U", "--ungraded", action="store_true",
help="Show only ungraded submissions.")
@ We don't need to do any particular processing for this option.


\subsection{Get and print the list of submissions}

We then simply call the appropriate list-submissions function with the
Expand Down Expand Up @@ -164,6 +145,12 @@ for submission in submission_list:

We now provide a function to set up the command-line options to select a
particular submission along with a function to process those options.
For this we need
\begin{itemize}
\item an assignment,
\item a user or group,
\item to know if we aim for all or just ungraded submissions.
\end{itemize}
<<functions>>=
def add_submission_options(parser):
try:
Expand All @@ -176,10 +163,20 @@ def add_submission_options(parser):
except argparse.ArgumentError:
pass

submissions_parser = parser.add_argument_group("filter submissions")
submissions_parser.add_argument("-U", "--ungraded", action="store_true",
help="Only ungraded submissions.")

def process_submission_options(canvas, args):
assignment_list = assignments.process_assignment_option(canvas, args)
user_list = users.process_user_or_group_option(canvas, args)
return list(filter_submissions(list_submissions(assignment_list), user_list))

if args.ungraded:
submissions = list_ungraded_submissions(assignment_list)
else:
submissions = list_submissions(assignment_list)

return list(filter_submissions(submissions, user_list))
@


Expand Down
Loading