Skip to content

Commit

Permalink
💻 Unsubmit program (#5304)
Browse files Browse the repository at this point in the history
Fixes #4634 

**How to test:**
1. Log in as a student in a teachers class
2. Create a program and submit it
3. Log in as the teacher
4. Go to the class the student is in click: overview of programs per adventure, open the submitted program
5. Click on the unsubmit button

https://github.com/hedyorg/hedy/assets/48122190/bfa25cbe-9ccc-4297-a5e1-761924f03b31
  • Loading branch information
Annelein authored Mar 27, 2024
1 parent 346b0e9 commit 7d4e7c3
Show file tree
Hide file tree
Showing 59 changed files with 524 additions and 6 deletions.
1 change: 1 addition & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,7 @@ def view_program(user, id):
lang=g.lang,
level=int(result['level']),
code=code),
is_teacher=user['is_teacher'],
**arguments_dict)


Expand Down
9 changes: 9 additions & 0 deletions messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,15 @@ msgstr ""
msgid "unsaved_class_changes"
msgstr ""

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

msgid "update_adventure_prompt"
msgstr ""

Expand Down
7 changes: 7 additions & 0 deletions static/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,13 @@ export function submit_program (id: string, index: number) {
});
}

export function unsubmit_program (id: string) {
tryCatchPopup(async () => {
const response = await postJsonWithAchievements('/programs/unsubmit', { id });
modal.notifySuccess(response.message);
});
}

