diff --git a/schoolapps/static/common/style.css b/schoolapps/static/common/style.css index 0cf34295b27980a09779490ae1fc0ddbfa608257..c3ff52480690bc3af2373f3d42a0b03780bf8af9 100755 --- a/schoolapps/static/common/style.css +++ b/schoolapps/static/common/style.css @@ -245,3 +245,58 @@ table.striped > tbody > tr:nth-child(odd) { } } +/*++++++++++++++++ +FEEDBACK +++++++++++++++++*/ + +.rating { + display: flex; + flex-direction: row-reverse; + width: 450px; + min-height: 40px; +} + +.rating label { + display: flex; + flex: 1; + position: relative; + cursor: pointer; +} +.rating label:after { + font-family: 'Material Icons'; + -webkit-font-feature-settings: 'liga'; + position: absolute; + color: #777; + top: 0; + left: 0; + width: 100%; + height: 100%; + text-align: center; + font-size: 40px; + content: 'star_border'; +} +.rating input { + display: none!important; +} +.rating > input:checked + label:after, +.rating > input:checked ~ label:after { + content: "star"; + color: #FFD700; +} +.rating > input:hover + label:after, +.rating > input:hover ~ label:after { + content: "star"; + color: #FFD700; +} +.float_right{ + float: right; +} +.feedback-input{ + width: 450px!important; + margin-top: 0; + margin-bottom: 0; +} +.span-info{ + width: 24px; + vertical-align: middle; +} diff --git a/schoolapps/support/forms.py b/schoolapps/support/forms.py index 3132dc64d86336cc877fe08e01c24f5fa5bb91fe..ac58c2a3bc34822d145a9c5945ecafb4810e12ee 100644 --- a/schoolapps/support/forms.py +++ b/schoolapps/support/forms.py @@ -12,31 +12,44 @@ class REBUSForm(forms.Form): class FeedbackForm(forms.Form): - ratings = [(1, 1), (2, 2), (3, 3), - (4, 4), (5, 5), (6, 6), - (7, 7), (8, 8), (9, 9), - (10, 10)] - - design_rating = forms.ChoiceField(label='Bitte bewerte das Design von SchoolApps auf einer Skala von 1 bis 10', - choices=ratings, required=True) - performance_rating = forms.ChoiceField(label='Bitte bewerte die Geschwindigkeit von SchoolApps auf einer ' - 'Skala von 1 bis 10', - choices=ratings, required=True) - usability_rating = forms.ChoiceField(label='Bitte bewerte die Benutzerfreundlichkeit von SchoolApps auf ' - 'einer Skala von 1 bis 10', - choices=ratings, required=True) + ratings = [(5, 5), (4, 4), (3, 3), (2, 2), (1, 1)] + + design_rating = forms.ChoiceField(label="Design", + choices=ratings, + widget=forms.RadioSelect) + + performance_rating = forms.ChoiceField(label='Geschwindigkeit', + choices=ratings, + widget=forms.RadioSelect(attrs={}), + required=False) + + usability_rating = forms.ChoiceField(label='Benutzerfreundlichkeit', + choices=ratings, + widget=forms.RadioSelect(attrs={"checked": "checked"}), + required=True) + overall_rating = forms.ChoiceField(label='Bitte bewerte SchoolApps insgesamt auf einer Skala von 1 bis 10', - choices=ratings, required=True) + choices=ratings, + widget=forms.RadioSelect(attrs={"checked": "checked"}), + required=True) - apps = forms.CharField(label="Bitte gebe uns Feedback zu den einzelnen Funktionen von SchoolApps", required=False, + apps = forms.CharField(label="Bitte gebe uns Feedback zu den einzelnen Funktionen von SchoolApps", + required=False, widget=forms.Textarea) - more = forms.CharField(label="Möchtest du uns sonst noch etwas mitteilen?", required=False, widget=forms.Textarea) - ideas = forms.CharField(label='Hast du Ideen, was wir noch in SchoolApps einbauen könnten/sollten?', - required=False, widget=forms.Textarea) - - layout = Layout(Row('design_rating', 'performance_rating', 'usability_rating'), - Row('overall_rating'), - Row("apps"), - Row('ideas'), - Row('more'), - ) + + more = forms.CharField(label="Möchtest du uns sonst noch etwas mitteilen?", + required=False, + widget=forms.Textarea( + attrs={"class": "materialize-textarea"} + )) + ideas = forms.CharField( + label='Hast du Ideen, was wir noch in SchoolApps einbauen könnten/sollten?', + required=False, + widget=forms.Textarea) + + #layout = Layout(#Row('design_rating', 'performance_rating', 'usability_rating'), + #Row('overall_rating'), + #Row("apps"), + #Row('ideas'), + #Row('more'), + # ) diff --git a/schoolapps/support/templates/support/feedback.html b/schoolapps/support/templates/support/feedback.html index 4637e9e3ae06d456df21e1f00dd0773f1cc3eacc..7dc7312bcdb6357369a144953009e0e69f5ac724 100644 --- a/schoolapps/support/templates/support/feedback.html +++ b/schoolapps/support/templates/support/feedback.html @@ -1,6 +1,7 @@ {% include 'partials/header.html' %} {% load material_form %} + <main> <p class="flow-text"> @@ -9,12 +10,95 @@ <form method="post"> {% csrf_token %} - {% form form=form %} - {% endform %} - <button type="submit" name="go" class="btn waves-effect waves-light green"> - Feedback senden + + + <!--<ul> + <div>Design <span class="red-text">*</span> + <div class="rating float_right"> + {% for choice in form.design_rating.field.choices %} + <li> + <input type="radio" name="design_rating" value="{{choice.0}}" required + {% ifequal form.design_rating.data choice.0 %} + checked="checked" + {% endifequal %}/> + <lable for="">{{choice.1}}</lable> + </li> + {% endfor %} + </div> + </div> + </ul>--> + + <ul class="collection"> + <li class="collection-item"> + <div>{{ form.design_rating.label }} <span class="red-text">*</span> + <div class="rating float_right"> + {% for radio in form.design_rating %} + {{ radio.tag }} + <label for="{{ radio.id_for_label }}"></label> + {% endfor %} + </div> + </div> + </li> + <li class="collection-item"> + <div>{{ form.performance_rating.label }} <span class="red-text">*</span> + <div class="rating float_right"> + {% for radio in form.performance_rating %} + {{ radio.tag }} + <label for="{{ radio.id_for_label }}"></label> + {% endfor %} + </div> + </div> + </li> + <li class="collection-item"> + <div>{{ form.usability_rating.label }} <span class="red-text">*</span> + <div class="rating float_right"> + {% for radio in form.usability_rating %} + {{ radio.tag }} + <label for="{{ radio.id_for_label }}"></label> + {% endfor %} + </div> + </div> + </li> + <li class="collection-item"> + <div>{{ form.overall_rating.label }} <span class="red-text">*</span> + <div class="rating float_right"> + {% for radio in form.overall_rating %} + {{ radio.tag }} + <label for="{{ radio.id_for_label }}"></label> + {% endfor %} + </div> + </div> + </li> + + + <li class="collection-item"> + <div>{{ form.ideas.label }} + <div class="input-field inline float_right feedback-input"> + <input name="{{ form.ideas.html_name }}" type="text" {{ form.ideas.required}}> + </div> + </div> + + </li> + + <li class="collection-item"> + <div> + <div class="input-field col s12"> + <textarea id="{{ form.more.id_for_label }}" name="{{ form.more.html_name }}" class="materialize-textarea"></textarea> + <label for="{{ form.more.id_for_label }}">{{ form.more.label }}</label> + </div> + </div> + </li> + + </ul> + + <!-- (add two "%"s to make it work again :) + { form form=form %} + { endform %} --> + + <button type="submit" name="go" class="btn waves-effect waves-light green"> + Feedback senden <i class="material-icons right">send</i> - </button> + </button> </form> diff --git a/schoolapps/support/templates/support/mail/feedback.html b/schoolapps/support/templates/support/mail/feedback.html index ade88167138bc9cece4e59a9391243234d87b37c..fba4e0416a21d59f322317812afca51da68f71fe 100755 --- a/schoolapps/support/templates/support/mail/feedback.html +++ b/schoolapps/support/templates/support/mail/feedback.html @@ -4,7 +4,7 @@ <p>Hallo,</p> <p>es gibt neues Feedback:</p> <blockquote> - Bewertungen: {{ design }}/10 (Design), {{ performance }}/10 (Geschwindigkeit), {{ usability }}/10 + Bewertungen: {{ design }}/5 (Design), {{ performance }}/5 (Geschwindigkeit), {{ usability }}/5 (Benutzerfreundlichkeit) Bewertung (insgesamt): {{ overall }}/10 diff --git a/schoolapps/support/templates/support/mail/feedback.txt b/schoolapps/support/templates/support/mail/feedback.txt index 24604afac56efbb62a021a2bbbbcdf87e807f6e7..b547bfb48f85da3cefd3c12741d60cdf8ceaf2b9 100755 --- a/schoolapps/support/templates/support/mail/feedback.txt +++ b/schoolapps/support/templates/support/mail/feedback.txt @@ -3,9 +3,9 @@ Hallo, es gibt neues Feedback: -Bewertungen: {{ design }}/10 (Design), {{ performance }}/10 (Geschwindigkeit), {{ usability }}/10 (Benutzerfreundlichkeit) +Bewertungen: {{ design }}/5 (Design), {{ performance }}/5 (Geschwindigkeit), {{ usability }}/5 (Benutzerfreundlichkeit) -Bewertung (insgesamt): {{ overall }}/10 +Bewertung (insgesamt): {{ overall }}/5 Feedback zu einzelnen Apps: {{ apps }} diff --git a/schoolapps/support/views.py b/schoolapps/support/views.py index f25d8b7f962d28902c02e27ce22eb5de9008909c..c52ca846c8a4fe6574f5236c592eba0ed119482e 100644 --- a/schoolapps/support/views.py +++ b/schoolapps/support/views.py @@ -65,68 +65,70 @@ def rebus(request): def feedback(request): - if request.method == 'POST': - form = FeedbackForm(request.POST) - if form.is_valid(): - # Read out form data - design_rating = form.cleaned_data['design_rating'] - performance_rating = form.cleaned_data['performance_rating'] - usability_rating = form.cleaned_data['usability_rating'] - overall_rating = form.cleaned_data['overall_rating'] - more = form.cleaned_data['more'] - ideas = form.cleaned_data['ideas'] - apps = form.cleaned_data["apps"] - - # Build description for kanboard - description = """ - **Bewertungen:** {}/10 (Design), {}/10 (Geschwindigkeit), {}/10 (Benutzerfreundlichkeit) - - **Bewertung (insgesamt):** {}/10 - - **Feedback zu einzelnen Apps:** {} - - **Ideen/Wünsche:** {} - - **Sonstiges:** {} - """.format(design_rating, performance_rating, usability_rating, overall_rating, apps, ideas, more) - - # Get color for kanboard by rating - if int(overall_rating) <= 3: - color = "red" - elif 3 < int(overall_rating) <= 7: - color = "yellow" - else: - color = "green" - - # Add kanboard task - kb.create_task(project_id=p_id_feedback, - title="Feedback von {}".format(request.user.username), - description=description, - color_id=color) - - # Register activity - act = Activity(title="Du hast uns Feedback gegeben.", - description="Du hast uns auf einer Skala von 1 bis 10 mit {} bewertet.".format( - overall_rating), app="Feedback", - user=request.user) - act.save() - - # Send mail - context = { - "design": design_rating, - "performance": performance_rating, - "usability": usability_rating, - "overall": overall_rating, - "more": more, - "apps": apps, - "ideas": ideas, - "user": request.user.username - } - send_mail_with_template("Neues Feedback", ["support@katharineum.de"], "support/mail/feedback.txt", - "support/mail/feedback.html", context) - - return render(request, 'support/feedback_submitted.html') - else: - form = FeedbackForm() - - return render(request, 'support/feedback.html', {'form': form}) + if request.method == 'POST': + form = FeedbackForm(request.POST) + if form.is_valid(): + # Read out form data + design_rating = form.cleaned_data['design_rating'] + performance_rating = form.cleaned_data['performance_rating'] + usability_rating = form.cleaned_data['usability_rating'] + overall_rating = form.cleaned_data['overall_rating'] + more = form.cleaned_data['more'] + ideas = form.cleaned_data['ideas'] + apps = form.cleaned_data["apps"] + + # Build description for kanboard + description = """ + **Bewertungen:** {}/5 (Design), {}/5 (Geschwindigkeit), {}/5 (Benutzerfreundlichkeit) + + **Bewertung (insgesamt):** {}/5 + + **Feedback zu einzelnen Apps:** {} + + **Ideen/Wünsche:** {} + + **Sonstiges:** {} + """.format(design_rating, performance_rating, usability_rating, overall_rating, apps, ideas, more) + + # Get color for kanboard by rating + if int(overall_rating) <= 3: + color = "red" + elif 3 < int(overall_rating) <= 7: + color = "yellow" + else: + color = "green" + + # Add kanboard task + kb.create_task(project_id=p_id_feedback, + title="Feedback von {}".format(request.user.username), + description=description, + color_id=color) + + # Register activity + act = Activity(title="Du hast uns Feedback gegeben.", + description="Du hast uns auf einer Skala von 1 bis 5 mit {} Sternen bewertet.".format( + overall_rating), app="Feedback", + user=request.user) + act.save() + + # Send mail + context = { + "design": design_rating, + "performance": performance_rating, + "usability": usability_rating, + "overall": overall_rating, + "more": more, + "apps": apps, + "ideas": ideas, + "user": request.user.username + } + send_mail_with_template("Neues Feedback von {}".format(request.user.username), ["support@katharineum.de"], "support/mail/feedback.txt", + "support/mail/feedback.html", context) + print(context) + + return render(request, 'support/feedback_submitted.html') + else: + form = FeedbackForm() + + + return render(request, 'support/feedback.html', {'form': form})