Assignment¶
Qualified name: tin.apps.assignments.models.Assignment
- class Assignment(*args, **kwargs)[source]¶
Bases:
ModelAn assignment (or quiz) for a student.
If
is_quizisTrue, this model doubles as a quiz.The manager for this model is
AssignmentQuerySet.- Parameters:
id (BigAutoField) – Primary key: ID
name (CharField) – Name
description (CharField) – Description
markdown (BooleanField) – Markdown
language (CharField) – Language
filename (CharField) – Filename
points_possible (DecimalField) – Points possible
assigned (DateTimeField) – Assigned
due (DateTimeField) – Due
hidden (BooleanField) – Hidden
grader_file (FileField) – Grader file
enable_grader_timeout (BooleanField) – Enable grader timeout
grader_timeout (IntegerField) – Grader timeout
grader_has_network_access (BooleanField) – Grader has network access
has_network_access (BooleanField) – Has network access
submission_limit_count (PositiveIntegerField) – Submission limit count
submission_limit_interval (PositiveIntegerField) – Submission limit interval
submission_limit_cooldown (PositiveIntegerField) – Submission limit cooldown
last_action_output (CharField) – Last action output
is_quiz (BooleanField) – Is quiz
quiz_action (CharField) – Quiz action
quiz_autocomplete_enabled (BooleanField) – Quiz autocomplete enabled
quiz_description (CharField) – Quiz description
quiz_description_markdown (BooleanField) – Quiz description markdown
Relationship fields:
- Parameters:
folder (
ForeignKeytoFolder) – Folder (related name:assignments)course (
ForeignKeytoCourse) – Course (related name:assignments)venv (
ForeignKeytoVenv) – Venv (related name:assignments)
Reverse relationships:
- Parameters:
submission_caps (Reverse
ForeignKeyfromSubmissionCap) – All submission caps of this assignment (related name ofassignment)cooldown_periods (Reverse
ForeignKeyfromCooldownPeriod) – All cooldown periods of this assignment (related name ofassignment)quiz (Reverse
OneToOneFieldfromQuiz) – The quiz of this assignment (related name ofassignment)log_messages (Reverse
ForeignKeyfromQuizLogMessage) – All log messages of this assignment (related name ofassignment)moss_results (Reverse
ForeignKeyfromMossResult) – All moss results of this assignment (related name ofassignment)submissions (Reverse
ForeignKeyfromSubmission) – All submissions of this assignment (related name ofassignment)final_submissions (Reverse
ForeignKeyfromPublishedSubmission) – All final submissions of this assignment (related name ofassignment)
Methods
Get the submission cap for an assignment before the due date.
Check if a student is submitting too quickly
Delete a file by id
Find an
SubmissionCapfor a student.Given a student, find the submission cap.
get_absolute_urlget_fileget_language_displayShows the label of the
language.get_next_by_assignedFinds next instance based on
assigned.get_next_by_dueFinds next instance based on
due.get_previous_by_assignedFinds previous instance based on
assigned.get_previous_by_dueFinds previous instance based on
due.get_quiz_action_displayShows the label of the
quiz_action.List all files in the assignments directory
Creates the directory where the assignment grader scripts go.
Check if the quiz has ended for a student
Check if the student has exceeded the maximum amount of issues they can have with a quiz.
Check if the quiz has been locked (e.g. due to leaving the tab).
Check if a quiz is open for a specific student
Save some text as a file
Save the grader file to the correct location.
Get the submission cap after the due date.
Check if a student is within the submission limit for an assignment.
Attributes
LANGUAGESQUIZ_ACTIONSassignedType:
DateTimeFieldcooldown_periodsType: Reverse
ForeignKeyfromCooldownPeriodcourseType:
ForeignKeytoCoursecourse_idInternal field, use
courseinstead.descriptionType:
CharFielddueType:
DateTimeFieldenable_grader_timeoutType:
BooleanFieldfilenameType:
CharFieldfinal_submissionsType: Reverse
ForeignKeyfromPublishedSubmissionfolderType:
ForeignKeytoFolderfolder_idInternal field, use
folderinstead.grader_fileType:
FileFieldgrader_has_network_accessType:
BooleanFieldgrader_log_filenamegrader_timeoutType:
IntegerFieldhas_network_accessType:
BooleanFieldhiddenType:
BooleanFieldidType:
BigAutoFieldis_quizType:
BooleanFieldlanguageType:
CharFieldlast_action_outputType:
CharFieldlog_messagesType: Reverse
ForeignKeyfromQuizLogMessagemarkdownType:
BooleanFieldmoss_resultsType: Reverse
ForeignKeyfromMossResultnameType:
CharFieldobjectspoints_possibleType:
DecimalFieldquizType: Reverse
OneToOneFieldfromQuizquiz_actionType:
CharFieldquiz_autocomplete_enabledType:
BooleanFieldquiz_descriptionType:
CharFieldquiz_description_markdownType:
BooleanFieldsubmission_capsType: Reverse
ForeignKeyfromSubmissionCapsubmission_limit_cooldownType:
PositiveIntegerFieldsubmission_limit_countType:
PositiveIntegerFieldsubmission_limit_intervalType:
PositiveIntegerFieldsubmissionsType: Reverse
ForeignKeyfromSubmissionvenvType:
ForeignKeytoVenvvenv_fully_createdvenv_idInternal field, use
venvinstead.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- before_submission_cap(student) float[source]¶
Get the submission cap for an assignment before the due date.
Returns
float("inf")if no cap is found.
- find_student_override(student) SubmissionCap | None[source]¶
Find an
SubmissionCapfor a student.Returns
Noneif no override exists.
- find_submission_cap(student) float[source]¶
Given a student, find the submission cap.
This takes into account student overrides, and due dates.
- list_files() list[tuple[int, str, str, int, datetime]][source]¶
List all files in the assignments directory
- Returns:
The index of the assignment
The name of the assignment submission
The full path to the assignment submission
The size of the submission
The time at which it was submitted
- quiz_issues_for_student(student) bool[source]¶
Check if the student has exceeded the maximum amount of issues they can have with a quiz.
- quiz_locked_for_student(student) bool[source]¶
Check if the quiz has been locked (e.g. due to leaving the tab)
- save_grader_file(grader_text: str) None[source]¶
Save the grader file to the correct location.
Warning
Writing to files in directories not controlled by us without some form of sandboxing is a security risk. Most notably, users can use symbolic links to trick you into writing to another file, outside the directory. they control. This solution is very hacky, but we don’t have another good way of doing this.