From a4dde237392e63261ea37a4a9907fa1d9bd239db Mon Sep 17 00:00:00 2001
From: janmax <mail-github@jmx.io>
Date: Thu, 6 Jul 2017 12:50:07 +0200
Subject: [PATCH] Added a progressbar with simple overall modifications to the
 panel

---
 core/templates/base.html                      |  2 +-
 core/templates/core/r/progress_card.html      |  8 ++-
 .../core/r/student_submission_list.html       |  2 +-
 core/templates/core/t/tutor_startpage.html    | 52 +++++++++++--------
 core/views/user_startpages.py                 |  7 ++-
 5 files changed, 45 insertions(+), 26 deletions(-)

diff --git a/core/templates/base.html b/core/templates/base.html
index 139ac915..c3c791fa 100644
--- a/core/templates/base.html
+++ b/core/templates/base.html
@@ -40,7 +40,7 @@
   </a>
 
   <div class="navbar-nav mr-auto">
-    {% block navbar %}{% endblock navbar %}
+    {% block navbar %}Grady, Sir. Delbert Grady.{% endblock navbar %}
   </div>
 
   {% if user.is_authenticated %}
diff --git a/core/templates/core/r/progress_card.html b/core/templates/core/r/progress_card.html
index 5ad002c4..99b20f30 100644
--- a/core/templates/core/r/progress_card.html
+++ b/core/templates/core/r/progress_card.html
@@ -5,12 +5,18 @@
     <thead>
       <th>Name</th>
       <th>Progress</th>
+      <th></th>
     </thead>
     <tbody>
       {% for submission_type in submission_type_list %}
       <tr>
         <td class="align-middle">{{ submission_type }}</td>
-        <td class="align-middle"><code>{{ submission_type.feedback_count }} / {{submission_type.submission_count}}</code></td>
+        <td class="align-middle" width="30%">
+          <div class="progress">
+            <div class="progress-bar" role="progressbar" style="width: {{submission_type.percentage}}%;"></div>
+          </div>
+        </td>
+      <td class="align-middle fit"><code>{{ submission_type.feedback_count }} / {{submission_type.submission_count}}</code></td>
       </tr>
       {% endfor %}
     </tbody>
diff --git a/core/templates/core/r/student_submission_list.html b/core/templates/core/r/student_submission_list.html
index 2b28a8d8..59bea601 100644
--- a/core/templates/core/r/student_submission_list.html
+++ b/core/templates/core/r/student_submission_list.html
@@ -24,7 +24,7 @@
           <td class="align-middle fit"> <a href="{% url 'SubmissionViewReviewer' submission.slug %}" class="btn btn-outline-primary mb-1" name="edit" value="View">View submission</a></td>
           <td class="align-middle"> {{ submission.type }} </td>
           <td class="align-middle"> {{ submission.student }} </td>
-          <td class="align-middle">
+          <td class="align-middle fit">
             {% if submission.feedback %}
             <code> {{ submission.feedback.score }} / {{ submission.type.full_score }} </code>
             {% else %}
diff --git a/core/templates/core/t/tutor_startpage.html b/core/templates/core/t/tutor_startpage.html
index f6929422..c9c3277a 100644
--- a/core/templates/core/t/tutor_startpage.html
+++ b/core/templates/core/t/tutor_startpage.html
@@ -14,6 +14,7 @@
       <h4 class="card-header">Overview</h4>
       <table class="table nomargin">
         <thead>
+          <th></th>
           <th>Name</th>
           <th>Progress</th>
           <th></th>
@@ -21,14 +22,23 @@
         <tbody>
           {% for submission_type in submission_type_list %}
           <tr>
-            <td class="align-middle">{{ submission_type }}</td>
-            <td class="align-middle"><code>{{ submission_type.feedback_count }} / {{submission_type.submission_count}}</code></td>
-            <td class="align-middle"><a role="button" class="btn btn-secondary" href="{% url 'CreateFeedbackForType' submission_type.slug %}">Get</a></td>
+            <td class="align-middle"><a role="button" class="btn btn-secondary {% if submission_type.percentage == 100 %}disabled{% endif %}" href="{% url 'CreateFeedbackForType' submission_type.slug %}">Get</a></td>
+            <td class="align-middle fit">{{ submission_type }}</td>
+            <td class="align-middle" width="70%">
+              <div class="progress">
+                <div class="progress-bar" role="progressbar" style="width: {{submission_type.percentage}}%;"></div>
+              </div>
+            </td>
+            <td class="align-middle fit"><code>{{ submission_type.feedback_count }} / {{submission_type.submission_count}}</code></td>
           </tr>
           {% endfor %}
