From: yomguy Date: Mon, 17 Dec 2012 00:57:59 +0000 (+0100) Subject: add more progression bars, update colors, real percent update in answer progressbar X-Git-Tag: 0.9-probarreau~249 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=c96f362c514778c4383b827ce95f0953ef105a21;p=teleforma.git add more progression bars, update colors, real percent update in answer progressbar --- diff --git a/teleforma/static/teleforma/css/teleforma.css b/teleforma/static/teleforma/css/teleforma.css index 2ca17c7b..581e2663 100644 --- a/teleforma/static/teleforma/css/teleforma.css +++ b/teleforma/static/teleforma/css/teleforma.css @@ -1680,29 +1680,6 @@ input,textarea{ font-size: 1.2em; } - -.ui-progressbar { - height: 10px; - /*webkit rainbow gradient*/ - background-image: -webkit-gradient(linear, left top, right top, - color-stop(0.00, blue), - color-stop(25%, green), - color-stop(50%, yellow), - color-stop(75%, orange), - color-stop(1.00, red) - ); - - transform:rotate(180deg); - -ms-transform:rotate(180deg); /* IE 9 */ - -moz-transform:rotate(180deg); /* Firefox */ - -webkit-transform:rotate(180deg); /* Safari and Chrome */ - -o-transform:rotate(180deg); /* Opera */ - - -moz-border-radius: 8px 0px 8px 8px; - -webkit-border-radius: 8px 0px 8px 8px; - border-radius: 8px 0px 8px 8px; - } - .messages { padding: 0.5em; } @@ -1752,3 +1729,48 @@ form .exceed{ border: 1px solid #adadad; color:#080; } + +.progress { + background-color: white; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; + +} + +.progress ul { + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; + +} + +.progress li { + font-size: 1.2em; +} + +.ui-progressbar { + margin-top: 0.5em; + height: 10px; + + /*webkit rainbow gradient*/ + background-color: white; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; + } + +#progressbar-general .ui-progressbar-value { + background-color: #4f628a; +} + + +#progressbar-seminar .ui-progressbar-value { + background-color: green; + } + + +#progressbar-answer .ui-progressbar-value { + background-color: #bb0000; + } + diff --git a/teleforma/static/teleforma/js/charCount.js b/teleforma/static/teleforma/js/charCount.js index 5cc239f2..5307208c 100644 --- a/teleforma/static/teleforma/js/charCount.js +++ b/teleforma/static/teleforma/js/charCount.js @@ -28,7 +28,7 @@ }; var options = $.extend(defaults, options); - + function calculate(obj){ var count = $(obj).val().length; if(count >= options.necessary){ @@ -42,10 +42,16 @@ } $(obj).next().html(options.counterText + count + ' / ' + options.necessary); + var percent = parseInt(count / options.necessary * 100); + if ( percent >= 100 ) { + percent = 100; + } + $('#answer-progress').html(percent); + $('#progressbar-answer').progressbar({ value: percent }); }; this.each(function() { - $(this).after('<'+ options.counterElement +' id="counter" class="' + options.css + '">'+ options.counterText +''); + $(this).after('<'+ options.counterElement +' id="counter" class="' + options.css + '">'+ options.counterText +''); calculate(this); $(this).keyup(function(){calculate(this)}); $(this).change(function(){calculate(this)}); diff --git a/teleforma/templates/teleforma/answer_form.html b/teleforma/templates/teleforma/answer_form.html index 35a4991e..1d600374 100644 --- a/teleforma/templates/teleforma/answer_form.html +++ b/teleforma/templates/teleforma/answer_form.html @@ -59,8 +59,29 @@ $(document).ready(function(){ {% trans "Save" %} -{% trans "Submit it" %} +{% trans "Submit it" %} {% endblock course_content %} + +{% block progress %} +
+

status {% trans "Progress" %}

+
+
    +
  • {% trans "General progress" %} : {{ total_progress }}% +
    +
  • +
  • {% trans "Seminar progress" %} : {{ seminar_progress }}% +
    +
  • +
  • {% trans "Answer progress" %} : 0% +
    +
  • + +
+ +
+
+{% endblock progress %} + diff --git a/teleforma/templates/teleforma/seminar_detail.html b/teleforma/templates/teleforma/seminar_detail.html index 6b3294da..bc7621d2 100644 --- a/teleforma/templates/teleforma/seminar_detail.html +++ b/teleforma/templates/teleforma/seminar_detail.html @@ -108,11 +108,20 @@ {% endblock course %} -{% block local_progress %} + +{% block progress %}
-

status {% trans "Progression" %} : {{ 100|sub:progress }}%

+

status {% trans "Progress" %}

-
+
    +
  • {% trans "General progress" %} : {{ total_progress }}% +
    +
  • +
  • {% trans "Seminar progress" %} : {{ seminar_progress }}% +
    +
  • +
-{% endblock local_progress %} \ No newline at end of file +{% endblock progress %} + diff --git a/teleforma/templates/teleforma/seminars.html b/teleforma/templates/teleforma/seminars.html index 948abe5a..663506b9 100644 --- a/teleforma/templates/teleforma/seminars.html +++ b/teleforma/templates/teleforma/seminars.html @@ -15,6 +15,21 @@ $(function () { {% endblock extra_javascript %} +{% block infra_javascript %} + +{% endblock infra_javascript %} + {% block content %}
@@ -93,14 +108,18 @@ $(function () {
-{% block local_progress %} +{% block progress %}

status {% trans "Informations" %}

-
+
    +
  • {% trans "General progress" %} : {{ total_progess }} +
    +
  • +
-{% endblock local_progress %} +{% endblock progress %} {% block status %} {% get_telecaster as telecaster %} diff --git a/teleforma/templates/telemeta/base.html b/teleforma/templates/telemeta/base.html index ac56ee9d..ed4a869d 100644 --- a/teleforma/templates/telemeta/base.html +++ b/teleforma/templates/telemeta/base.html @@ -48,13 +48,6 @@ - {% if user.is_authenticated %} @@ -72,6 +65,7 @@ $(function() { {% endblock %} {% block extra_javascript %}{% endblock %} +{% block infra_javascript %}{% endblock %} diff --git a/teleforma/views/pro.py b/teleforma/views/pro.py index 9fa958cd..7bde0601 100644 --- a/teleforma/views/pro.py +++ b/teleforma/views/pro.py @@ -63,7 +63,6 @@ def get_seminars(user): def seminar_progress(user, seminar): """return the user progress of a seminar in percent - WARNING! the result is 100-progress so that we can customize the progress bar background. """ progress = 0 @@ -84,26 +83,27 @@ def seminar_progress(user, seminar): progress += question.weight if total != 0: - return 100-int(progress*100/total) + return int(progress*100/total) else: - return 100 + return 0 def total_progress(user): """return the user progress of all seminars in percent""" - revisions = user.seminar_revision.all() progress = 0 - n = 0 - - for revision in revisions: - progress += revision.progress - n += 1 + auditor = user.auditor.all() + if auditor: + seminars = auditor[0].seminars.all() + elif user.is_superuser or user.is_staff: + seminars = Seminar.objects.all() + for seminar in seminars: + progress += seminar_progress(user, seminar) - if n: - return 100-int(progress/n) + if seminars: + return int(progress/len(seminars)) else: - return 100 + return 0 def seminar_validated(user, seminar): validated = [] @@ -129,7 +129,7 @@ class SeminarView(DetailView): context = super(SeminarView, self).get_context_data(**kwargs) seminar = self.get_object() context['all_seminars'] = get_seminars(self.request.user) - context['progress'] = seminar_progress(self.request.user, seminar) + context['seminar_progress'] = seminar_progress(self.request.user, seminar) context['total_progress'] = total_progress(self.request.user) context['validated'] = seminar_validated(self.request.user, seminar) return context @@ -146,9 +146,8 @@ class SeminarsView(ListView): def get_context_data(self, **kwargs): context = super(SeminarsView, self).get_context_data(**kwargs) - user = self.request.user context['all_seminars'] = self.seminars - context['total_progress'] = total_progress(user) + context['total_progress'] = total_progress(self.request.user) return context @method_decorator(login_required) @@ -226,7 +225,8 @@ class AnswerView(FormView): context['all_seminars'] = get_seminars(self.request.user) context['question'] = self.question context['seminar'] = self.question.seminar - context['progress'] = seminar_progress(self.request.user, self.question.seminar) + context['seminar_progress'] = seminar_progress(self.request.user, self.question.seminar) + context['total_progress'] = total_progress(self.request.user) return context def get_success_url(self): @@ -247,7 +247,8 @@ class MediaPackageView(DetailView): context['all_seminars'] = all_seminars context['seminar'] = seminar context['media_package'] = media_package - context['progress'] = seminar_progress(self.request.user, seminar) + context['seminar_progress'] = seminar_progress(self.request.user, seminar) + context['total_progress'] = total_progress(self.request.user) return context @method_decorator(login_required)