diff --git a/db.sqlite3 b/db.sqlite3 index c2c5383..0a4db40 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/tkupek_elearning/elearning/migrations/0025_user_completed_message_shown.py b/tkupek_elearning/elearning/migrations/0025_user_completed_message_shown.py new file mode 100644 index 0000000..a572c60 --- /dev/null +++ b/tkupek_elearning/elearning/migrations/0025_user_completed_message_shown.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.1 on 2016-03-05 12:48 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('elearning', '0024_auto_20160305_1222'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='completed_message_shown', + field=models.BooleanField(default=False), + ), + ] diff --git a/tkupek_elearning/elearning/migrations/0026_auto_20160305_1331.py b/tkupek_elearning/elearning/migrations/0026_auto_20160305_1331.py new file mode 100644 index 0000000..2b7c44e --- /dev/null +++ b/tkupek_elearning/elearning/migrations/0026_auto_20160305_1331.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.1 on 2016-03-05 13:31 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('elearning', '0025_user_completed_message_shown'), + ] + + operations = [ + migrations.AddField( + model_name='setting', + name='popup_completed_message', + field=models.TextField(null=True), + ), + migrations.AddField( + model_name='setting', + name='popup_completed_title', + field=models.CharField(max_length=100, null=True), + ), + ] diff --git a/tkupek_elearning/elearning/migrations/0027_auto_20160305_1333.py b/tkupek_elearning/elearning/migrations/0027_auto_20160305_1333.py new file mode 100644 index 0000000..d56f81b --- /dev/null +++ b/tkupek_elearning/elearning/migrations/0027_auto_20160305_1333.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.1 on 2016-03-05 13:33 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('elearning', '0026_auto_20160305_1331'), + ] + + operations = [ + migrations.AddField( + model_name='setting', + name='popup_leave_message', + field=models.TextField(blank=True, null=True), + ), + migrations.AlterField( + model_name='setting', + name='footer', + field=models.TextField(blank=True, null=True), + ), + migrations.AlterField( + model_name='setting', + name='logo', + field=models.CharField(blank=True, max_length=256), + ), + migrations.AlterField( + model_name='setting', + name='message_access_denied', + field=models.TextField(blank=True, null=True), + ), + migrations.AlterField( + model_name='setting', + name='message_already_answered', + field=models.TextField(blank=True, null=True), + ), + migrations.AlterField( + model_name='setting', + name='message_welcome_user', + field=models.TextField(blank=True, null=True), + ), + migrations.AlterField( + model_name='setting', + name='popup_completed_message', + field=models.TextField(blank=True, null=True), + ), + migrations.AlterField( + model_name='setting', + name='popup_completed_title', + field=models.CharField(blank=True, max_length=100, null=True), + ), + migrations.AlterField( + model_name='setting', + name='text_answer', + field=models.CharField(blank=True, max_length=100, null=True), + ), + migrations.AlterField( + model_name='setting', + name='text_next', + field=models.CharField(blank=True, max_length=100, null=True), + ), + migrations.AlterField( + model_name='setting', + name='text_solution', + field=models.CharField(blank=True, max_length=100, null=True), + ), + ] diff --git a/tkupek_elearning/elearning/migrations/0028_auto_20160305_1338.py b/tkupek_elearning/elearning/migrations/0028_auto_20160305_1338.py new file mode 100644 index 0000000..ddd36d6 --- /dev/null +++ b/tkupek_elearning/elearning/migrations/0028_auto_20160305_1338.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.1 on 2016-03-05 13:38 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('elearning', '0027_auto_20160305_1333'), + ] + + operations = [ + migrations.AlterField( + model_name='setting', + name='active', + field=models.BooleanField(default=False), + ), + ] diff --git a/tkupek_elearning/elearning/models.py b/tkupek_elearning/elearning/models.py index 4e4f6f3..45855a0 100644 --- a/tkupek_elearning/elearning/models.py +++ b/tkupek_elearning/elearning/models.py @@ -13,20 +13,34 @@ def gen_token(): class Setting(models.Model): title = models.CharField(max_length=100, null=True) - footer = models.TextField(null=True) - message_welcome_user = models.TextField(null=True) - message_access_denied = models.TextField(null=True) - message_already_answered = models.TextField(null=True) - text_answer = models.CharField(max_length=100, null=True) - text_solution = models.CharField(max_length=100, null=True) - text_next = models.CharField(max_length=100, null=True) - logo = models.CharField(max_length=256, null=False) - active = models.BooleanField(unique=True, default=False) + footer = models.TextField(null=True, blank=True) + message_welcome_user = models.TextField(null=True, blank=True) + message_access_denied = models.TextField(null=True, blank=True) + message_already_answered = models.TextField(null=True, blank=True) + text_answer = models.CharField(max_length=100, null=True, blank=True) + text_solution = models.CharField(max_length=100, null=True, blank=True) + text_next = models.CharField(max_length=100, null=True, blank=True) + popup_completed_title = models.CharField(max_length=100, null=True, blank=True) + popup_completed_message = models.TextField(null=True, blank=True) + popup_leave_message = models.TextField(null=True, blank=True) + logo = models.CharField(max_length=256, null=False, blank=True) + active = models.BooleanField(default=False) statistic_token = models.CharField(max_length=40, null=True, default=gen_token, unique=True) def __unicode__(self): return self.title + def save(self, *args, **kwargs): + if self.active: + try: + temp = Setting.objects.get(active=True) + if self != temp: + temp.active = False + temp.save() + except Setting.DoesNotExist: + pass + super(Setting, self).save(*args, **kwargs) + class Question(models.Model): id = models.AutoField(primary_key=True) @@ -52,6 +66,7 @@ class User(models.Model): token = models.CharField(max_length=40, null=True, default=gen_token, unique=True) name = models.CharField(max_length=100, null=False) last_seen = models.DateTimeField(null=True, blank=True) + completed_message_shown = models.BooleanField(null=False, default=False) def __unicode__(self): return self.name diff --git a/tkupek_elearning/elearning/static/js/elearning.js b/tkupek_elearning/elearning/static/js/elearning.js index 1d92732..346dabe 100644 --- a/tkupek_elearning/elearning/static/js/elearning.js +++ b/tkupek_elearning/elearning/static/js/elearning.js @@ -22,6 +22,10 @@ var QueryString = function () { }(); window.onload = init(); +//window.onbeforeunload = function() { + //var message = document.getElementById("popup-leave-message").innerHTML; + //return message; + //} function init() { enable_disable_question(); @@ -45,7 +49,6 @@ function enable_disable_question() { } } - function toggle_solution(id) { var element = document.getElementById("explanation_" + id); @@ -137,8 +140,13 @@ function getCheckboxAnswers(id) { function parseResponse(id, responseText) { - var correctOptions = JSON.parse(responseText).options_id; - var progress = JSON.parse(responseText).progress; + var parse = JSON.parse(responseText); + var correctOptions = parse.options_id; + var progress = parse.progress; + + if(parse.show_completed) { + $('#completed-modal').modal('show'); + } setCorrectOptions(correctOptions, id) setProgress(progress) @@ -176,6 +184,7 @@ function setCorrectOptions(correctOptions, id) { function setProgress(progress) { progressbar = document.getElementById("progressbar"); progressbar.style.width = progress + "%"; + progressbar.innerHTML = progress + "%"; } function ajaxRequest() { @@ -196,4 +205,3 @@ function ajaxRequest() { else return false } - diff --git a/tkupek_elearning/elearning/templates/elearning.html b/tkupek_elearning/elearning/templates/elearning.html index 7ca0743..4b2d4b4 100644 --- a/tkupek_elearning/elearning/templates/elearning.html +++ b/tkupek_elearning/elearning/templates/elearning.html @@ -11,22 +11,50 @@
{{ settings.message_welcome_user|safe }}