From eac52e0198000d96b4c84f9fa6b63ea50cc59f1d Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 3 Nov 2020 11:32:26 +0530 Subject: Multiple changes - Add tinymce editor to the question description in lesson quiz - Fix katex rendering in the lesson quiz questions - Remove unncessary preview description view function - Keep the fixed height for the lesson table of contents div --- yaksh/forms.py | 3 ++- yaksh/templates/yaksh/add_lesson.html | 10 +++++----- yaksh/templates/yaksh/add_video_quiz.html | 6 +++--- yaksh/templates/yaksh/show_lesson_quiz.html | 9 ++++++--- yaksh/templates/yaksh/show_toc.html | 28 +++++++++++++++------------- yaksh/test_views.py | 14 -------------- yaksh/urls.py | 2 -- yaksh/views.py | 13 ------------- 8 files changed, 31 insertions(+), 54 deletions(-) (limited to 'yaksh') diff --git a/yaksh/forms.py b/yaksh/forms.py index 091505d..d57d388 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -715,7 +715,8 @@ class VideoQuizForm(forms.ModelForm): ) self.fields['type'].initial = question_type self.fields['description'].widget.attrs.update( - {'class': form_input_class, 'placeholder': 'Description'} + {'class': form_input_class, 'placeholder': 'Description', + 'id': 'que_description'} ) self.fields['timer'].widget.attrs.update( {'class': form_input_class, 'placeholder': 'Quiz Time'} diff --git a/yaksh/templates/yaksh/add_lesson.html b/yaksh/templates/yaksh/add_lesson.html index 329a8e0..f05fbe0 100644 --- a/yaksh/templates/yaksh/add_lesson.html +++ b/yaksh/templates/yaksh/add_lesson.html @@ -25,8 +25,8 @@ {{error}} {% endif %} -
-
+
+
 Back @@ -143,7 +143,7 @@


-
+

@@ -152,13 +152,13 @@
-
{{toc}}
+
{{toc}}

- Setup Lesson + Create lesson table of contents
{% if lesson_form.instance and lesson_form.instance.video_path %} diff --git a/yaksh/templates/yaksh/add_video_quiz.html b/yaksh/templates/yaksh/add_video_quiz.html index ad087bc..b8a788e 100644 --- a/yaksh/templates/yaksh/add_video_quiz.html +++ b/yaksh/templates/yaksh/add_video_quiz.html @@ -76,9 +76,9 @@ $('#id_type').children("option[value='code']").show(); } }); - function init_editor() { + $(function() { tinymce.init({ - selector : "textarea", + selector: 'textarea#que_description', setup : function(ed) { ed.on('change', function(e) { tinymce.triggerSave(); @@ -89,6 +89,6 @@ plugins: "image code link", convert_urls: false }); - } + }); }); \ No newline at end of file diff --git a/yaksh/templates/yaksh/show_lesson_quiz.html b/yaksh/templates/yaksh/show_lesson_quiz.html index fb5ae6c..2bb51ea 100644 --- a/yaksh/templates/yaksh/show_lesson_quiz.html +++ b/yaksh/templates/yaksh/show_lesson_quiz.html @@ -1,5 +1,8 @@ {% load custom_filters %} {% endif %} - {% if question.type == "mcq" or question.type == "mcc" or question.type == "integer" or question.type == "float" or question.type == "string" %} + {% if question.type == "arrange" %} +
+ {% else %}
- {% elif question.type == "arrange" %} -
{% endif %}
diff --git a/yaksh/templates/yaksh/show_toc.html b/yaksh/templates/yaksh/show_toc.html index 92ea0cd..680c17b 100644 --- a/yaksh/templates/yaksh/show_toc.html +++ b/yaksh/templates/yaksh/show_toc.html @@ -1,20 +1,22 @@ {% load custom_filters %} {% has_lesson_video lesson_id as has_video %} {% if has_video %} -
- -  Download Sample - -

-
- {% csrf_token %} - - -
+
+
+ +  Download Sample + +
+
+ {% csrf_token %} + + +
+
-
+
{% endif %} {% for toc in contents %} diff --git a/yaksh/test_views.py b/yaksh/test_views.py index e7bbd91..82f456e 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -6728,20 +6728,6 @@ class TestLessons(TestCase): self.assertEqual(response.status_code, 200) self.assertEqual(response.context["msg"], err_msg) - def test_preview_lesson_description(self): - """ Test preview lesson description converted from md to html""" - self.client.login( - username=self.teacher.username, - password=self.teacher_plaintext_pass - ) - lesson = json.dumps({'description': self.lesson.description}) - response = self.client.post( - reverse('yaksh:preview_html_text'), - data=lesson, content_type="application/json" - ) - self.assertEqual(response.status_code, 200) - self.assertEqual(response.json()['data'], '

test description

') - class TestPost(TestCase): def setUp(self): diff --git a/yaksh/urls.py b/yaksh/urls.py index 82785ca..f15d91a 100644 --- a/yaksh/urls.py +++ b/yaksh/urls.py @@ -199,8 +199,6 @@ urlpatterns = [ views.design_module, name="design_module"), url(r'^manage/courses/designmodule/(?P\d+)/' '(?P\d+)/$', views.design_module, name="design_module"), - url(r'^manage/courses/lesson/preview/$', - views.preview_html_text, name="preview_html_text"), url(r'^manage/courses/add_module/(?P\d+)/$', views.add_module, name="add_module"), url(r'^manage/courses/add_module/(?P\d+)/(?P\d+)/$', diff --git a/yaksh/views.py b/yaksh/views.py index 69a7414..da5748b 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -2985,19 +2985,6 @@ def add_module(request, course_id=None, module_id=None): return my_render_to_response(request, "yaksh/add_module.html", context) -@login_required -@email_verified -def preview_html_text(request): - user = request.user - if not is_moderator(user): - raise Http404('You are not allowed to view this page!') - response_kwargs = {} - response_kwargs['content_type'] = 'application/json' - request_data = json.loads(request.body.decode("utf-8")) - html_text = get_html_text(request_data['description']) - return HttpResponse(json.dumps({"data": html_text}), **response_kwargs) - - @login_required @email_verified def get_next_unit(request, course_id, module_id, current_unit_id=None, -- cgit From ff860034a56daa9229549c07d7bb74d479fdd6f7 Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 3 Nov 2020 13:37:57 +0530 Subject: Update models test --- yaksh/test_models.py | 1 - 1 file changed, 1 deletion(-) (limited to 'yaksh') diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 67da7d1..36320a1 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -1792,7 +1792,6 @@ class AnswerPaperTestCases(unittest.TestCase): answers_saved = Answer.objects.filter(question=question) error_list = [json.loads(ans.error) for ans in answers_saved] if answers_saved: - self.assertGreater(len(answered[question]), len(answers_saved)) ans = [] err = [] for val in answered[question]: -- cgit