Skip to content

Commit

Permalink
Change templates and js
Browse files Browse the repository at this point in the history
- Fix issue onlick toc jump to player time
- Use bootstrap modal instead of jquery dialog for responsive interface
- Disallow empty question submission for lesson quiz
  • Loading branch information
adityacp committed Nov 12, 2020
1 parent 11a6ffb commit 06747ca
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
11 changes: 4 additions & 7 deletions yaksh/static/yaksh/js/show_toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,8 @@ function unlock_screen() {
}

function show_question(data) {
$("#dialog").html(data);
$("#dialog").dialog({
width: 800,
height: 500,
});
$("#myModal").modal({backdrop: 'static', keyboard: false});
$("#lesson_quiz_question").html(data)
$("#submit-quiz-form").submit(function(e) {
e.preventDefault();
lock_screen();
Expand All @@ -135,7 +132,7 @@ function show_question(data) {
function select_toc(element) {
var toc_id = element.getAttribute("data-toc");
var content_type = element.getAttribute("data-toc-type");
var toc_time = $("#toc_time_"+toc_id).val();
var toc_time = $("#toc_time_"+toc_id).html().trim();
player.currentTime = get_time_in_seconds(toc_time);
if (content_type == 1) {
show_topic($("#toc_desc_"+toc_id).val(), true);
Expand Down Expand Up @@ -199,8 +196,8 @@ function ajax_call(url, method, data, csrf, screen_lock=true) {
show_question(msg.data);
}
if (msg.message) {
$("#myModal").modal('hide');
if (msg.success) {
$("#dialog").dialog("close");
show_message(msg.message, "success");
}
else {
Expand Down
1 change: 0 additions & 1 deletion yaksh/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
</script>
<script type="text/javascript" src="{% static 'yaksh/js/toastr.min.js' %}">
</script>

<!-- The loading of KaTeX is deferred to speed up page rendering -->
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script>

Expand Down
2 changes: 1 addition & 1 deletion yaksh/templates/yaksh/course_modules.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="card">
<div class="card-header">
{{ course.name }}
<a href="{% url "yaksh:course_forum" course.id %}" class="btn btn-info pull-right">Discussion Forum</a>
<a href="{% url 'yaksh:course_forum' course.id %}" class="btn btn-info pull-right">Discussion Forum</a>
</div>
<div class="card-body">
{% if course.view_grade %}
Expand Down
8 changes: 4 additions & 4 deletions yaksh/templates/yaksh/show_lesson_quiz.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h2>{{ question.summary }}</h2>
<input name="answer" type="radio" value="{{ test_case.id }}" checked />
{{ test_case.options|safe }} <br/>
{% else %}
<input name="answer" type="radio" value="{{ test_case.id }}" />
<input name="answer" type="radio" value="{{ test_case.id }}" required="" />
{{ test_case.options|safe }} <br/>
{% endif %}
{% endfor %}
Expand All @@ -80,21 +80,21 @@ <h2>{{ question.summary }}</h2>
{% if question.type == "integer" %}
<!-- Integer type Question -->
Enter Integer:<br/>
<input autofocus class="form-control" name="answer" type="number" id="integer" value="{{ last_attempt|to_integer }}" />
<input autofocus class="form-control" name="answer" type="number" id="integer" value="{{ last_attempt|to_integer }}" required=""/>
<br><br>
{% endif %}

{% if question.type == "string" %}
<!-- String type question -->
Enter Text:<br/>
<textarea autofocus name="answer" id="string" class="form-control" style="width: 100%">{{ last_attempt|to_str }}</textarea>
<textarea autofocus name="answer" id="string" class="form-control" style="width: 100%" required="">{{ last_attempt|to_str }}</textarea>
<br/><br/>
{% endif %}

{% if question.type == "float" %}
<!-- Float type question -->
Enter Decimal Value :<br/>
<input autofocus class="form-control" name="answer" type="number" step="any" id="float" value="{{ last_attempt|to_float }}" />
<input autofocus class="form-control" name="answer" type="number" step="any" id="float" value="{{ last_attempt|to_float }}" required=""/>
<br/><br/>
{% endif %}

Expand Down
9 changes: 7 additions & 2 deletions yaksh/templates/yaksh/show_video.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
<script type="text/javascript" src="{% static 'yaksh/js/show_toc.js' %}">
</script>
<script src="{% static 'yaksh/js/jquery-sortable.js' %}"></script>
<script type="text/javascript" src="{% static 'yaksh/js/mathjax/MathJax.js' %}?config=TeX-MML-AM_CHTML">
</script>
<script type="text/javascript" src="{% static 'yaksh/js/tinymce/js/tinymce/tinymce.min.js' %}"></script>
{% endblock %}
{% block css %}
Expand Down Expand Up @@ -282,5 +280,12 @@
</div>
</div>
<div id="dialog"></div>
<div class="modal" tabindex="-1" role="dialog" id="myModal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" id="lesson_quiz_question"></div>
</div>
</div>
</div>
{% endblock %}

0 comments on commit 06747ca

Please sign in to comment.