Skip to content

Commit

Permalink
sort projects by score when its already scored
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeygrigorev committed Oct 11, 2024
1 parent 2ca5e33 commit f59e974
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 25 deletions.
58 changes: 33 additions & 25 deletions courses/templates/projects/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,50 @@

<h2 class="mb-3 text-center">Projects of {{ project.title }}</h2>

{% for submission in submissions %}
<div class="p-2 border-bottom {% cycle 'bg-white' 'bg-light' %}">
<div class="d-flex justify-content-between align-items-center text-decoration-none">
<a href="{{ submission.github_link }}" target="_blank">
<div>
{{ submission.enrollment.display_name }}
<span
class="ms-2"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{{ submission.github_link }}">
<i class="fas fa-external-link-alt"></i>
</span>
</div>
</a>
{% if project.state == 'CL' %}
<div>
The project is closed. Come back later to see the submissions.
</div>

{% else %}

{% if is_authenticated %}
{% for submission in submissions %}
<div class="p-2 border-bottom {% cycle 'bg-white' 'bg-light' %}">
<div class="d-flex justify-content-between align-items-center text-decoration-none">
<a href="{{ submission.github_link }}" target="_blank">
<div>
{{ submission.enrollment.display_name }}
<span
class="ms-2"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{{ submission.github_link }}">
<i class="fas fa-external-link-alt"></i>
</span>
</div>
</a>

<div>
{% if submission.to_evaluate %}
<a href="{% url 'projects_eval_submit' course_slug=course.slug project_slug=project.slug review_id=submission.review.id %}" class="btn btn-primary btn-sm">
Evaluate <span class="badge bg-light text-dark">{{ submission.review.get_state_display }}</span>
</a>
{% else %}
{% if submission.own %}
{% if is_authenticated and project.state == 'PR' %}
{% if submission.to_evaluate %}
<a href="{% url 'projects_eval_submit' course_slug=course.slug project_slug=project.slug review_id=submission.review.id %}" class="btn btn-primary btn-sm">
Evaluate <span class="badge bg-light text-dark">{{ submission.review.get_state_display }}</span>
</a>
{% elif submission.own %}
Your project
{% else %}
<button onclick="confirmEvaluation('{% url 'projects_eval_add' course_slug=course.slug project_slug=project.slug submission_id=submission.id %}')" class="btn btn-outline-primary btn-sm">
<i class="fas fa-plus"></i> Add to Evaluation
</button>
{% endif %}
{% elif project.state == 'CO' %}
{{ submission.project_score }}
{% endif %}
</div>
{% endif %}
</div>
</div>
</div>
{% endfor %}
{% endfor %}
{% endif %}

<script>
function confirmEvaluation(url) {
Expand Down
4 changes: 4 additions & 0 deletions courses/templates/projects/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ <h2>Feedback:</h2>
</div>
</div>

<div class="text-center">
<a href="{% url 'project_list' course.slug project.slug %}">See all projects</a>
</div>

{% endif %}

<div class="text-center">
Expand Down
4 changes: 4 additions & 0 deletions courses/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ def projects_list_view(request, course_slug, project_slug):

submissions = ProjectSubmission.objects.filter(project=project)

if project.state == ProjectState.COMPLETED.value:
submissions = submissions.order_by('-project_score')

user = request.user
is_authenticated = user.is_authenticated

Expand All @@ -532,6 +535,7 @@ def projects_list_view(request, course_slug, project_slug):
review_ids[eval_id] = review
else:
review_ids = {}
own_submissions = set()

for submission in submissions:
if submission.id in review_ids:
Expand Down

0 comments on commit f59e974

Please sign in to comment.