summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grades/templates/add_grades.html5
-rw-r--r--yaksh/forms.py31
-rw-r--r--yaksh/management/commands/create_moderator.py5
-rw-r--r--yaksh/models.py2
-rw-r--r--yaksh/static/yaksh/js/add_course.js16
-rw-r--r--yaksh/static/yaksh/js/add_grades.js14
-rw-r--r--yaksh/static/yaksh/js/add_question.js7
-rw-r--r--yaksh/static/yaksh/js/add_quiz.js13
-rw-r--r--yaksh/static/yaksh/js/lesson.js19
-rw-r--r--yaksh/templates/yaksh/add_course.html2
-rw-r--r--yaksh/templates/yaksh/add_lesson.html17
-rw-r--r--yaksh/templates/yaksh/add_module.html4
-rw-r--r--yaksh/templates/yaksh/add_quiz.html1
-rw-r--r--yaksh/templates/yaksh/user_status.html75
14 files changed, 173 insertions, 38 deletions
diff --git a/grades/templates/add_grades.html b/grades/templates/add_grades.html
index 198eb4b..c7006a9 100644
--- a/grades/templates/add_grades.html
+++ b/grades/templates/add_grades.html
@@ -1,7 +1,12 @@
{% extends "manage.html" %}
+{% load static %}
{% load custom_filters %}
{% block title %} Add/Edit Grading {% endblock %}
{% block pagetitle %} Add/Edit Grading {% endblock %}
+{% block script %}
+ <script type="text/javascript" src="{% static 'yaksh/js/tinymce/js/tinymce/tinymce.min.js' %}"></script>
+ <script type="text/javascript" src="{% static 'yaksh/js/add_grades.js' %}"></script>
+{% endblock %}
{% block main %}
<html>
<div class="row">
diff --git a/yaksh/forms.py b/yaksh/forms.py
index d57d388..7a9eb87 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -515,6 +515,22 @@ class QuestionPaperForm(forms.ModelForm):
class LessonForm(forms.ModelForm):
+ video_options = (
+ ("---", "Select Video Option"), ("youtube", "Youtube"),
+ ("vimeo", "Vimeo"), ("others", "Others")
+ )
+ video_option = forms.ChoiceField(
+ choices=video_options, required=False,
+ help_text='Add videos from youtube, vimeo or other',
+ widget=forms.Select({'class': 'custom-select'}))
+ video_url = forms.CharField(
+ widget=forms.TextInput(
+ {'class': form_input_class,
+ 'placeholder': 'Video ID for Youtube, Vimeo and URL for others'}
+ ),
+ required=False
+ )
+
def __init__(self, *args, **kwargs):
super(LessonForm, self).__init__(*args, **kwargs)
des_msg = "Enter Lesson Description as Markdown text"
@@ -524,13 +540,14 @@ class LessonForm(forms.ModelForm):
self.fields['description'].widget.attrs.update(
{'class': form_input_class, 'placeholder': des_msg}
)
- self.fields['video_path'].widget.attrs.update(
- {'class': form_input_class,
- 'placeholder': dedent("""\
- {'youtube': '', 'vimeo': '', 'others': ''}
- """),
- }
- )
+ self.fields['video_path'].widget = forms.HiddenInput()
+ try:
+ video = literal_eval(self.instance.video_path)
+ key = list(video.keys())[0]
+ self.fields['video_option'].initial = key
+ self.fields['video_url'].initial = video[key]
+ except ValueError:
+ pass
class Meta:
model = Lesson
diff --git a/yaksh/management/commands/create_moderator.py b/yaksh/management/commands/create_moderator.py
index 3ec012e..c0f160a 100644
--- a/yaksh/management/commands/create_moderator.py
+++ b/yaksh/management/commands/create_moderator.py
@@ -10,6 +10,7 @@ from django.contrib.auth.models import User, Group, Permission
# local imports
from yaksh.models import create_group
+from yaksh.views import _create_or_update_profile
class Command(BaseCommand):
@@ -43,6 +44,10 @@ class Command(BaseCommand):
)
)
else:
+ if not hasattr(user, 'profile'):
+ _create_or_update_profile(user,
+ {'is_email_verified': True}
+ )
user.profile.is_moderator = True
user.profile.save()
self.stdout.write(
diff --git a/yaksh/models.py b/yaksh/models.py
index e2b9952..50e9363 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1331,7 +1331,7 @@ class Profile(models.Model):
super(Profile, self).save(*args, **kwargs)
def __str__(self):
- return '%s' % (self.user.get_full_name())
+ return '%s' % (self.user.get_full_name() or self.user.username)
###############################################################################
diff --git a/yaksh/static/yaksh/js/add_course.js b/yaksh/static/yaksh/js/add_course.js
new file mode 100644
index 0000000..0fba2e9
--- /dev/null
+++ b/yaksh/static/yaksh/js/add_course.js
@@ -0,0 +1,16 @@
+$(document).ready(function () {
+ $(function() {
+ tinymce.init({
+ selector: 'textarea#id_instructions',
+ setup : function(ed) {
+ ed.on('change', function(e) {
+ tinymce.triggerSave();
+ });
+ },
+ max_height: 400,
+ height: 400,
+ plugins: "image code link",
+ convert_urls: false
+ });
+ });
+});
diff --git a/yaksh/static/yaksh/js/add_grades.js b/yaksh/static/yaksh/js/add_grades.js
new file mode 100644
index 0000000..151fef1
--- /dev/null
+++ b/yaksh/static/yaksh/js/add_grades.js
@@ -0,0 +1,14 @@
+$(function() {
+ tinymce.init({
+ selector: 'textarea#id_description',
+ setup : function(ed) {
+ ed.on('change', function(e) {
+ tinymce.triggerSave();
+ });
+ },
+ max_height: 400,
+ height: 400,
+ plugins: "image code link",
+ convert_urls: false
+ });
+ });
diff --git a/yaksh/static/yaksh/js/add_question.js b/yaksh/static/yaksh/js/add_question.js
index 479e8da..d5a6121 100644
--- a/yaksh/static/yaksh/js/add_question.js
+++ b/yaksh/static/yaksh/js/add_question.js
@@ -220,11 +220,4 @@ $(document).ready(() => {
$('#id_language').children("option[value='other']").show();
}
})
- $('#add_more').click(function() {
- var form_idx = $(tc_type).val();
- $('#form_set').append($('#empty_form').html().replace(/__prefix__/g, form_idx));
- $(tc_type).val(parseInt(form_idx) + 1);
- var form_type = "#id_"+'{{tc_class}}'+"_set-"+form_idx+"-type";
- $(form_type).val($("#id_"+'{{tc_class}}'+"_set-0-type").val());
- });
}); \ No newline at end of file
diff --git a/yaksh/static/yaksh/js/add_quiz.js b/yaksh/static/yaksh/js/add_quiz.js
index dab5a3d..38a9dc8 100644
--- a/yaksh/static/yaksh/js/add_quiz.js
+++ b/yaksh/static/yaksh/js/add_quiz.js
@@ -1,6 +1,5 @@
function test()
{
-
document.getElementById('id_duration').setAttribute('class','mini-text form-control');
document.getElementById('id_pass_criteria').setAttribute('class','mini-text form-control');
if (document.getElementById("id_description").value != "")
@@ -13,6 +12,18 @@ function test()
document.getElementById('rendered_text').innerHTML = document.getElementById('id_instructions').value ;
});
document.getElementById('rendered_text').innerHTML = document.getElementById('id_instructions').value ;
+ tinymce.init({
+ selector: 'textarea#id_instructions',
+ setup : function(ed) {
+ ed.on('change', function(e) {
+ tinymce.triggerSave();
+ });
+ },
+ max_height: 400,
+ height: 400,
+ plugins: "image code link",
+ convert_urls: false
+ });
}
String.prototype.beginsWith = function (string) {
diff --git a/yaksh/static/yaksh/js/lesson.js b/yaksh/static/yaksh/js/lesson.js
index 64ac4da..d562197 100644
--- a/yaksh/static/yaksh/js/lesson.js
+++ b/yaksh/static/yaksh/js/lesson.js
@@ -16,6 +16,25 @@ $(document).ready(function() {
}
);
});
+ var completion_msg = "Add Youtube and Vimeo video ID, for Others add "+
+ "video file url e.g https://example.com/video.mp4"
+ $("#video_msg").attr("title", completion_msg);
+ $("#video_msg").tooltip();
+ $("#submit-lesson").click(function() {
+ var video_option = $("#id_video_option").val();
+ var video_url = $("#id_video_url").val();
+ if(video_option != "---") {
+ if(!video_url.trim()) {
+ $('#id_video_url').prop('required', true);
+ }
+ else {
+ $("#id_video_path").val("{'"+video_option+"': '"+video_url+"'}");
+ }
+ } else {
+ $('#id_video_url').prop('required', false);
+ $("#id_video_path").val(null);
+ }
+ });
const player = new Plyr('#player');
var timer = $("#vtimer");
var totalSeconds;
diff --git a/yaksh/templates/yaksh/add_course.html b/yaksh/templates/yaksh/add_course.html
index 0072a95..07ac81b 100644
--- a/yaksh/templates/yaksh/add_course.html
+++ b/yaksh/templates/yaksh/add_course.html
@@ -6,8 +6,10 @@
{% endblock %}
{% block script %}
+<script type="text/javascript" src="{% static 'yaksh/js/tinymce/js/tinymce/tinymce.min.js' %}"></script>
<script type="text/javascript" src="{% static 'yaksh/js/jquery.datetimepicker.full.min.js' %}">
</script>
+<script type="text/javascript" src="{% static 'yaksh/js/add_course.js' %}"></script>
{% endblock %}
{% block title %} Add Course {% endblock %}
{% block pagetitle %} Add Course {% endblock %}
diff --git a/yaksh/templates/yaksh/add_lesson.html b/yaksh/templates/yaksh/add_lesson.html
index 4400032..385ebe0 100644
--- a/yaksh/templates/yaksh/add_lesson.html
+++ b/yaksh/templates/yaksh/add_lesson.html
@@ -11,6 +11,7 @@
</script>
<script type="text/javascript" src="{% static 'yaksh/js/mathjax/MathJax.js' %}?config=TeX-MML-AM_CHTML">
</script>
+
{% endblock %}
{% block css %}
@@ -83,9 +84,12 @@
Active:&nbsp;{{lesson_form.active}}
<br><br>
Video Path:
- <span class="badge badge-info">
- {{lesson_form.video_path.help_text}}
- </span>
+ <a data-toggle="tooltip" id="video_msg">
+ <i class="fa fa-question-circle"></i>
+ </a>
+ {{lesson_form.video_option}}
+ <br><br>
+ {{lesson_form.video_url}}
{{lesson_form.video_path}}
<br>
Video File:
@@ -132,12 +136,13 @@
</center>
{% endif %}
<center>
- <button class="btn btn-success btn-lg" type="submit" id="submit" name="Save">
+ <button class="btn btn-success btn-lg" type="submit" id="submit-lesson" name="Save">
<i class="fa fa-save"></i>
Save
</button>
{% if lesson_files %}
- <button class="btn btn-danger btn-lg" type="submit" id="submit" name="Delete"> <i class="fa fa-trash"></i>&nbsp;Delete Files
+ <button class="btn btn-danger btn-lg" type="submit" name="Delete">
+ <i class="fa fa-trash"></i>&nbsp;Delete Files
</button>
{% endif %}
</center>
@@ -230,4 +235,4 @@
</div>
</div>
</div>
-{% endblock %} \ No newline at end of file
+{% endblock %}
diff --git a/yaksh/templates/yaksh/add_module.html b/yaksh/templates/yaksh/add_module.html
index aee50c1..9df194a 100644
--- a/yaksh/templates/yaksh/add_module.html
+++ b/yaksh/templates/yaksh/add_module.html
@@ -1,6 +1,8 @@
{% extends "manage.html" %}
{% load static %}
-{% block title %}Create/Edit Learning Module{% endblock %}
+{% block title %}
+ Create/Edit Learning Module
+{% endblock %}
{% block script %}
<script type="text/javascript" src="{% static 'yaksh/js/jquery-3.3.1.min.js' %}">
diff --git a/yaksh/templates/yaksh/add_quiz.html b/yaksh/templates/yaksh/add_quiz.html
index 9b80e0d..7918858 100644
--- a/yaksh/templates/yaksh/add_quiz.html
+++ b/yaksh/templates/yaksh/add_quiz.html
@@ -12,6 +12,7 @@
{% block script %}
<script src="{% static 'yaksh/js/jquery-3.3.1.min.js' %}"></script>
+<script type="text/javascript" src="{% static 'yaksh/js/tinymce/js/tinymce/tinymce.min.js' %}"></script>
<script src="{% static 'yaksh/js/add_quiz.js' %}"></script>
<script src="{% static 'yaksh/js/jquery.datetimepicker.full.min.js' %}"></script>
<script type="text/javascript">
diff --git a/yaksh/templates/yaksh/user_status.html b/yaksh/templates/yaksh/user_status.html
index 5f006c9..5a7cb3d 100644
--- a/yaksh/templates/yaksh/user_status.html
+++ b/yaksh/templates/yaksh/user_status.html
@@ -3,18 +3,39 @@
<br>
<strong>Overall Course Progress:</strong>
<div class="progress">
- {% if course_percentage <= 50 %}
- <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="40"
- aria-valuemin="0" aria-valuemax="100" style="width:{{course_percentage}}%">
+ {% if course_percentage == 0 %}
+ <b style="color: black;">{{course_percentage}}% Completed</b>
+ {% elif course_percentage <= 50 %}
+ <div
+ class="progress-bar progress-bar-danger"
+ role="progressbar"
+ aria-valuenow="40"
+ aria-valuemin="0"
+ aria-valuemax="100"
+ style="width:{{course_percentage}}%">
+ <b style="color: black;">{{course_percentage}}% Completed</b>
+ </div>
{% elif course_percentage <= 75 %}
- <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="40"
- aria-valuemin="0" aria-valuemax="100" style="width:{{course_percentage}}%">
+ <div
+ class="progress-bar progress-bar-warning"
+ role="progressbar"
+ aria-valuenow="40"
+ aria-valuemin="0"
+ aria-valuemax="100"
+ style="width:{{course_percentage}}%">
+ <b style="color: black;">{{course_percentage}}% Completed</b>
+ </div>
{% else %}
- <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40"
- aria-valuemin="0" aria-valuemax="100" style="width:{{course_percentage}}%">
+ <div
+ class="progress-bar progress-bar-success"
+ role="progressbar"
+ aria-valuenow="40"
+ aria-valuemin="0"
+ aria-valuemax="100"
+ style="width:{{course_percentage}}%">
+ <b style="color: black;">{{course_percentage}}% Completed</b>
+ </div>
{% endif %}
- <b style="color: black;">{{course_percentage}}% Completed</b>
- </div>
</div>
<br>
<strong>Per Module Progress:</strong>
@@ -25,15 +46,39 @@
<td width="30%">{{ module.name }}</td>
<td>
<div class="progress">
- {% if percent <= 50 %}
- <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:{{percent}}%">
+ {% if percent == 0 %}
+ <b style="color: black;">{{percent}}% Completed</b>
+ {% elif percent <= 50 %}
+ <div
+ class="progress-bar progress-bar-danger"
+ role="progressbar"
+ aria-valuenow="40"
+ aria-valuemin="0"
+ aria-valuemax="100"
+ style="width:{{percent}}%">
+ <b style="color: black;">{{percent}}% Completed</b>
+ </div>
{% elif percent <= 75 %}
- <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:{{percent}}%">
+ <div
+ class="progress-bar progress-bar-warning"
+ role="progressbar"
+ aria-valuenow="40"
+ aria-valuemin="0"
+ aria-valuemax="100"
+ style="width:{{percent}}%">
+ <b style="color: black;">{{percent}}% Completed</b>
+ </div>
{% else %}
- <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:{{percent}}%">
+ <div
+ class="progress-bar progress-bar-success"
+ role="progressbar"
+ aria-valuenow="40"
+ aria-valuemin="0"
+ aria-valuemax="100"
+ style="width:{{percent}}%">
+ <b style="color: black;">{{percent}}% Completed</b>
+ </div>
{% endif %}
- <b style="color: black;">{{percent}}% Completed</b>
- </div>
</div>
</td>
</tr>