From 4c0de3c98d6f266d1984a86caf4ecf3d2b3f7894 Mon Sep 17 00:00:00 2001 From: juliotoscano Date: Wed, 23 Nov 2016 09:40:14 -0300 Subject: [PATCH] modifying modal-exam for panel-exam #362 --- courses/templates/subject/create.html | 2 +- courses/templates/subject/form_view_teacher.html | 2 +- exam/static/js/Exam.js | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ exam/static/js/modalExam.js | 147 --------------------------------------------------------------------------------------------------------------------------------------------------- exam/templates/exam/create.html | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------- 5 files changed, 199 insertions(+), 218 deletions(-) create mode 100644 exam/static/js/Exam.js delete mode 100644 exam/static/js/modalExam.js diff --git a/courses/templates/subject/create.html b/courses/templates/subject/create.html index 6b4e9b8..a854739 100644 --- a/courses/templates/subject/create.html +++ b/courses/templates/subject/create.html @@ -4,7 +4,7 @@ {% block breadcrumbs %} {{ block.super }} - {% breadcrumb 'Create subject' 'course:create_subject' %} + {% breadcrumb 'Create subject' 'course:create_subject' %} {% endblock breadcrumbs %} {% block content %} diff --git a/courses/templates/subject/form_view_teacher.html b/courses/templates/subject/form_view_teacher.html index 18544b6..b1ca3b7 100644 --- a/courses/templates/subject/form_view_teacher.html +++ b/courses/templates/subject/form_view_teacher.html @@ -103,7 +103,7 @@
  • {% trans 'Create Forum' %}
  • {% trans 'Create Poll' %}
  • {% trans 'Delivery Material' %}
  • -
  • {% trans 'Create exam' %}
  • +
  • {% trans 'Create exam' %}
  • diff --git a/exam/static/js/Exam.js b/exam/static/js/Exam.js new file mode 100644 index 0000000..96ea05b --- /dev/null +++ b/exam/static/js/Exam.js @@ -0,0 +1,146 @@ +//Insert Create select with question type + var idQuestionType = 1; + $("#addQuestion").on("click", function(event){ + var element = + '
    ' + + '' + '
    ' + + '' + + '
    ' + + '
    ' + '
    ' + ; + if (idQuestionType == 1){ + $(element).insertAfter('#buttonAddQuestion'); + }else{ + var idhr = '#hr_'+(idQuestionType-1); + $(element).insertAfter(idhr); + } + idQuestionType++; + }) + + //Insert question choice + function showDiv (elem, questionType_id) { + if (elem.value == 0) { + var questionChoice = + '
    ' + + '
    '+ + ''+ + '
    '+ + ''+ + '
    '+ + '
    '+ + '
    '+ + ''+ + '
    '+ + '
    '+ + ''+ + '
    '+ + '
    '+ + ''+ + '
    '+ + '
    '+ + '
    '+ + '
    '+ + ''+ + '
    '+ + '
    '; + } else if (elem.value == 1) { + var questionChoice = + '
    '+ + '
    '+ + ''+ + '
    '+ + ''+ + '
    '+ + '
    '+ + '
    '+ + ''+ + '
    '+ + '
    '+ + '
    '+ + ''+ + ''+ + ''+ + '
    '+ + '
    '+ + '
    '+ + ''+ + ''+ + ''+ + '
    '+ + '
    '+ + '
    '+ + '
    '+ + ''+ + '
    '+ + '
    '; + } else if (elem.value == 3) { + var questionChoice = + '
    '+ + '
    '+ + ''+ + '
    '+ + ''+ + '
    '+ + '
    '+ + '
    '; + } + if(document.getElementById('questionChoice_'+ questionType_id)){ + $('#questionChoice_'+ questionType_id).detach(); + } + $(questionChoice).insertBefore('#hr_'+questionType_id); + $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. + } +//Bug quando criamos sem ser na ordem +function functionNewAlternative(Question_Id){ + var alternative = parseInt($("div input").last().val()) + 1; + var element = '
    ' + + ''+ + '
    '; + $(Question_Id).append(element); + $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. +} +function functionNewAlternativeTF(Question_Id){ + var alternative = parseInt($("div").last().val()) + 1; + var element = + '
    '+ + ''+ + ''+ + ''+ + '
    '; + $(Question_Id).append(element); + $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. +} \ No newline at end of file diff --git a/exam/static/js/modalExam.js b/exam/static/js/modalExam.js deleted file mode 100644 index 9f5a197..0000000 --- a/exam/static/js/modalExam.js +++ /dev/null @@ -1,147 +0,0 @@ - -//Insert Create select with question type - var idQuestionType = 1; - $("#addQuestion").on("click", function(event){ - var element = - '
    ' + - '' + '
    ' + - '' + - '
    ' + - '
    ' + '
    ' - ; - if (idQuestionType == 1){ - $(element).insertAfter('#buttonAddQuestion'); - }else{ - var idhr = '#hr_'+(idQuestionType-1); - $(element).insertAfter(idhr); - } - idQuestionType++; - }) - - //Insert question choice - function showDiv (elem, questionType_id) { - if (elem.value == 0) { - var questionChoice = - '
    ' + - '
    '+ - ''+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '; - } else if (elem.value == 1) { - var questionChoice = - '
    '+ - '
    '+ - ''+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+ - ''+ - ''+ - ''+ - '
    '+ - '
    '+ - '
    '+ - ''+ - ''+ - ''+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '; - } else if (elem.value == 3) { - var questionChoice = - '
    '+ - '
    '+ - ''+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '; - } - if(document.getElementById('questionChoice_'+ questionType_id)){ - $('#questionChoice_'+ questionType_id).detach(); - } - $(questionChoice).insertBefore('#hr_'+questionType_id); - $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. - } -//Bug quando criamos sem ser na ordem -function functionNewAlternative(Question_Id){ - var alternative = parseInt($("div input").last().val()) + 1; - var element = '
    ' + - ''+ - '
    '; - $(Question_Id).append(element); - $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. -} -function functionNewAlternativeTF(Question_Id){ - var alternative = parseInt($("div").last().val()) + 1; - var element = - '
    '+ - ''+ - ''+ - ''+ - '
    '; - $(Question_Id).append(element); - $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. -} \ No newline at end of file diff --git a/exam/templates/exam/create.html b/exam/templates/exam/create.html index 703e996..f999106 100644 --- a/exam/templates/exam/create.html +++ b/exam/templates/exam/create.html @@ -1,80 +1,62 @@ +{% extends 'subject/index.html' %} -{% load i18n widget_tweaks dict_access static%} +{% load i18n widget_tweaks static django_bootstrap_breadcrumbs %} -{# {% block style %} #} - - - - -{# {% endblock %} #} +{% block breadcrumbs %} + {{ block.super }} + {% breadcrumb 'Create exam' 'course:create_exam' %} +{% endblock breadcrumbs %} {% block content %} - -