Commit a8f59598d7733762fc7db654837a89810951c2db

Authored by ailsoncgt
2 parents 3629ead9 c1bfb395

Merge ...

amadeus/settings.py
@@ -54,6 +54,7 @@ INSTALLED_APPS = [ @@ -54,6 +54,7 @@ INSTALLED_APPS = [
54 'app', 54 'app',
55 'courses', 55 'courses',
56 'forum', 56 'forum',
  57 + 'exam',
57 'poll', 58 'poll',
58 'links', 59 'links',
59 'files', 60 'files',
app/templates/home.html
@@ -31,11 +31,11 @@ @@ -31,11 +31,11 @@
31 // Configure the url we're about to hit 31 // Configure the url we're about to hit
32 setTimeout(function (){ 32 setTimeout(function (){
33 $.ajax({ 33 $.ajax({
34 - url: baseUrl, 34 + url: baseUrl,
35 data: {'page': pageNum}, 35 data: {'page': pageNum},
36 success: function(data) { 36 success: function(data) {
37 $("#loading").hide(); 37 $("#loading").hide();
38 - 38 +
39 $("#timeline").append(data); 39 $("#timeline").append(data);
40 }, 40 },
41 complete: function(data, textStatus){ 41 complete: function(data, textStatus){
@@ -46,7 +46,7 @@ @@ -46,7 +46,7 @@
46 }, 1000) 46 }, 1000)
47 }; 47 };
48 48
49 - $(document).ready(function(){ 49 + $(document).ready(function(){
50 $(window).bind('scroll', loadOnScroll); 50 $(window).bind('scroll', loadOnScroll);
51 }); 51 });
52 </script> 52 </script>
@@ -62,70 +62,48 @@ @@ -62,70 +62,48 @@
62 {% endblock %} 62 {% endblock %}
63 63
64 {% block sidebar %} 64 {% block sidebar %}
65 - <div class="panel panel-primary"> 65 + <div class="panel panel-primary navigation">
66 <div class="panel-heading"> 66 <div class="panel-heading">
67 - <img src="{{ user.image_url }}" id="img" class="img-rounded">  
68 - <p></p>  
69 - <div class="row">  
70 - <div class="col-xs-3 col-md-3">  
71 - <i class="fa fa-facebook-official fa-2x" aria-hidden="true"></i>  
72 - </div>  
73 - <div class="col-xs-3 col-md-3">  
74 - <i class="fa fa-twitter fa-2x" aria-hidden="true"></i>  
75 - </div>  
76 - <div class="col-xs-3 col-md-3">  
77 - <i class="fa fa-linkedin-square fa-2x" aria-hidden="true"></i>  
78 - </div>  
79 - <div class="col-xs-3 col-md-3">  
80 - <i class="fa fa-google-plus-official fa-2x" aria-hidden="true"></i>  
81 - </div>  
82 - </div>  
83 - </div>  
84 - <div class="panel-body">  
85 - <ul class="nav nav-pills nav-stacked">  
86 - <li> <a href="{% url 'app:index' %}">{% trans 'Home' %}</a></li>  
87 - <li> <a href="{% url 'users:profile' %}">{% trans 'Profile' %}</a></li>  
88 - <li> <a href="#">{% trans 'Pending Tasks' %}</a></li>  
89 - {% if user|has_role:'student' and not user.is_staff %}  
90 - <li> <a href="{% url 'course:manage' %}">{% trans 'My courses' %}</a></li>  
91 - {% endif %}  
92 - {% if user|has_role:'system_admin' %}  
93 - <li> <a href="{% url 'users:manage' %}">{% trans 'Manage Users' %}</a></li>  
94 - {% endif %}  
95 - {% if user|has_role:'system_admin' or user|has_role:'professor' %}  
96 - <li>  
97 - <a href="#courses_list" class="accordion" data-toggle="collapse">{% trans 'Manage Courses' %}</a>  
98 -  
99 - <div id="courses_list" class="collapse">  
100 - <ul class="nav nav-pill nav-stacked accordion_list">  
101 - {% for course in courses_list %}  
102 - <li><a href="{% url 'course:view' course.slug %}">{{ course }}</a></li>  
103 - {% endfor %}  
104 - </ul>  
105 - </div>  
106 - </li>  
107 - {% endif %}  
108 - </ul>  
109 - </div>  
110 - </div> 67 + <h4>Menu</h4>
  68 + </div>
  69 + <div class="panel-body">
  70 + <ul class="nav nav-pills nav-stacked">
  71 + <li><a href="{% url 'app:index' %}">{% trans 'Home' %}</a></li>
  72 + <li><a href="{% url 'users:profile' %}">{% trans 'Profile' %}</a></li>
  73 + {% if user|has_role:'student' or not user.is_staff %}
  74 + <li><a href="{% url 'course:manage' %}">{% trans 'My courses' %}</a></li>
  75 + {% endif %}
  76 + {% if user|has_role:'system_admin' %}
  77 + <li> <a href="{% url 'users:manage' %}">{% trans 'Manage Users' %}</a></li>
  78 + {% endif %}
  79 + {% if user|has_role:'system_admin' or user|has_role:'professor' %}
  80 + <li>
  81 + <a href="#courses_list" class="accordion" data-toggle="collapse">{% trans 'Manage Courses' %}</a>
  82 + <div id="courses_list" class="collapse">
  83 + <ul class="nav nav-pill nav-stacked accordion_list">
  84 + {% for course in courses_list %}
  85 + <li><a href="{% url 'course:view' course.slug %}">{{ course }}</a></li>
  86 + {% endfor %}
  87 + </ul>
  88 + </div>
  89 + </li>
  90 + {% endif %}
  91 + </ul>
  92 + </div>
  93 + </div>
111 {% endblock %} 94 {% endblock %}
112 95
113 {% block content %} 96 {% block content %}
114 {% if user|has_role:'system_admin' %} 97 {% if user|has_role:'system_admin' %}
115 - <h3>{% trans 'Courses' %}</h3>  
116 -  
117 - <div id="timeline">  
118 - {% include page_template %}  
119 - </div>  
120 - 98 + <h3>{% trans 'Courses' %}</h3>
  99 + <div id="timeline">
  100 + {% include page_template %}
  101 + </div>
121 {% else %} 102 {% else %}
122 -  
123 - <div id="timeline">  
124 - {% include page_template %}  
125 - </div>  
126 - 103 + <div id="timeline">
  104 + {% include page_template %}
  105 + </div>
127 {% endif %} 106 {% endif %}
128 -  
129 <div id="loading" class="alert alert-primary" role="alert" style="display: none"> 107 <div id="loading" class="alert alert-primary" role="alert" style="display: none">
130 <center> 108 <center>
131 <span class="fa fa-spin fa-circle-o-notch"></span> 109 <span class="fa fa-spin fa-circle-o-notch"></span>
app/templates/home_student.html
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 {% block sidebar %} 18 {% block sidebar %}
19 <div class="panel panel-primary navigation"> 19 <div class="panel panel-primary navigation">
20 <div class="panel-heading"> 20 <div class="panel-heading">
21 - <h5>{% trans 'Menu' %}</h5> 21 + <h4>{% trans 'Menu' %}</h4>
22 </div> 22 </div>
23 <div class="panel-body"> 23 <div class="panel-body">
24 <ul class="nav nav-pills nav-stacked"> 24 <ul class="nav nav-pills nav-stacked">
core/templates/base.html
@@ -47,77 +47,60 @@ @@ -47,77 +47,60 @@
47 {% endblock %} 47 {% endblock %}
48 </head> 48 </head>
49 <body> 49 <body>
  50 + {% block nav %}
  51 + <div class="navbar navbar-default">
  52 + <div class="navbar-header">
  53 + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
  54 + <span class="icon-bar"></span>
  55 + <span class="icon-bar"></span>
  56 + <span class="icon-bar"></span>
  57 + </button>
  58 + <a class="navbar-brand" href="{% url 'app:index' %}"><img class="logo" src="{% static 'img/topo-amadeus-white.png' %}" alt="Logo"/></a>
  59 + </div>
  60 + <div class="navbar-collapse collapse navbar-responsive-collapse">
  61 + <ul class="nav navbar-nav navbar-right notifications">
  62 + <li class="" data-toggle="tooltip" data-placement="bottom" title data-original-title="notifications">
  63 + <a class="dropdown-toggle" data-toggle="dropdown"> <span id="notification-count" class="badge notification-count">{{notifications.count}}</span><i class="fa fa-bell" aria-hidden="true"></i></a>
  64 + <ul id="notification-dropdown" class="dropdown-menu">
  65 + <li class="dropdown-header">Notifications</li>
  66 + {% include "notifications.html" %}
  67 +
  68 + <li>
  69 + <a onclick="getNotifications(5)">
  70 + <div id="notification-see-more" class="list-group-item">
  71 + <div class="row-content">
  72 + <p class="list-group-item-text">See More</p>
  73 + </div>
  74 + </a>
  75 + </li>
  76 + </ul>
  77 + </li>
  78 +
  79 + <li data-toggle="tooltip" data-placement="bottom" title data-original-title="{% trans 'messages' %}"> <a href="#"><i class="fa fa-comments" aria-hidden="true"></i></a> </li>
  80 + <li > <a class="link" href="{% url 'users:profile' %}">{{ user }}</a></li>
  81 + <li data-toggle="tooltip" data-placement="bottom" title data-original-title="log out"> <a href="{% url 'core:logout' %}"><i class="fa fa-sign-out" aria-hidden="true"></i></a></li>
  82 + </ul>
  83 + </div>
  84 + </div>
  85 + {% endblock %}
50 <div class="container-fluid"> 86 <div class="container-fluid">
51 - {% block nav %}  
52 - <div class="row">  
53 - <div class="navbar navbar-default">  
54 - <div class="navbar-header">  
55 - <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">  
56 - <span class="icon-bar"></span>  
57 - <span class="icon-bar"></span>  
58 - <span class="icon-bar"></span>  
59 - </button>  
60 - <a class="navbar-brand" href="{% url 'app:index' %}"><img class="logo" src="{% static 'img/topo-amadeus-white.png' %}" alt="Logo"/></a>  
61 - </div>  
62 - <div class="navbar-collapse collapse navbar-responsive-collapse">  
63 - <ul class="nav navbar-nav navbar-right notifications">  
64 - <li class="" data-toggle="tooltip" data-placement="bottom" title data-original-title="notifications">  
65 - <a class="dropdown-toggle" data-toggle="dropdown"> <span id="notification-count" class="badge notification-count">{{notifications.count}}</span><i class="fa fa-bell" aria-hidden="true"></i></a>  
66 - <ul id="notification-dropdown" class="dropdown-menu">  
67 - <li class="dropdown-header">Notifications</li>  
68 - {% include "notifications.html" %}  
69 -  
70 - <li>  
71 - <a onclick="getNotifications(5)">  
72 - <div id="notification-see-more" class="list-group-item">  
73 - <div class="row-content">  
74 - <p class="list-group-item-text">See More</p>  
75 - </div>  
76 - </a>  
77 - </li>  
78 - </ul>  
79 - </li>  
80 -  
81 - <li data-toggle="tooltip" data-placement="bottom" title data-original-title="{% trans 'messages' %}"> <a href="#"><i class="fa fa-comments" aria-hidden="true"></i></a> </li>  
82 - <li > <a class="link" href="{% url 'users:profile' %}">{{ user }}</a></li>  
83 - <li data-toggle="tooltip" data-placement="bottom" title data-original-title="log out"> <a href="{% url 'core:logout' %}"><i class="fa fa-sign-out" aria-hidden="true"></i></a></li>  
84 - </ul>  
85 - </div>  
86 - </div>  
87 - </div>  
88 - {% endblock %}  
89 -  
90 <div class="row"> 87 <div class="row">
91 - <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 col-xl-2">  
92 - {% block sidebar %}  
93 -  
94 - {% endblock %}  
95 - </div>  
96 -  
97 - <div class="col-xs-10 col-sm-10 col-md-10 col-lg-10 col-xl-10">  
98 - {% block breadcrumbs %}  
99 -  
100 - {% endblock %}  
101 -  
102 - {% block render_breadcrumbs %}  
103 -  
104 - {% endblock %}  
105 - <div class="row">  
106 - <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">  
107 - {% block content %}  
108 -  
109 - {% endblock %}  
110 - </div>  
111 -  
112 -  
113 - </div>  
114 - </div> 88 + <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 col-xl-2">
  89 + {% block sidebar %}{% endblock %}
  90 + </div>
  91 + <div class="col-xs-10 col-sm-10 col-md-10 col-lg-10 col-xl-10">
  92 + {% block breadcrumbs %}{% endblock %}
  93 + {% block render_breadcrumbs %}{% endblock %}
  94 + </div>
  95 + <div class="col-xs-10 col-sm-10 col-md-10 col-lg-10 col-xl-10">
  96 + {% block content %}{% endblock %}
  97 + </div>
115 </div> 98 </div>
116 </div> 99 </div>
117 <script src="{% static 'js/main.js' %}"></script> 100 <script src="{% static 'js/main.js' %}"></script>
118 <script type="text/javascript" src="{% static 'js/topic_editation_presentation.js' %}"></script> 101 <script type="text/javascript" src="{% static 'js/topic_editation_presentation.js' %}"></script>
119 {% block script_file %} 102 {% block script_file %}
120 - 103 +
121 {% endblock script_file %} 104 {% endblock script_file %}
122 </body> 105 </body>
123 106
courses/static/js/course.js
@@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
  1 +/*
  2 +*
  3 +* Function to subscribe (works for courses and subjects)
  4 +*
  5 +*/
  6 +function subscribe(elem, url, confirm_message) {
  7 + alertify.confirm(confirm_message, function(){
  8 + $.ajax({
  9 + dataType: "json",
  10 + url: url,
  11 + success: function (data) {
  12 + if (data.status == "ok") {
  13 + elem.disabled(true);
  14 + alertify.success(data.message);
  15 + } else {
  16 + alertify.error(data.message);
  17 + }
  18 + }
  19 + });
  20 + });
  21 +}
0 \ No newline at end of file 22 \ No newline at end of file
courses/static/js/modal_category.js 0 → 100644
@@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
  1 +
  2 +var Submite = {
  3 + remove: function(url,dados,id_li_link){
  4 + $('#category').modal('hide');
  5 + $.post(url,dados, function(data){
  6 + $(id_li_link).remove();
  7 + $("#modal_category").empty();
  8 + $("div.modal-backdrop.fade.in").remove();
  9 + alertify.success("Category removed successfully!");
  10 + }).fail(function(){
  11 + $("#modal_category").empty();
  12 + $("#modal_category").append(data);
  13 + $('#category').modal('show');
  14 + });
  15 + }
  16 +}
  17 +
  18 +var modal = {
  19 + get: function (url, id_modal, id_div_modal){
  20 + $.get(url, function(data){
  21 + if($(id_modal).length){
  22 + $(id_div_modal).empty();
  23 + $(id_div_modal).append(data);
  24 + } else {
  25 + $(id_div_modal).append(data);
  26 + }
  27 + $(id_modal).modal('show');
  28 + });
  29 + }
  30 +};
0 \ No newline at end of file 31 \ No newline at end of file
courses/templates/category/delete.html
1 -{% extends 'base.html' %}  
2 -  
3 -{% load static i18n %}  
4 {% load static i18n permission_tags %} 1 {% load static i18n permission_tags %}
5 2
6 -{% block breadcrumbs %}  
7 - <ol class="breadcrumb">  
8 - <li><a href="{% url 'app:index' %}">{% trans 'Home' %}</a></li>  
9 - <li class="active">{% trans 'Manage Categories' %}</li>  
10 - </ol>  
11 -{% endblock %} 3 +<!-- Modal (remember to change the ids!!!) -->
  4 +<div class="modal fade" id="category" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  5 + <div class="modal-dialog" role="document">
  6 + <div class="modal-content">
  7 + <!-- Modal Header -->
  8 + <div class="modal-header">
12 9
13 -{% block sidebar %}  
14 - <div class="panel panel-primary navigation">  
15 - <div class="panel-heading">  
16 - <h5>{% trans 'Menu' %}</h5>  
17 - </div>  
18 - <div class="panel-body">  
19 - <ul class="nav nav-pills nav-stacked">  
20 - <li><a href="{% url 'users:profile' %}">{% trans 'Profile' %}</a></li>  
21 - <li><a href="{% url 'course:manage' %}">{% trans 'My Courses' %}</a></li>  
22 - </ul>  
23 - </div> 10 + <h4 class="modal-title" id="myModalLabel">{% trans "Delete Category" %}</h4>
  11 + </div>
  12 + <!-- Modal Body -->
  13 + <div class="modal-body">
  14 + <!-- Put ONLY your content here!!! -->
  15 + <form id="delete_form" action="" method="post">
  16 + {% csrf_token %}
  17 + <p>{% trans 'Are you sure you want to delete the subject' %} "{{category.name}}"?</p>
  18 + </form>
  19 + </div>
  20 + <!-- Modal Footer -->
  21 + <div class="modal-footer">
  22 + <!-- Don't remove that!!! -->
  23 + <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans "Close" %}</button>
  24 + <button type="submit" id="button" form="delete_form" class="btn btn-primary btn-raised">{% trans "Delete" %}</button>
  25 + <script>
  26 + $("#delete_form").submit(function(event) {
  27 + Submite.remove("{% url 'course:delete_cat' category.slug %}",$(this).serialize(),"#category_{{category.slug}}");
  28 + event.preventDefault();
  29 + });
  30 + </script>
  31 + </div>
24 </div> 32 </div>
25 -  
26 -{% if user|has_role:'professor' or user|has_role:'system_admin' %}  
27 -  
28 - <div class="panel panel-primary navigation">  
29 - <div class="panel-heading">  
30 - <h3 class="panel-title">Actions</h3>  
31 - </div>  
32 - <div class="panel-body">  
33 - <ul class="nav nav-pills nav-stacked">  
34 - <li><a href="javascript:void(0)">Replicate Course</a></li>  
35 - <li><a href="{% url 'course:create' %}">Create Course</a></li>  
36 - <li><a href="{% url 'course:create_cat' %}">Create Category</a></li>  
37 - </ul>  
38 - </div>  
39 - </div>  
40 - <div class="panel panel-primary navigation">  
41 - <div class="panel-heading">  
42 - <h3 class="panel-title">Category</h3>  
43 - </div>  
44 - <div class="panel-body">  
45 - <ul class="nav nav-pills nav-stacked">  
46 - <li><a href="{% url 'course:create_cat' %}">Create Category</a></li>  
47 - <li><a href="{% url 'course:manage_cat' %}">List Category</a></li>  
48 - </ul>  
49 - </div>  
50 - </div>  
51 -{% endif %}  
52 -{% endblock %}  
53 -  
54 -{% block content %}  
55 - <div class="card card-content">  
56 - <div class="card-body">  
57 - <form action="" method="post">{% csrf_token %}  
58 - <h1>{% trans 'Are you sure you want to delete the category' %} "{{ object }}"?</h1>  
59 - <input type="submit" class="btn btn-success btn-sm" value="{% trans 'Yes' %}" />  
60 - <a href="{% url 'course:manage_cat' %}" class="btn btn-danger btn-sm">{% trans 'No' %}</a>  
61 - </form>  
62 - </div>  
63 - </div>  
64 -{% endblock %} 33 + </div>
  34 +</div>
  35 +<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  36 +<script src="{% static 'js/modal_category.js' %}"></script>
courses/templates/category/index.html
@@ -82,7 +82,8 @@ @@ -82,7 +82,8 @@
82 <td class="text-center"> 82 <td class="text-center">
83 <a href="{% url 'course:view_cat' category.slug %}" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-eye-open"></span></a> 83 <a href="{% url 'course:view_cat' category.slug %}" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-eye-open"></span></a>
84 <a href="{% url 'course:update_cat' category.slug %}" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-edit"></span></a> 84 <a href="{% url 'course:update_cat' category.slug %}" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-edit"></span></a>
85 - <a href="{% url 'course:delete_cat' category.slug %}" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-trash"></span></a> 85 + <a href="javascript:modal.get('{% url 'course:delete_cat' category.slug %}','#category','#modal_category');" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-trash"></span></a>
  86 +
86 </td> 87 </td>
87 </tr> 88 </tr>
88 {% endfor %} 89 {% endfor %}
@@ -96,4 +97,6 @@ @@ -96,4 +97,6 @@
96 </tbody> 97 </tbody>
97 </table> 98 </table>
98 </div> 99 </div>
99 -{% endblock %} 100 + <div class="row" id="modal_category">
  101 +<script src="{% static 'js/modal_category.js' %}"></script>
  102 +{% endblock %}
100 \ No newline at end of file 103 \ No newline at end of file
courses/templates/course/index.html
@@ -11,47 +11,35 @@ @@ -11,47 +11,35 @@
11 {% endblock %} 11 {% endblock %}
12 12
13 {% block sidebar %} 13 {% block sidebar %}
14 - <div class="panel panel-primary navigation"> 14 + <div class="panel panel-primary navigation">
15 <div class="panel-heading"> 15 <div class="panel-heading">
16 - <h5>{% trans 'Menu' %}</h5> 16 + <h4>Menu</h4>
17 </div> 17 </div>
18 <div class="panel-body"> 18 <div class="panel-body">
19 <ul class="nav nav-pills nav-stacked"> 19 <ul class="nav nav-pills nav-stacked">
20 - <li><a href="{% url 'core:home' %}">{% trans 'Home' %}</a></li> 20 + <li><a href="{% url 'app:index' %}">{% trans 'Home' %}</a></li>
21 <li><a href="{% url 'users:profile' %}">{% trans 'Profile' %}</a></li> 21 <li><a href="{% url 'users:profile' %}">{% trans 'Profile' %}</a></li>
22 - <li><a href="{% url 'course:manage' %}">{% trans 'My Courses' %}</a></li> 22 + {% if user|has_role:'student' or not user.is_staff %}
  23 + <li><a href="{% url 'course:manage' %}">{% trans 'My courses' %}</a></li>
  24 + {% endif %}
  25 + {% if user|has_role:'system_admin' %}
  26 + <li> <a href="{% url 'users:manage' %}">{% trans 'Manage Users' %}</a></li>
  27 + {% endif %}
  28 + {% if user|has_role:'system_admin' or user|has_role:'professor' %}
  29 + <li>
  30 + <a href="#courses_list" class="accordion" data-toggle="collapse">{% trans 'Manage Courses' %}</a>
  31 + <div id="courses_list" class="collapse">
  32 + <ul class="nav nav-pill nav-stacked accordion_list">
  33 + {% for course in courses_list %}
  34 + <li><a href="{% url 'course:view' course.slug %}">{{ course }}</a></li>
  35 + {% endfor %}
  36 + </ul>
  37 + </div>
  38 + </li>
  39 + {% endif %}
23 </ul> 40 </ul>
24 </div> 41 </div>
25 </div> 42 </div>
26 -  
27 -{% if user|has_role:'professor' or user|has_role:'system_admin' %}  
28 -  
29 - <div class="panel panel-primary navigation">  
30 - <div class="panel-heading">  
31 - <h3 class="panel-title">Actions</h3>  
32 - </div>  
33 - <div class="panel-body">  
34 - <ul class="nav nav-pills nav-stacked">  
35 - <li><a href="javascript:void(0)">Replicate Course</a></li>  
36 - <li><a href="{% url 'course:create' %}">Create Course</a></li>  
37 - </ul>  
38 - </div>  
39 - </div>  
40 -  
41 - <div class="panel panel-primary navigation">  
42 - <div class="panel-heading">  
43 - <h3 class="panel-title">Category</h3>  
44 - </div>  
45 - <div class="panel-body">  
46 - <ul class="nav nav-pills nav-stacked">  
47 - <li><a href="{% url 'course:create_cat' %}">Create Category</a></li>  
48 - <li><a href="{% url 'course:manage_cat' %}">List Category</a></li>  
49 - </ul>  
50 - </div>  
51 - </div>  
52 -  
53 -{% endif %}  
54 -  
55 {% endblock %} 43 {% endblock %}
56 44
57 {% block content %} 45 {% block content %}
@@ -98,13 +86,13 @@ @@ -98,13 +86,13 @@
98 <div class="panel panel-info"> 86 <div class="panel panel-info">
99 <div class="panel-heading" role="tab"> 87 <div class="panel-heading" role="tab">
100 <div class="row"> 88 <div class="row">
101 - <div class="col-xs-9 col-md-9 titleTopic"> 89 + <div class="col-xs-9 col-md-10 titleTopic">
102 <a role="button" data-toggle="collapse" data-parent="#accordion" href=".collapseOne" aria-expanded="false" aria-controls="collapseOne" class="collapsed"> 90 <a role="button" data-toggle="collapse" data-parent="#accordion" href=".collapseOne" aria-expanded="false" aria-controls="collapseOne" class="collapsed">
103 <h4 style="color:white">{{course.name}}</h4> 91 <h4 style="color:white">{{course.name}}</h4>
104 </a> 92 </a>
105 </div> 93 </div>
106 {% if user|has_role:'professor' or user|has_role:'system_admin' %} 94 {% if user|has_role:'professor' or user|has_role:'system_admin' %}
107 - <div class="col-xs-4 col-md-3" id="divMoreActions"> 95 + <div class="col-xs-4 col-md-2" id="divMoreActions">
108 <div class="btn-group"> 96 <div class="btn-group">
109 <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> 97 <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
110 <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> 98 <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i>
courses/templates/subject/index.html
@@ -36,12 +36,12 @@ @@ -36,12 +36,12 @@
36 <div class="panel panel-info"> 36 <div class="panel panel-info">
37 <div class="panel-heading"> 37 <div class="panel-heading">
38 <div class="row"> 38 <div class="row">
39 - <div class="col-md-10 col-sm-9"> 39 + <div class="col-md-10 col-sm-10">
40 <h3>{{subject}}</h3> 40 <h3>{{subject}}</h3>
41 </div> 41 </div>
42 {% professor_subject subject user as subject_professor%} 42 {% professor_subject subject user as subject_professor%}
43 {% if subject_professor %} 43 {% if subject_professor %}
44 - <div class="col-xs-4 col-md-3 divMoreActions"> 44 + <div class="col-xs-4 col-md-2 divMoreActions">
45 <div class="btn-group"> 45 <div class="btn-group">
46 <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> 46 <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
47 <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> 47 <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i>
courses/urls.py
@@ -29,7 +29,7 @@ urlpatterns = [ @@ -29,7 +29,7 @@ urlpatterns = [
29 url(r'^subjects/categories$',views.IndexSubjectCategoryView.as_view(), name='subject_category_index'), 29 url(r'^subjects/categories$',views.IndexSubjectCategoryView.as_view(), name='subject_category_index'),
30 url(r'^forum/', include('forum.urls', namespace = 'forum')), 30 url(r'^forum/', include('forum.urls', namespace = 'forum')),
31 url(r'^poll/', include('poll.urls', namespace = 'poll')), 31 url(r'^poll/', include('poll.urls', namespace = 'poll')),
32 - # url(r'^exam/', include('exam.urls', namespace = 'exam')), 32 + url(r'^exam/', include('exam.urls', namespace = 'exam')),
33 url(r'^files/', include('files.urls', namespace = 'file')), 33 url(r'^files/', include('files.urls', namespace = 'file')),
34 url(r'^upload-material/$', views.UploadMaterialView.as_view(), name='upload_material'), 34 url(r'^upload-material/$', views.UploadMaterialView.as_view(), name='upload_material'),
35 url(r'^links/',include('links.urls',namespace = 'links')), 35 url(r'^links/',include('links.urls',namespace = 'links')),
courses/views.py
@@ -35,10 +35,10 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): @@ -35,10 +35,10 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView):
35 list_courses = None 35 list_courses = None
36 categorys_courses = None 36 categorys_courses = None
37 if has_role(self.request.user,'professor') or has_role(self.request.user,'system_admin'): 37 if has_role(self.request.user,'professor') or has_role(self.request.user,'system_admin'):
38 - list_courses = Course.objects.filter(professors__name = self.request.user.name).order_by('name') 38 + list_courses = Course.objects.filter(Q(professors = True)|Q(professors__name = self.request.user.name)).order_by('name')
39 categorys_courses = CourseCategory.objects.filter(course_category__professors__name = self.request.user.name).distinct() 39 categorys_courses = CourseCategory.objects.filter(course_category__professors__name = self.request.user.name).distinct()
40 else: 40 else:
41 - list_courses = Course.objects.filter(students__name = self.request.user.name) 41 + list_courses = Course.objects.filter(Q(students = True)|Q(students__name = self.request.user.name)).order_by('name')
42 categorys_courses = CourseCategory.objects.filter(course_category__students__name = self.request.user.name).distinct() 42 categorys_courses = CourseCategory.objects.filter(course_category__students__name = self.request.user.name).distinct()
43 43
44 courses_category = Course.objects.filter(category__name = self.request.GET.get('category')) 44 courses_category = Course.objects.filter(category__name = self.request.GET.get('category'))
@@ -305,6 +305,19 @@ class DeleteCatView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): @@ -305,6 +305,19 @@ class DeleteCatView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView):
305 model = CourseCategory 305 model = CourseCategory
306 template_name = 'category/delete.html' 306 template_name = 'category/delete.html'
307 307
  308 + def dispatch(self, *args, **kwargs):
  309 + category = get_object_or_404(CourseCategory, slug = self.kwargs.get('slug'))
  310 + if(not has_object_permission('delete_category', self.request.user, category)):
  311 + return self.handle_no_permission()
  312 + return super(DeleteCatView, self).dispatch(*args, **kwargs)
  313 +
  314 +
  315 + def get_context_data(self, **kwargs):
  316 + context = super(DeleteCatView, self).get_context_data(**kwargs)
  317 + context['course'] = self.object.course_category
  318 + context['category'] = self.object
  319 + return context
  320 +
308 def get_success_url(self): 321 def get_success_url(self):
309 messages.success(self.request, _('Category deleted successfully!')) 322 messages.success(self.request, _('Category deleted successfully!'))
310 return reverse_lazy('course:manage_cat') 323 return reverse_lazy('course:manage_cat')
exam/templates/exam/create.html
@@ -0,0 +1,116 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 %} #}
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 +]
@@ -24,7 +24,7 @@ class ViewExam(LoginRequiredMixin,generic.DetailView): @@ -24,7 +24,7 @@ class ViewExam(LoginRequiredMixin,generic.DetailView):
24 template_name = 'exam/view.html' 24 template_name = 'exam/view.html'
25 25
26 def get_object(self, queryset=None): 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 def get_context_data(self, **kwargs): 29 def get_context_data(self, **kwargs):
30 context = super(ViewExam, self).get_context_data(**kwargs) 30 context = super(ViewExam, self).get_context_data(**kwargs)
@@ -227,3 +227,29 @@ class AnswerStudentExam(LoginRequiredMixin,generic.CreateView): @@ -227,3 +227,29 @@ class AnswerStudentExam(LoginRequiredMixin,generic.CreateView):
227 context['keys'] = keys 227 context['keys'] = keys
228 228
229 return context 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'
files/templates/files/delete_file.html
@@ -59,6 +59,7 @@ @@ -59,6 +59,7 @@
59 contentType: false, 59 contentType: false,
60 success: function(data) { 60 success: function(data) {
61 $('#fileDeleteModal').modal('hide'); 61 $('#fileDeleteModal').modal('hide');
  62 + $('#file_{{ file.slug }}').remove();
62 $('#file_edit_{{ file.slug }}').remove(); 63 $('#file_edit_{{ file.slug }}').remove();
63 $('#file_edit_icon_{{ file.slug }}').remove(); 64 $('#file_edit_icon_{{ file.slug }}').remove();
64 }, 65 },