Skip to content

Commit

Permalink
💻 Go to next student button on reviewing (#5821)
Browse files Browse the repository at this point in the history
Adds two buttons, so we can decide which one to keep tomorrow in the meeting:

![image](https://github.com/user-attachments/assets/000e4f49-f83f-4465-a6e5-c3a5ffb7f146)

1. The "Go to next student" button, does what the original issue suggests, a button to review the next student that completed this adventure, i.e: iterating over columns.

2. The "Go next" button goes to the next adventure submitted by the student, i.e: iterating over rows.

I added both to see which one would you guys prefer.

Fixes #5772

**How to test**

*  Log in as teacher1 and go to the class.
* Click the eye icon in one of the programs.
* Check that when you click the Go next button you go to the next adventure
* Check that when you click go next student you go to the next student.
  • Loading branch information
jpelay authored Oct 4, 2024
1 parent bd2a7c9 commit 529dd05
Show file tree
Hide file tree
Showing 64 changed files with 2,286 additions and 519 deletions.
38 changes: 36 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1914,9 +1914,40 @@ def view_program(user, id):
arguments_dict['program_timestamp'] = utils.localized_date_format(result['date'])
else:
arguments_dict['show_edit_button'] = True

arguments_dict['show_checkbox'] = is_teacher(user)\
is_students_teacher = is_teacher(user)\
and result['username'] in DATABASE.get_teacher_students(user['username'])
arguments_dict['is_students_teacher'] = is_students_teacher

classes = DATABASE.get_student_classes_ids(result['username'])
next_classmate_adventure_id = None
if classes:
class_id = classes[0]
class_ = DATABASE.get_class(class_id) or {}
students = sorted(class_.get('students', []))
index = students.index(result['username'])
for student in students[index + 1:]:
id = f"{student}-{result['adventure_name']}-{result['level']}"
next_classmate_adventure = DATABASE.student_adventure_by_id(id) or {}
next_classmate_adventure_id = next_classmate_adventure.get('program_id')
if next_classmate_adventure_id:
break

student_customizations = DATABASE.get_student_class_customizations(result['username'])
adventure_index = 0
adventures_for_this_level = student_customizations.get('sorted_adventures', {}).get(str(result['level']), [])
for index, adventure in enumerate(adventures_for_this_level):
if adventure['name'] == result['adventure_name']:
adventure_index = index
break

next_program_id = None
for i in range(adventure_index + 1, len(adventures_for_this_level)):
next_adventure = adventures_for_this_level[i]
next_adventure_id = f"{result['username']}-{next_adventure['name']}-{result['level']}"
next_student_adventure = DATABASE.student_adventure_by_id(next_adventure_id) or {}
next_program_id = next_student_adventure.get('program_id')
if next_program_id:
break

return render_template("view-program-page.html",
blur_button_available=True,
Expand All @@ -1926,6 +1957,9 @@ def view_program(user, id):
level=int(result['level']),
code=code),
is_teacher=user['is_teacher'],
class_id=student_customizations['id'],
next_program_id=next_program_id,
next_classmate_program_id=next_classmate_adventure_id,
**arguments_dict)


Expand Down
Loading

0 comments on commit 529dd05

Please sign in to comment.