Skip to content

Commit 368aa26

Browse files
committedDec 29, 2024·
Update dependencies and submission prompt for CS50x course
1 parent 8ef8276 commit 368aa26

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed
 

‎setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
description="This is submit50, with which you can submit solutions to problems for CS50.",
1818
long_description="This is submit50, with which you can submit solutions to problems for CS50.",
19-
install_requires=["lib50>=3,<4", "packaging", "requests>=2.19", "setuptools", "termcolor>=1.1"],
19+
install_requires=["lib50>=3,<4", "packaging", "pytz", "requests>=2.19", "setuptools", "termcolor>=1.1"],
2020
keywords=["submit", "submit50"],
2121
name="submit50",
2222
python_requires=">=3.6",
@@ -26,6 +26,6 @@
2626
entry_points={
2727
"console_scripts": ["submit50=submit50.__main__:main"]
2828
},
29-
version="3.1.5",
29+
version="3.2.0",
3030
include_package_data=True
3131
)

‎submit50/__main__.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
from importlib.resources import files
1818
from packaging import version
19+
from datetime import datetime
20+
from pytz import timezone
1921
from . import __version__, CONFIG_LOADER
2022

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

164166

167+
def check_slug_year(slug):
168+
"""Warn if the slug is for previous year's CS50x course."""
169+
170+
# extract the year from the slug
171+
try:
172+
year = re.search(r"cs50/problems/(\d{4})/x", slug)
173+
if year and int(year.group(1)) < int(datetime.now(timezone("US/Eastern")).year):
174+
suggested_slug = re.sub(r"cs50/problems/\d{4}/x", f"cs50/problems/{datetime.now(timezone('US/Eastern')).year}/x", slug)
175+
cprint(_("You are submitting to a previous year's CS50x course. Your submission will not be counted towards this year's course."), "yellow")
176+
cprint(_("If you are looking to submit to this year's course, please use the following slug:"), "yellow")
177+
cprint(suggested_slug, "yellow")
178+
179+
# Ask if they want to continue
180+
if not re.match(f"^\s*(?:{_('y|yes')})\s*$", input(_("Do you want to continue with this submission (yes/no)? ")), re.I):
181+
raise Error(_("User aborted submission."))
182+
183+
except ValueError:
184+
pass
185+
186+
165187
def excepthook(type, value, tb):
166188
"""Report an exception."""
167189
if (issubclass(type, Error) or issubclass(type, lib50.Error)) and str(value):
@@ -223,7 +245,8 @@ def main():
223245

224246
check_announcements()
225247
check_version()
226-
248+
check_slug_year(args.slug)
249+
227250
user_name, commit_hash, message = lib50.push("submit50", args.slug, CONFIG_LOADER, prompt=prompt)
228251
print(message)
229252

‎submit50/locale/es/LC_MESSAGES/submit50.po

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ msgid "Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!"
1515
msgstr "¡Lo siento, algo está mal! ¡Déjale saber a sysadmins@cs50.harvard.edu!"
1616

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

2424
msgid "y|yes"
2525
msgstr "s|s[ií]"

0 commit comments

Comments
 (0)
Please sign in to comment.