+        </tbody>
+      </table>
+      <table class="table nomargin">
+        <tbody>
           <tr>
-            <td><strong>Your contribution:</strong></td>
-            <td colspan="2"><code>{% if feedback_list|length > 0 %} {{feedback_list|length}} {% else %} None. Sad. {% endif %}</code></td>
+            <td class="fit"><strong>Your contribution:</strong></td>
+            <td colspan="6"><code>{% if feedback_list|length > 0 %} {{feedback_list|length}} {% else %} None. Sad. {% endif %}</code></td>
           </tr>
         </tbody>
       </table>
@@ -48,13 +58,13 @@
           <th></th>
         </thead>
         <tbody>
-            {% for feedback in feedback_open_list %}
-            <tr>
-              <td class="align-middle"> {{ feedback.of_submission.type }} </td>
-              <td class="align-middle"> {{ feedback.of_tutor }} </td>
-              <td class="align-middle"><a class="btn btn-secondary" href="{% url 'FeedbackEdit' feedback.slug %}"> Assign </a></td>
-            </tr>
-            {% endfor %}
+          {% for feedback in feedback_open_list %}
+          <tr>
+            <td class="align-middle"> {{ feedback.of_submission.type }} </td>
+            <td class="align-middle"> {{ feedback.of_tutor }} </td>
+            <td class="align-middle"><a class="btn btn-secondary" href="{% url 'FeedbackEdit' feedback.slug %}"> Assign </a></td>
+          </tr>
+          {% endfor %}
         </tbody>
       </table>
     </div>
@@ -81,7 +91,7 @@
           {% for feedback in feedback_list %}
           <tr>
             <td>
-            {% include "core/component/feedback_badge.html" %}
+              {% include "core/component/feedback_badge.html" %}
             </td>
             <td> {{ feedback.of_submission.type }} </td>
             <td> <code> {{ feedback.score }} / {{feedback.of_submission.type.full_score}} </code> </td>
@@ -106,14 +116,14 @@
 <script>
   $(document).ready(function() {
     $('#list-id-tutoren').DataTable({
-        "paging":     false,
-        "info":       false,
-        "searching":  false,
-        "stateSave":  true,
-        "order":      [[ 0, 'desc' ], [ 3, 'desc' ]],
-        "columnDefs": [
-          { "orderable": false, "targets": -1 },
-        ]
+      "paging":     false,
+      "info":       false,
+      "searching":  false,
+      "stateSave":  true,
+      "order":      [[ 0, 'desc' ], [ 3, 'desc' ]],
+      "columnDefs": [
+      { "orderable": false, "targets": -1 },
+      ]
     });
   });
 </script>
diff --git a/core/views/user_startpages.py b/core/views/user_startpages.py
index 1a0e4f4a..f6fd29f1 100644
--- a/core/views/user_startpages.py
+++ b/core/views/user_startpages.py
@@ -1,6 +1,6 @@
 from django.contrib.auth.decorators import login_required
 from django.contrib.auth.models import User
-from django.db.models import Count, Q, Case, When, IntegerField, Value
+from django.db.models import Count, Q, F, Case, When, IntegerField, Value
 from django.http import HttpResponseRedirect
 from django.shortcuts import render
 from django.urls import reverse
@@ -46,6 +46,8 @@ def get_annotated_feedback_count():
             )
         ).annotate(
             submission_count=Count('submissions')
+        ).annotate(
+            percentage=(F('feedback_count') * 100 / F('submission_count'))
         ).all().order_by('name')
 
 def get_annotated_tutor_list():
@@ -54,8 +56,9 @@ def get_annotated_tutor_list():
 
 @group_required('Tutors')
 def tutor_view(request):
+    submission_type = get_annotated_feedback_count()
     context = {
-        'submission_type_list': get_annotated_feedback_count(),
+        'submission_type_list': submission_type,
         'feedback_list': Feedback.objects.filter(of_tutor=request.user),
         'feedback_open_list': Feedback.objects.filter(Q(status=Feedback.OPEN) & ~Q(of_tutor=request.user)),
     }
-- 
GitLab