Update Steps
Base Class
All update steps must inherit from/implement the following base class
(with some repeated from FlowStep
)
- class flow.flow_steps.FlowUpdateStep[RecordType]
A flow step to update the overall list of records.
Parent Class:
FlowStep
- abstract class property description: str
A high-level description of the step
- abstract class property config_types: list[tuple[str, Type[ValidConfigTypes], str]]
The types of the configurations for the step. Each tuple in the list should include the name, type, and description of a configuration (respectively). See
FlowStep
- abstractmethod validate() None
This function should inspect the object’s
configs
attribute, and perform any static validation possible.
- abstractmethod update_records(records: list[tuple[RecordType, allocate_lock]], logger: Callable[[str], None], get_metadata: Callable[[str], Any], set_metadata: Callable[[str, Any], None], debug: bool = False) None
Update our records with any new information.
- Parameters:
records (list[tuple[RecordType, Lock]]) – The list of records to manipulate
logger (Callable[[str], None]) – A function to log any notable events
get_metadata (Callable[[str], Any],) – A function to retrieve global metadata previously set in the flow
set_metadata (Callable[[str, Any], None]) – A function to set global metadata within the flow
debug (bool, optional) – Whether we are in “debug” mode. In debug mode, no external state should be modified, and we are free to inject dummy information. Defaults to False.
Implementations
- class canvas_steps.enrollment.UpdateEnrollment
An update step that updates enrollment based on Canvas.
This step removes any student who is marked as enrolled, but no longer on Canvas. Similarly, the flow re-enrolls any record that shows the student as unenrolled, but the student is present on Canvas.
Supported record types:
StudentRecord
Sets metadata:
unenrolled_netids
- class canvas_steps.github_usernames.GitHubUsernames
An update step for getting student’s GitHub usernames from Canvas.
This step checks a Canvas quiz’s responses, specifically one with a “Fill in the Blank” question. It gets the responses, and adds them to the record as their username. It additionally checks and updates the record with whether the GitHub username is valid (i.e. it actually corresponds to a GitHub profile).
Supported record types:
StudentRecord
- configs.quiz_id: int
The ID of the Canvas quiz to check. The can be taken from the URL; going to the quiz, the URL should be of the form
.../quizzes/<quiz_id>
- configs.question_id: int
The ID of the “Fill in the Blank” question in the Canvas quiz to get responses from. This is slightly trickier to obtain:
One could determine it from the browser by inspecting the page source; see here
One could use the API to figure out the possible IDs (and corresponding names) of questions for a given quiz
To aid with this,
GitHubUsernames
includes the possible questions and their IDs in the exception thrown by an invalid question ID invalidate
. This allows users to determine the question ID by initially guessing an incorrect ID, then inspecting the resulting exception message during validation to determine the correct ID.
- validate() None
Validate the configurations for the step.
Specifically, we make sure that a quiz with the given ID exists in the Canvas course, and that it contains a question with the given ID that is a ‘Fill in the Blank’ question
- class github_steps.mark_accepted.MarkAccepted
An update step to mark students who have accepted a GitHub invite.
This step checks the current membership of the GitHub organization, and marks students with usernames in the organization membership as having accepted their invitation.
Supported record types:
StudentRecord
- configs.staff_team: str
The name of the staff team in the GitHub organization (usually
staff
). Members in this team are not considered students for the purpose of checking whether a student is in the organization.
- validate() None
Validate the configurations for the step.
Specifically, we make sure that the GitHub organization contains a team with the specified name
- class utils.basic_steps.BasicUpdateStep
A basic flow update step to increment records.
Supported record types:
int
- configs.increment: int
The amount to increment records by
- validate() None
Validate the configurations for the step.
Specifically, we make sure that the supplied increment amount is positive