diff options
author | Palaparthy Adityachandra | 2020-11-03 17:20:23 +0530 |
---|---|---|
committer | GitHub | 2020-11-03 17:20:23 +0530 |
commit | 81f96a24954d375ab32ab8dfb1ee8aba299655c6 (patch) | |
tree | add26043d9c69cf50553b5eb45e8744618a4b607 /yaksh | |
parent | 602f88e334865c995d86a457acdca6cc43b354ef (diff) | |
parent | 81f04f1382b1416480ed0bf0e4018afcce4cfef4 (diff) | |
download | online_test-81f96a24954d375ab32ab8dfb1ee8aba299655c6.tar.gz online_test-81f96a24954d375ab32ab8dfb1ee8aba299655c6.tar.bz2 online_test-81f96a24954d375ab32ab8dfb1ee8aba299655c6.zip |
Merge pull request #785 from adityacp/multiple_ui_fixes
Multiple UI changes
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/forms.py | 3 | ||||
-rw-r--r-- | yaksh/static/yaksh/js/lesson.js | 11 | ||||
-rw-r--r-- | yaksh/templates/base.html | 13 | ||||
-rw-r--r-- | yaksh/templates/yaksh/add_lesson.html | 10 | ||||
-rw-r--r-- | yaksh/templates/yaksh/add_video_quiz.html | 6 | ||||
-rw-r--r-- | yaksh/templates/yaksh/show_lesson_quiz.html | 17 | ||||
-rw-r--r-- | yaksh/templates/yaksh/show_toc.html | 28 | ||||
-rw-r--r-- | yaksh/templates/yaksh/show_video.html | 2 | ||||
-rw-r--r-- | yaksh/test_models.py | 15 | ||||
-rw-r--r-- | yaksh/test_views.py | 14 | ||||
-rw-r--r-- | yaksh/urls.py | 2 | ||||
-rw-r--r-- | yaksh/views.py | 13 |
12 files changed, 61 insertions, 73 deletions
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/static/yaksh/js/lesson.js b/yaksh/static/yaksh/js/lesson.js index 2cc2e62..586ae18 100644 --- a/yaksh/static/yaksh/js/lesson.js +++ b/yaksh/static/yaksh/js/lesson.js @@ -1,13 +1,20 @@ $(document).ready(function() { - MathJax.Hub.Queue(["Typeset", MathJax.Hub]); var simplemde = new SimpleMDE({ element: document.getElementById("id_description"), forceSync: true, hideIcons: ["preview", "side-by-side", "fullscreen"] }); simplemde.codemirror.on("change", function() { - MathJax.Hub.Queue(["Typeset", MathJax.Hub]); $("#description_body").html(simplemde.markdown(simplemde.value())); + renderMathInElement( + document.body, + { + delimiters: [ + {left: "$$", right: "$$", display: false}, + {left: "$", right: "$", display: true}, + ] + } + ); }); const player = new Plyr('#player'); var timer = $("#vtimer"); diff --git a/yaksh/templates/base.html b/yaksh/templates/base.html index 2cc607c..4fa12c7 100644 --- a/yaksh/templates/base.html +++ b/yaksh/templates/base.html @@ -52,12 +52,21 @@ <script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script> <!-- To automatically render math in text elements, include the auto-render extension: --> - <script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous" - onload="renderMathInElement(document.body);"></script> + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous"> + </script> <script> new WOW().init(); $(document).ready(function() { + renderMathInElement( + document.body, + { + delimiters: [ + {left: "$$", right: "$$", display: false}, + {left: "$", right: "$", display: true}, + ] + } + ); $(".alert").delay(2000).slideUp(200, function() { $(this).alert('close'); }); 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}} </div> {% endif %} - <div class="row justify-content-center form-group"> - <div class="col-md-5 col-md-offset-4"> + <div class="row"> + <div class="col-md-6"> <a class="btn btn-primary" href="{% url 'yaksh:get_course_modules' course_id %}"> <i class="fa fa-arrow-left"></i> Back </a> @@ -143,7 +143,7 @@ </form> </div> <br><br> - <div class="col-md-5"> + <div class="col-md-6"> <br> <div class="card"> <div class="card-header"> @@ -152,13 +152,13 @@ </a> </div> <div class="collapse show" id="toc-collapse"> - <div class="card-body" id="toc">{{toc}}</div> + <div class="card-body" id="toc" style="max-height: 400px; overflow-y: auto;">{{toc}}</div> </div> </div> <br> <div class="card" id="preview_text_div"> <div class="card-header"> - Setup Lesson + Create lesson table of contents </div> <div class="card-body"> {% 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 }); - } + }); }); </script>
\ 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..82e01bc 100644 --- a/yaksh/templates/yaksh/show_lesson_quiz.html +++ b/yaksh/templates/yaksh/show_lesson_quiz.html @@ -1,5 +1,16 @@ {% load custom_filters %} <script type="text/javascript"> + $(document).ready(function() { + renderMathInElement( + document.body, + { + delimiters: [ + {left: "$$", right: "$$", display: false}, + {left: "$", right: "$", display: true}, + ] + } + ); + }); function user_arranged_options() { var temp_array = [] var add_array = document.getElementById("arrange_order"); @@ -120,11 +131,11 @@ var order_array = $(arrange).sortable(['serialize']); </script> {% 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" %} + <br><button class="btn btn-success" type="submit" name="check" id="check" onClick="return user_arranged_options();">Submit</button> + {% else %} <br><button class="btn btn-success" type="submit" name="check" id="check">Submit </button> - {% elif question.type == "arrange" %} - <br><button class="btn btn-success" type="submit" name="check" id="check" onClick="return user_arranged_options();">Submit</button> {% endif %} </div> </div> 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 %} - <div> - <a href="{% url 'yaksh:download_sample_toc' %}"> - <i class="fa fa-download"></i> Download Sample - </a> - <br><br> - <form action="" method="POST" enctype="multipart/form-data"> - {% csrf_token %} - <input type="file" name="toc" required=""> - <button class="btn btn-outline-success" id="upload_toc" name="upload_toc"> - <i class="fa fa-upload"></i> Upload TOC - </button> - </form> + <div class="card"> + <div class="card-body"> + <a href="{% url 'yaksh:download_sample_toc' %}"> + <i class="fa fa-download"></i> Download Sample + </a> + <hr> + <form action="" method="POST" enctype="multipart/form-data"> + {% csrf_token %} + <input type="file" name="toc" required=""> + <button class="btn btn-outline-success" id="upload_toc" name="upload_toc"> + <i class="fa fa-upload"></i> Upload TOC + </button> + </form> + </div> </div> - <hr> + <br> {% endif %} <table class="table table-responsive-sm"> {% for toc in contents %} diff --git a/yaksh/templates/yaksh/show_video.html b/yaksh/templates/yaksh/show_video.html index 6e3cabb..627773d 100644 --- a/yaksh/templates/yaksh/show_video.html +++ b/yaksh/templates/yaksh/show_video.html @@ -163,7 +163,7 @@ </a> </div> <div class="collapse show" id="toc-collapse"> - <div class="card-body" id="toc"> + <div class="card-body" id="toc" style="max-height: 400px; overflow-y: auto;"> <table class="table table-responsive"> {% for content in toc %} {% with content.get_toc_text as toc_name %} diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 67da7d1..fe0d3b5 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -1788,20 +1788,7 @@ class AnswerPaperTestCases(unittest.TestCase): """ Test get_question_answer() method of Answer Paper""" questions = self.answerpaper.questions.all() answered = self.answerpaper.get_question_answers() - for question in questions: - 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]: - if val.get('answer') is not None: - ans.append(val.get('answer')) - if val.get('error_list') is not None: - err.append(val.get('error_list')) - self.assertEqual(set(ans), set(answers_saved)) - self.assertEqual(error_list, err) + self.assertEqual(list(questions), list(answered.keys())) def test_is_answer_correct(self): self.assertTrue(self.answerpaper.is_answer_correct(self.questions[0])) 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'], '<p>test description</p>') - 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<module_id>\d+)/' '(?P<course_id>\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<course_id>\d+)/$', views.add_module, name="add_module"), url(r'^manage/courses/add_module/(?P<course_id>\d+)/(?P<module_id>\d+)/$', diff --git a/yaksh/views.py b/yaksh/views.py index 69a7414..da5748b 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -2987,19 +2987,6 @@ def add_module(request, course_id=None, module_id=None): @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, first_unit=None): user = request.user |