diff --git a/core/static/core/style.scss b/core/static/core/style.scss index 548c3b97..bfd84785 100644 --- a/core/static/core/style.scss +++ b/core/static/core/style.scss @@ -1668,3 +1668,14 @@ label { } } + +/* --------------------------------------pedagogy-----------------------------------*/ + +.pedagogy { + &.star_not_checked { + color : gray; + } + &.star_checked { + color : orange; + } +} diff --git a/pedagogy/forms.py b/pedagogy/forms.py index 9180516d..00984cf7 100644 --- a/pedagogy/forms.py +++ b/pedagogy/forms.py @@ -24,6 +24,8 @@ from django import forms from django.utils.translation import ugettext_lazy as _ +from django.forms.widgets import Widget +from django.templatetags.static import static from core.views.forms import MarkdownInput from core.models import User @@ -72,6 +74,10 @@ class UVForm(forms.ModelForm): self.fields["author"].initial = author_id +class StarList(forms.NumberInput): + template_name = "pedagogy/starlist.jinja" + + class UVCommentForm(forms.ModelForm): """ Form handeling creation and edit of an UVComment @@ -93,6 +99,11 @@ class UVCommentForm(forms.ModelForm): "comment": MarkdownInput, "author": forms.HiddenInput, "uv": forms.HiddenInput, + "grade_global": StarList, + "grade_utility": StarList, + "grade_interest": StarList, + "grade_teaching": StarList, + "grade_work_load": StarList, } def __init__(self, author_id, uv_id, *args, **kwargs): diff --git a/pedagogy/templates/pedagogy/macros.jinja b/pedagogy/templates/pedagogy/macros.jinja new file mode 100644 index 00000000..78b78afc --- /dev/null +++ b/pedagogy/templates/pedagogy/macros.jinja @@ -0,0 +1,15 @@ +{% macro display_star(grade) -%} + + {% if grade >= 0 %} + {% for i in range(5) %} + {% if i <= grade %} + + {% else %} + + {% endif %} + {% endfor %} + {% else %} +

{% trans %} not rated {% endtrans %}

+ {% endif %} + +{%- endmacro %} \ No newline at end of file diff --git a/pedagogy/templates/pedagogy/starlist.jinja b/pedagogy/templates/pedagogy/starlist.jinja new file mode 100644 index 00000000..53dc4290 --- /dev/null +++ b/pedagogy/templates/pedagogy/starlist.jinja @@ -0,0 +1,41 @@ +
+ {# #} + + + {% for i in i|rjust:5 %} + + {% endfor %} + +
\ No newline at end of file diff --git a/pedagogy/templates/pedagogy/uv_detail.jinja b/pedagogy/templates/pedagogy/uv_detail.jinja index 42b02b9c..56bb7385 100644 --- a/pedagogy/templates/pedagogy/uv_detail.jinja +++ b/pedagogy/templates/pedagogy/uv_detail.jinja @@ -1,4 +1,5 @@ {% extends "core/base.jinja" %} +{% import "pedagogy/macros.jinja" as macros%} {% block title %} {% trans %}UV Details{% endtrans %} @@ -23,11 +24,11 @@ {% if object.comments.exists() %}

{% trans %}Comments{% endtrans %}

{% for comment in object.comments.all() %} -

{{ comment.grade_global }}

-

{{ comment.grade_utility }}

-

{{ comment.grade_interest }}

-

{{ comment.grade_teaching }}

-

{{ comment.grade_work_load }}

+

{{ macros.display_star(comment.grade_global) }}

+

{{ macros.display_star(comment.grade_utility) }}

+

{{ macros.display_star(comment.grade_interest) }}

+

{{ macros.display_star(comment.grade_teaching) }}

+

{{ macros.display_star(comment.grade_work_load) }}

{{ comment.comment|markdown }}

{% trans %}Published: {% endtrans %}{{ comment.publish_date }}

{% trans %}Author: {% endtrans %}{{ comment.author }}

@@ -48,4 +49,4 @@ {{ form.as_p() }}

-{% endblock %} \ No newline at end of file +{% endblock %}