Skip to content

Commit

Permalink
Creates link for shared programs (hedyorg#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
Felienne authored Aug 27, 2021
1 parent b760d3f commit b860a2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion templates/class-overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h2>{{auth.class_overview}}: {{class_info.name}}</h2>
<td class="p-2">{{student.last_login}}</td>
<td class="p-2">{{student.highest_level}}</td>
<td class="p-2">{{student.programs}}</td>
<td class="p-2">{% if student.latest_shared %}<a target="_blank" href={{student.latest_shared.link}}>{{student.latest_shared.name}} ({{student.latest_shared.level}})</a>{% else %}-{% endif %}</td>
<td class="p-2">{% if student.latest_shared %}<a target="_blank" href="{{student.latest_shared.link}}">{{student.latest_shared.name}} ({{student.latest_shared.level}})</a>{% else %}-{% endif %}</td>
<td class="p-2"><a href="#" onclick="remove_student ('{{class_info.id}}', '{{student.username}}')">{{auth.remove_student}}</a></td>
</tr>
{% endfor %}
Expand Down
6 changes: 5 additions & 1 deletion website/teacher.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def get_class (user, class_id):
programs = DATABASE.programs_for_user(student_username)
highest_level = max(program['level'] for program in programs) if len(programs) else 0
sorted_public_programs = list(sorted([program for program in programs if program.get ('public')], key=lambda p: p['date']))
latest_shared = sorted_public_programs[-1] if sorted_public_programs else None
if sorted_public_programs:
latest_shared = sorted_public_programs[-1]
latest_shared['link'] = os.getenv ('BASE_URL') + f"hedy/{latest_shared['id']}/view"
else:
latest_shared = None
students.append ({'username': student_username, 'last_login': utils.mstoisostring (student ['last_login']), 'programs': len (programs), 'highest_level': highest_level, 'latest_shared': latest_shared})

if utils.is_testing_request (request):
Expand Down

0 comments on commit b860a2a

Please sign in to comment.