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 submission metadata to assertRequiredFilesPresent #10

Open
ChrisMayfield opened this issue Oct 3, 2023 · 0 comments
Open

Add submission metadata to assertRequiredFilesPresent #10

ChrisMayfield opened this issue Oct 3, 2023 · 0 comments

Comments

@ChrisMayfield
Copy link
Member

During the CS 149 planning meeting today, we had the idea to combine these two tests into one. The code in test_submission_count could be added to assertRequiredFilesPresent.

    @weight(0)
    def test_submission_count(self):
        """Submission count"""
        try:
            meta = json.load(open("/autograder/submission_metadata.json"))
        except FileNotFoundError:
            print("WARNING: metadata not found (please notify your instructor)")
            return  # This error should happen only when testing the autograder

        count = 1 + len(meta["previous_submissions"])
        stamp = datetime.fromisoformat(meta["created_at"])
        stamp += timedelta(hours=3)  # Pacific to Eastern
        stamp = stamp.strftime("%b %d at %H:%M:%S")
        print(f"Submission {count} ({stamp})")

    @required()
    @weight(0)
    def test_submitted_files(self):
        """Check submitted files"""
        self.assertRequiredFilesPresent([FILENAME])

In addition, assertRequiredFilesPresent could enforce a submission limit:

    @required()
    @weight(0)
    def test_submission_count(self):
        """Submission count"""
        try:
            meta = json.load(open("/autograder/submission_metadata.json"))
        except FileNotFoundError:
            print("WARNING: metadata not found (please notify your instructor)")
            return  # This error should happen only when testing the autograder

        count = 1 + len(meta["previous_submissions"])
        print(f"Submission {count} of {MAX_SUBMISSIONS}")
        if count > MAX_SUBMISSIONS:
            self.fail("Limit exceeded. Please click the Submission History button "
                      "and activate the submission you would like us to grade.\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant