Skip to content

Commit

Permalink
other option
Browse files Browse the repository at this point in the history
  • Loading branch information
jpelay committed Sep 30, 2024
1 parent c67d2e6 commit cdbbb77
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
20 changes: 17 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1620,11 +1620,24 @@ def view_program(user, id):
arguments_dict['program_timestamp'] = utils.localized_date_format(result['date'])
else:
arguments_dict['show_edit_button'] = True

arguments_dict['is_students_teacher'] = 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']), [])
Expand Down Expand Up @@ -1652,6 +1665,7 @@ def view_program(user, id):
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
3 changes: 3 additions & 0 deletions templates/view-program-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ <h1>{{initial_adventure.name}}</h1>
{{_('go_next')}}
</a>
{% endif %}
{% if next_classmate_program_id %}
<a class="green-btn" href="/hedy/{{ next_classmate_program_id }}/view">{{ _('go_to_next_student') }}</a>
{% endif %}
<a class="green-btn" href="/for-teachers/class/{{ class_id }}">
{{_('back_to_class')}}
</a>
Expand Down

0 comments on commit cdbbb77

Please sign in to comment.