summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2008-04-07 13:59:28 +0200
committerGuillaume Seguin <guillaume@segu.in>2008-04-07 13:59:28 +0200
commit97405921e778eb35618919540d8d8b33809f1552 (patch)
tree109520a8a587fa7e1b365d020a9f14d9dcc2e703
parent5fa4ef5325a084728b1a970d2cd22bdba49b9b6d (diff)
downloadmarks-97405921e778eb35618919540d8d8b33809f1552.tar.gz
marks-97405921e778eb35618919540d8d8b33809f1552.tar.bz2
* Add ratings view to compare totals of marks sets against a given ratings set
-rw-r--r--main/views.py29
-rw-r--r--templates/main/ratings.html26
-rw-r--r--urls.py1
3 files changed, 56 insertions, 0 deletions
diff --git a/main/views.py b/main/views.py
index d5b77a0..4dd8f98 100644
--- a/main/views.py
+++ b/main/views.py
@@ -126,6 +126,35 @@ def exam_view (request, exam):
}
return render_page (request, data, "main/exam.html")
+def ratings_view (request, ratings_set):
+ '''View the totals of a given ratings set'''
+ user_data = get_user_data (request)
+ if not ratings_set in user_data["ratings"]:
+ return home_view (request)
+ ratings = {}
+ for exam in user_data["exams"]:
+ ratings[exam] = get_rating (user_data, exam, ratings_set)
+ totals = {}
+ total_ratings = 0
+ for exam in user_data["exams"]:
+ rating = get_rating (user_data, exam, ratings_set)
+ total_ratings += rating
+ for marks_set in user_data["marks"]:
+ if total_ratings:
+ total = 0
+ for exam in user_data["exams"]:
+ rating = get_rating (user_data, exam, ratings_set)
+ total += rating * get_mark (user_data, exam, marks_set)
+ totals[marks_set] = round (float (total) / total_ratings, 2)
+ else:
+ totals[marks_set] = 0
+ data = {
+ "ratings_set": ratings_set,
+ "ratings": ratings,
+ "totals": totals,
+ }
+ return render_page (request, data, "main/ratings.html")
+
def marks_view (request, marks_set):
'''View the totals of a given marks set'''
user_data = get_user_data (request)
diff --git a/templates/main/ratings.html b/templates/main/ratings.html
new file mode 100644
index 0000000..34deef4
--- /dev/null
+++ b/templates/main/ratings.html
@@ -0,0 +1,26 @@
+{% extends "main/base.html" %}
+{% load marks_tags %}
+
+
+{% block title %}{{ block.super }} ~ Jeu de coefficients {{ ratings_set }}{% endblock %}
+
+{% block content %}
+{% rounded_block_start 'fullblock' %}Jeu de coefficients {{ ratings_set }}{% end_rounded_block_start %}
+<h4>Coefficients</h4>
+<div class="blockcontent">
+<ul>
+ {% for exam,rating in ratings.items %}
+ <li>{{ exam }}: {{ rating }}</li>
+ {% endfor %}
+</ul>
+</div>
+<h4>Totaux</h4>
+<div class="blockcontent">
+<ul>
+ {% for set_name,total in totals.items %}
+ <li>{{ set_name }}: {{ total }}</li>
+ {% endfor %}
+</ul>
+</div>
+{% rounded_block_end %}
+{% endblock %}
diff --git a/urls.py b/urls.py
index f5aea49..3be3d92 100644
--- a/urls.py
+++ b/urls.py
@@ -24,6 +24,7 @@ urlpatterns = patterns('',
(r'^reset$', 'marks.main.views.reset_view'),
(r'^export$', 'marks.main.views.export_view'),
(r'^view/exam/(.+)$', 'marks.main.views.exam_view'),
+ (r'^view/ratings/(.+)$', 'marks.main.views.ratings_view'),
(r'^view/marks/(.+)$', 'marks.main.views.marks_view'),
(r'^delete/exam/(.+)$', 'marks.main.views.delete_exam_view'),
(r'^delete/ratings/(.+)$', 'marks.main.views.delete_ratings_view'),