export async function set_explore_favourite(id: string, favourite: number) {
let prompt = "Are you sure you want to remove this program as a \"Hedy\'s choice\" program?";
if (favourite) {
Expand Down
7 changes: 7 additions & 0 deletions static/js/appbundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -55175,6 +55175,7 @@ ${i2}` : o2;
tryCatchErrorBox: () => tryCatchErrorBox,
tryCatchPopup: () => tryCatchPopup,
tryPaletteCode: () => tryPaletteCode,
unsubmit_program: () => unsubmit_program,
update_adventure: () => update_adventure,
update_user_tags: () => update_user_tags,
viewProgramLink: () => viewProgramLink
Expand Down Expand Up @@ -99489,6 +99490,12 @@ pygame.quit()
change_to_submitted(index3);
});
}
function unsubmit_program(id2) {
tryCatchPopup(async () => {
const response = await postJsonWithAchievements("/programs/unsubmit", { id: id2 });
modal.notifySuccess(response.message);
});
}
async function set_explore_favourite(id2, favourite) {
let prompt = `Are you sure you want to remove this program as a "Hedy's choice" program?`;
if (favourite) {
Expand Down
4 changes: 2 additions & 2 deletions static/js/appbundle.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions templates/view-program-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<h2>{{_('submitted_header')}}</h2>
<h3 class="inline-block mt-0">{{_('submission_time')}}: {{program_timestamp}}</h3>
</div>
{% if is_teacher %}
<div class="text-center">
<button class="green-btn" data-cy="unsubmit-btn" onclick="hedyApp.modal.confirm ('{{_('unsubmit_warning')}}', function () {hedyApp.unsubmit_program ('{{initial_adventure.id}}', {{ loop_index }})})">{{_('unsubmit_program')}}</button>
</div>
{% endif %}
{% endif %}
<h1>{{initial_adventure.name}}</h1>
<h2 class="mt-0">{{_('level_title')}} {{level}}</h2>
Expand Down
9 changes: 9 additions & 0 deletions translations/ar/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2038,6 +2038,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

msgid "update_adventure_prompt"
msgstr "هل أنت متأكد أنك تريد تعديل هذه المغامرة؟"

Expand Down
9 changes: 9 additions & 0 deletions translations/bg/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

#, fuzzy
msgid "update_adventure_prompt"
msgstr "Are you sure you want to update this adventure?"
Expand Down
9 changes: 9 additions & 0 deletions translations/bn/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2385,6 +2385,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

#, fuzzy
msgid "update_adventure_prompt"
msgstr "Are you sure you want to update this adventure?"
Expand Down
9 changes: 9 additions & 0 deletions translations/ca/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,15 @@ msgstr "Desbloqueja els llindars de nivell"
msgid "unsaved_class_changes"
msgstr "Hi ha canvis no guardats, segur que voleu sortir d'aquesta pàgina?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

msgid "update_adventure_prompt"
msgstr "Estàs segur que vols actualitzar aquesta aventura?"

Expand Down
9 changes: 9 additions & 0 deletions translations/cs/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2281,6 +2281,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

#, fuzzy
msgid "update_adventure_prompt"
msgstr "Are you sure you want to update this adventure?"
Expand Down
9 changes: 9 additions & 0 deletions translations/cy/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2397,6 +2397,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

#, fuzzy
msgid "update_adventure_prompt"
msgstr "Are you sure you want to update this adventure?"
Expand Down
9 changes: 9 additions & 0 deletions translations/da/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2398,6 +2398,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

#, fuzzy
msgid "update_adventure_prompt"
msgstr "Are you sure you want to update this adventure?"
Expand Down
9 changes: 9 additions & 0 deletions translations/de/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,15 @@ msgstr "Schalte Level.Grenzen frei"
msgid "unsaved_class_changes"
msgstr "Es gibt ungespeicherte Änderungen, bist du dir sicher, dass du diese Seite verlassen möchtest?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

msgid "update_adventure_prompt"
msgstr "Bist du sicher, dass du dieses Abenteuer updaten möchtest?"

Expand Down
9 changes: 9 additions & 0 deletions translations/el/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2122,6 +2122,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

msgid "update_adventure_prompt"
msgstr "Είσαι σίγουρος ότι θέλεις να ενημερώσεις την περιπέτεια;"

Expand Down
9 changes: 9 additions & 0 deletions translations/en/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr "Unsubmit program"

msgid "unsubmit_warning"
msgstr "Are you sure you want to unsubmit this program?"

msgid "unsubmitted"
msgstr "Unsubmitted"

msgid "update_adventure_prompt"
msgstr "Are you sure you want to update this adventure?"

Expand Down
9 changes: 9 additions & 0 deletions translations/eo/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

msgid "update_adventure_prompt"
msgstr "Ĉu vi certas, ke vi volas modifi ĉi tiun aventuron?"

Expand Down
9 changes: 9 additions & 0 deletions translations/es/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -1823,6 +1823,15 @@ msgstr "Desbloquear umbrales de nivel"
msgid "unsaved_class_changes"
msgstr "Hay cambios sin guardar, ¿estás seguro de que quieres abandonar esta página?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

msgid "update_adventure_prompt"
msgstr "¿Estás seguro de que quieres actualizar esta aventura?"

Expand Down
9 changes: 9 additions & 0 deletions translations/et/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2330,6 +2330,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

#, fuzzy
msgid "update_adventure_prompt"
msgstr "Are you sure you want to update this adventure?"
Expand Down
9 changes: 9 additions & 0 deletions translations/fa/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

#, fuzzy
msgid "update_adventure_prompt"
msgstr "Are you sure you want to update this adventure?"
Expand Down
9 changes: 9 additions & 0 deletions translations/fi/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2396,6 +2396,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

#, fuzzy
msgid "update_adventure_prompt"
msgstr "Are you sure you want to update this adventure?"
Expand Down
9 changes: 9 additions & 0 deletions translations/fr/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,15 @@ msgstr "Déverrouiller les limites de niveau"
msgid "unsaved_class_changes"
msgstr "Il y a des changements non pris en comptes, es-tu sur de vouloir quitter la page ?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

msgid "update_adventure_prompt"
msgstr "Es-tu sur de vouloir mettre cette aventure à jour ?"

Expand Down
9 changes: 9 additions & 0 deletions translations/fy/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

#, fuzzy
msgid "update_adventure_prompt"
msgstr "Are you sure you want to update this adventure?"
Expand Down
9 changes: 9 additions & 0 deletions translations/he/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2322,6 +2322,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

#, fuzzy
msgid "update_adventure_prompt"
msgstr "Are you sure you want to update this adventure?"
Expand Down
9 changes: 9 additions & 0 deletions translations/hi/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2150,6 +2150,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "There are unsaved changes, are you sure you want to leave this page?"

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

msgid "update_adventure_prompt"
msgstr "क्या आप वाकई इस adventure को अद्यतन करना चाहते हैं?"

Expand Down
9 changes: 9 additions & 0 deletions translations/hu/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,15 @@ msgstr "Unlock level thresholds"
msgid "unsaved_class_changes"
msgstr "Biztosan elhagyod ezt az oldalt? Mentetlen változtatásaid vannak, amik így elveszhetnek."

msgid "unsubmit_program"
msgstr ""

msgid "unsubmit_warning"
msgstr ""

msgid "unsubmitted"
msgstr ""

#, fuzzy
msgid "update_adventure_prompt"
msgstr "Biztosan frissíted ezt a kalandot?"
Expand Down
Loading

0 comments on commit 7d4e7c3

Please sign in to comment.