Commit 14d5a37370d3b638233fc1f6bf3d5224ffa0a7cd

Authored by Jailson Dias
1 parent c6fdd0d7

templates de exame #171

amadeus/settings.py
... ... @@ -54,6 +54,7 @@ INSTALLED_APPS = [
54 54 'app',
55 55 'courses',
56 56 'forum',
  57 + 'exam',
57 58 'poll',
58 59 'links',
59 60 'files',
... ...
courses/urls.py
... ... @@ -27,7 +27,7 @@ urlpatterns = [
27 27 url(r'^subjects/categories$',views.IndexSubjectCategoryView.as_view(), name='subject_category_index'),
28 28 url(r'^forum/', include('forum.urls', namespace = 'forum')),
29 29 url(r'^poll/', include('poll.urls', namespace = 'poll')),
30   - # url(r'^exam/', include('exam.urls', namespace = 'exam')),
  30 + url(r'^exam/', include('exam.urls', namespace = 'exam')),
31 31 url(r'^files/', include('files.urls', namespace = 'file')),
32 32 url(r'^upload-material/$', views.UploadMaterialView.as_view(), name='upload_material'),
33 33 url(r'^links/',include('links.urls',namespace = 'links')),
... ...
exam/templates/exam/create.html
... ... @@ -0,0 +1,116 @@
  1 +{% extends "base.html" %}
  2 +
  3 +{% load i18n %}
  4 +
  5 +{% block content %}
  6 +<div class="panel panel-info">
  7 + <div class="panel-heading">
  8 + {% block title_poll %}
  9 + <h1 class="panel-title">{% trans "New Exam" %}</h1>
  10 + {% endblock title_poll %}
  11 + </div>
  12 + <div class="panel-body">
  13 + <div class="row form-group">
  14 + <label for="exam_name" class="col-md-2 control-label">{% trans "Exam Name" %}</label>
  15 + <div class="col-md-10">
  16 + <input type="text" name="exam_name" class="form-control" id="exam_name" placeholder="{% trans 'Exam Name' %}">
  17 + </div>
  18 + </div>
  19 + <div class="row form-group">
  20 + <label for="begin_date" class="col-md-2 control-label">{% trans "Exam's begin date" %}</label>
  21 + <div class="col-md-10">
  22 + <input type="date" name="begin_date" class="form-control" id="begin_date" placeholder='{% trans "Begin Date" %}'>
  23 + </div>
  24 + </div>
  25 + <div class="row form-group">
  26 + <label for="end_date" class="col-md-2 control-label">{% trans "Exam's end date" %}</label>
  27 + <div class="col-md-10">
  28 + <input type="text" name="end_date" class="form-control" id="end_date" placeholder='{% trans "End Date" %}'>
  29 + </div>
  30 + </div>
  31 + <div class="row form-group">
  32 + <div class="col-md-10">
  33 + <div class="checkbox">
  34 + <label>
  35 + <input type="checkbox" name="checkbox"><span class="checkbox-material"><span class="check"></span></span> {% trans "Allow submissions after deadline?" %}
  36 + </label>
  37 + </div>
  38 + </div>
  39 + </div>
  40 + <div class="row form-group" id="questions">
  41 +
  42 + </div>
  43 + <div class="row form-group">
  44 + <label for="questionType" class="col-md-2 control-label">{% trans "Question Type" %}</label>
  45 + <div class="col-md-10">
  46 + <select id="questionType" class="form-control" name="option_question" onchange="showDiv (this)">
  47 + <option selected disabled>{% trans "Question Type" %}</option>
  48 + <option value="0">{% trans "Multiple Choice" %}</option>
  49 + <option value="1">{% trans "True or False" %}</option>
  50 + <option value="2">{% trans "Gap Filling" %}</option>
  51 + <option value="3">{% trans "Discursive Question" %}</option>
  52 + </select>
  53 + </div>
  54 + </div>
  55 + <div class="row">
  56 + <div class="col-md-12">
  57 + <button type="button" class="btn btn-primary btn-raised" id="add_question">{% trans "add question" %}</button>
  58 + </div>
  59 + </div>
  60 + </div>
  61 + <div class="panel-footer text-right">
  62 + <button type="submite" id="button" form="form" class="btn btn-primary btn-raised">{% trans "Create" %}</button>
  63 + </div>
  64 +</div>
  65 +<script>
  66 +var id = 1;
  67 +$("#add_question").click(function(){
  68 + $.get("{% url 'course:exam:true_or_false_question' %}", function(data){
  69 + // var teste = String(data);
  70 + // teste.replace("#radiosTF", "W3Schools");
  71 + // alert(teste);
  72 + $("#questions").append(data);
  73 + // $("#radiosTF").attr("id", "true_id_" + id);
  74 + $("#0").attr("id","true_" + id++);
  75 + });
  76 +});
  77 +
  78 +var alternativeValue = 3;
  79 +
  80 +$('#newAlternative').click(function () {
  81 + var element = '<div class="radio radio-primary">' +
  82 + '<label>' +
  83 + '<input type="radio" name="alternatives" id="alternative4"' + 'value="' +alternativeValue + '">' +
  84 + '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>' +
  85 + '</label>' +
  86 + '</div>';
  87 + $('#radios').append(element);
  88 +
  89 + alternativeValue++;
  90 +});
  91 +
  92 +var tfAlternativeValue = 3;
  93 +
  94 +$('#tfAlternative').click(function () {
  95 + var element = '<div class="radio radio-primary">' +
  96 + '<label>' +
  97 + '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>' +
  98 + '</label>' +
  99 + '<label>' +
  100 + '<input type="radio" name="alternative' + tfAlternativeValue +'" value="T">' +
  101 + '</label>' +
  102 + '<label>' +
  103 + '<input type="radio" name="alternative2" value="F">' +
  104 + '</label>' +
  105 + '</div>';
  106 + $('#radiosTF').append(element);
  107 +
  108 + tfAlternativeValue++;
  109 +});
  110 +
  111 +$(function() {
  112 + $( "#begin_date,#end_date" ).datepicker();
  113 +});
  114 +</script>
  115 +
  116 +{% endblock content %}
... ...
exam/templates/exam/discursive_question.html 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<div class="form-group" id="discursiveQuestion">
  2 + <label for="question" class="col-md-2 control-label">{% trans "Question" %}</label>
  3 + <div class="col-md-10">
  4 + <textarea class="form-control" rows="1" id="question" placeholder="{% trans 'Question' %}"></textarea>
  5 + </div>
  6 +</div>
... ...
exam/templates/exam/gap_filling_answer.html 0 → 100644
exam/templates/exam/gap_filling_question.html 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +<div class="form-group" id="gapFilling" style="display: none;">
  2 + <p>Gap Filling Question</p>
  3 +</div>
... ...
exam/templates/exam/multiple_choice_answer.html 0 → 100644
exam/templates/exam/multiple_choice_question.html 0 → 100644
... ... @@ -0,0 +1,40 @@
  1 +<div class="form-group" id="multipleChoice">
  2 +
  3 + <label for="questionName" class="col-md-2 control-label">Question</label>
  4 +
  5 +
  6 + <div class="col-md-10">
  7 + <textarea class="form-control" rows="1" id="questionName" placeholder="Wording"></textarea>
  8 + </div>
  9 +
  10 +
  11 +</div>
  12 +<div class="form-group">
  13 + <label for="alternative" class="col-md-2 control-label">Alternatives</label>
  14 + <div class="col-md-10" id="radios">
  15 + <div class="radio radio-primary">
  16 + <label>
  17 + <input checked type="radio" name="alternatives" id="alternative1" value="1">
  18 + <textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>
  19 + </label>
  20 + </div>
  21 + <div class="radio radio-primary">
  22 + <label>
  23 + <input type="radio" name="alternatives" id="alternative2" value="2">
  24 + <textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>
  25 + </label>
  26 + </div>
  27 + </div>
  28 +</div>
  29 +<!-- new alternative button -->
  30 +<div class="form-group">
  31 + <div class="col-md-12 col-md-offset-2">
  32 + <button type="button" class="btn btn-primary" id="newAlternative">New Alternative</button>
  33 + </div>
  34 +</div>
  35 +<div class="form-group">
  36 + <div class="col-md-12 col-md-offset-2">
  37 + <button type="submit" class="btn btn-primary">Save</button>
  38 + <button type="cancel" class="btn btn-default">Cancel</button>
  39 + </div>
  40 +</div>
... ...
exam/templates/exam/true_or_false_answer.html 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +{% load i18n %}
  2 +
  3 +<div class="row form-group" >
  4 + <div class="col-md-1">
  5 + </br>
  6 + <label><span class="glyphicon glyphicon-move"></span></label>
  7 + </div>
  8 + <div class="col-md-10">
  9 + <input class="form-control" placeholder='{% trans "Write your alternative" %}'></input>
  10 + </div>
  11 + <div class="col-md-1">
  12 + </br>
  13 + <label><span class="glyphicon glyphicon-remove" onclick="this.parentNode.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode.parentNode);"></span></label>
  14 + </div>
  15 +</div>
... ...
exam/templates/exam/true_or_false_question.html 0 → 100644
... ... @@ -0,0 +1,67 @@
  1 +{# {% extends "base.html" %} #}
  2 +
  3 +{% load i18n %}
  4 +{# {% block content %} #}
  5 +<style>
  6 + .glyphicon-remove:hover {
  7 + cursor: pointer;
  8 + }
  9 + .glyphicon-move:hover {
  10 + cursor: move;
  11 + }
  12 +</style>
  13 +<div class="" id="0">
  14 + <div class="row form-group">
  15 + <div class="col-md-1">
  16 + </br>
  17 + <label><span class="glyphicon glyphicon-move"></span></label>
  18 + </div>
  19 + <div class="col-md-2">
  20 + <label for="questionName" class="control-label">{% trans "Question" %}</label>
  21 + </div>
  22 + <div class="col-md-9">
  23 + <div class="row">
  24 + <div class="col-md-11">
  25 + <input class="form-control" id="questionName" placeholder="{% trans 'Question' %}"></input>
  26 + </div>
  27 + <div class="col-md-1">
  28 + </br>
  29 + <label><span class="glyphicon glyphicon-remove"></span></label>
  30 + </div>
  31 + </div>
  32 + </div>
  33 +
  34 + </div>
  35 + <div class="row">
  36 + <div class="col-md-offset-1 col-md-2">
  37 + <label class="control-label">{% trans "Alternatives: T/F" %}</label>
  38 + </div>
  39 + <div class="col-md-9" id="radiosTF">
  40 + {% include "exam/true_or_false_answer.html" %}
  41 + </div>
  42 + </div>
  43 + <div class="form-group">
  44 + <div class="col-md-9 col-md-offset-3">
  45 + <button type="button" class="btn btn-primary btn-raised" id="new_alternative">{% trans "New Alternative" %}</button>
  46 + </div>
  47 + </div>
  48 +</div>
  49 +<script type="text/javascript">
  50 + $("#new_alternative").click(function(){
  51 + $.get("{% url 'course:exam:true_or_false_answer' %}", function(data){
  52 + $("#radiosTF").append(data);
  53 + });
  54 + });
  55 + //deve ser importado apenas depois do html
  56 + $( "#radiosTF" ).sortable({ // utilizado para fazer a re-organização das respostas
  57 + delay: 100,
  58 + distance: 5,
  59 + update: function( event, ui ) {
  60 + var cont = 1;
  61 + $("#radiosTF div div input").each(function(){
  62 + $(this).attr('name',cont++);
  63 + });
  64 + },
  65 + });
  66 +</script>
  67 +{# {% endblock content %} #}
... ...
exam/urls.py
1   -# from django.conf.urls import url
2   -#
3   -# from . import views
4   -#
5   -# urlpatterns = [
6   -# url(r'^create/(?P<slug>[\w\-_]+)/$', views.CreateExam.as_view(), name='create_exam'), # exam slug
7   -# url(r'^update/(?P<slug>[\w\-_]+)/$', views.UpdateExam.as_view(), name='update_exam'), # topic slug
8   -# url(r'^view/(?P<slug>[\w\-_]+)/$', views.ViewExam.as_view(), name='view_exam'), # exam slug
9   -# url(r'^delete/(?P<slug>[\w\-_]+)/$', views.DeleteExam.as_view(), name='delete_exam'), # exam
10   -# url(r'^answer/$', views.AnswerExam.as_view(), name='answer_exam'), # exam
11   -# url(r'^answer-exam/(?P<slug>[\w\-_]+)/$', views.AnswerStudentExam.as_view(), name='answer_student_exam'), # exam slug
12   -# ]
  1 +from django.conf.urls import url
  2 +
  3 +from . import views
  4 +
  5 +urlpatterns = [
  6 + url(r'^create/(?P<slug>[\w\-_]+)/$', views.CreateExam.as_view(), name='create_exam'), # exam slug
  7 + url(r'^update/(?P<slug>[\w\-_]+)/$', views.UpdateExam.as_view(), name='update_exam'), # topic slug
  8 + url(r'^view/(?P<slug>[\w\-_]+)/$', views.ViewExam.as_view(), name='view_exam'), # exam slug
  9 + url(r'^delete/(?P<slug>[\w\-_]+)/$', views.DeleteExam.as_view(), name='delete_exam'), # exam
  10 + url(r'^answer/$', views.AnswerExam.as_view(), name='answer_exam'), # exam
  11 + url(r'^answer-exam/(?P<slug>[\w\-_]+)/$', views.AnswerStudentExam.as_view(), name='answer_student_exam'), # exam slug
  12 +
  13 +
  14 + url(r'^discursive-question/$',views.DiscursiveQuestion.as_view(), name="discursive_question"),
  15 + url(r'^gap-filling-question/$',views.GapFillingQuestion.as_view(), name="gap_filling_question"),
  16 + url(r'^gap-filling-answer/$',views.GapFillingAnswer.as_view(), name="gap_filling_answer"),
  17 + url(r'^multiple-choice-question/$',views.MultipleChoiceQuestion.as_view(), name="multiple_choice_question"),
  18 + url(r'^multiple-choice-answer/$',views.MultipleChoiceAnswer.as_view(), name="multiple_choice_answer"),
  19 + url(r'^true-or-false-question/$',views.TrueOrFalseQuestion.as_view(), name="true_or_false_question"),
  20 + url(r'^true-or-false-answer/$',views.TrueOrFalseAnswer.as_view(), name="true_or_false_answer"),
  21 +]
... ...
exam/views.py
... ... @@ -24,7 +24,7 @@ class ViewExam(LoginRequiredMixin,generic.DetailView):
24 24 template_name = 'exam/view.html'
25 25  
26 26 def get_object(self, queryset=None):
27   - return get_object_or_404(Exam, slug = self.kwargs.get('slug'))
  27 + return get_object_or_404(Topic, slug = self.kwargs.get('slug'))
28 28  
29 29 def get_context_data(self, **kwargs):
30 30 context = super(ViewExam, self).get_context_data(**kwargs)
... ... @@ -227,3 +227,29 @@ class AnswerStudentExam(LoginRequiredMixin,generic.CreateView):
227 227 context['keys'] = keys
228 228  
229 229 return context
  230 +
  231 +class MultipleChoiceQuestion(generic.TemplateView):
  232 + template_name = 'exam/multiple_choice_question.html'
  233 +
  234 +
  235 +class MultipleChoiceAnswer(generic.TemplateView):
  236 + template_name = 'exam/multiple_choice_answer.html'
  237 +
  238 +
  239 +class DiscursiveQuestion(generic.TemplateView):
  240 + template_name = 'exam/discursive_question.html'
  241 +
  242 +
  243 +class TrueOrFalseQuestion(generic.TemplateView):
  244 + template_name = 'exam/true_or_false_question.html'
  245 +
  246 +
  247 +class TrueOrFalseAnswer(generic.TemplateView):
  248 + template_name = 'exam/true_or_false_answer.html'
  249 +
  250 +
  251 +class GapFillingQuestion(generic.TemplateView):
  252 + template_name = 'exam/gap_filling_question.html'
  253 +
  254 +class GapFillingAnswer(generic.TemplateView):
  255 + template_name = 'exam/gap_filling_answer.html'
... ...