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

Update submission prompt for CS50x course #375

Merged
merged 1 commit into from
Dec 30, 2024
Merged
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
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
description="This is submit50, with which you can submit solutions to problems for CS50.",
long_description="This is submit50, with which you can submit solutions to problems for CS50.",
install_requires=["lib50>=3,<4", "packaging", "requests>=2.19", "setuptools", "termcolor>=1.1"],
install_requires=["lib50>=3,<4", "packaging", "pytz", "requests>=2.19", "setuptools", "termcolor>=1.1"],
keywords=["submit", "submit50"],
name="submit50",
python_requires=">=3.6",
Expand All @@ -26,6 +26,6 @@
entry_points={
"console_scripts": ["submit50=submit50.__main__:main"]
},
version="3.1.5",
version="3.2.0",
include_package_data=True
)
27 changes: 25 additions & 2 deletions submit50/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

from importlib.resources import files
from packaging import version
from datetime import datetime
from pytz import timezone
from . import __version__, CONFIG_LOADER

# Internationalization
Expand Down Expand Up @@ -137,7 +139,7 @@ def prompt(honesty, included, excluded):
# Show default message
if honesty == True:
honesty_question = _(
"Keeping in mind the course's policy on academic honesty, "
"Keeping in mind the course's policy on academic honesty, including its restrictions on AI use, "
"are you sure you want to submit these files (yes/no)? "
)
# If a custom message is configured, show that instead
Expand All @@ -162,6 +164,26 @@ def prompt(honesty, included, excluded):
return True


def check_slug_year(slug):
"""Warn if the slug is for previous year's CS50x course."""

# extract the year from the slug
try:
year = re.search(r"cs50/problems/(\d{4})/x", slug)
if year and int(year.group(1)) < int(datetime.now(timezone("US/Eastern")).year):
suggested_slug = re.sub(r"cs50/problems/\d{4}/x", f"cs50/problems/{datetime.now(timezone('US/Eastern')).year}/x", slug)
cprint(_("You are submitting to a previous year's CS50x course. Your submission will not be counted towards this year's course."), "yellow")
cprint(_("If you are looking to submit to this year's course, please use the following slug:"), "yellow")
cprint(suggested_slug, "yellow")

# Ask if they want to continue
if not re.match(f"^\s*(?:{_('y|yes')})\s*$", input(_("Do you want to continue with this submission (yes/no)? ")), re.I):
raise Error(_("User aborted submission."))

except ValueError:
pass


def excepthook(type, value, tb):
"""Report an exception."""
if (issubclass(type, Error) or issubclass(type, lib50.Error)) and str(value):
Expand Down Expand Up @@ -223,7 +245,8 @@ def main():

check_announcements()
check_version()

check_slug_year(args.slug)

user_name, commit_hash, message = lib50.push("submit50", args.slug, CONFIG_LOADER, prompt=prompt)
print(message)

Expand Down
8 changes: 4 additions & 4 deletions submit50/locale/es/LC_MESSAGES/submit50.po
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ msgid "Sorry, something's wrong! Let [email protected] know!"
msgstr "¡Lo siento, algo está mal! ¡Déjale saber a [email protected]!"

msgid ""
"Keeping in mind the course's policy on academic honesty, are you sure you "
"want to submit these files (yes/no)? "
"Keeping in mind the course's policy on academic honesty, including its restrictions on AI use, "
"are you sure you want to submit these files (yes/no)? "
msgstr ""
"Teniendo en cuenta la política de honestidad académica del curso, ¿estás "
"seguro que quieres enviar estos archivos (sí/no)? "
"Teniendo en cuenta la política de honestidad académica del curso, incluidas sus restricciones sobre el uso de IA, "
"¿estás seguro que quieres enviar estos archivos (sí/no)? "

msgid "y|yes"
msgstr "s|s[ií]"
Expand Down
Loading