Commit cc972f58 authored by Bruno Martin's avatar Bruno Martin
Browse files

working couse and lesson admin

parent 16dc4315
......@@ -50,7 +50,7 @@
if (force)
$scope.fu.addField('force', true);
$scope.fu.sendTo('/admin/course/import/')
$scope.fu.sendTo('/legacy/admin/course/import/')
.then(function(response) {
if (response.data.error) {
if (response.data.error == 'course_started') {
......
......@@ -9,16 +9,14 @@
'directive.waiting-screen',
'directive.alertPopup',
'directive.contenteditable',
'directive.codemirror',
'core.services',
'directive.fixedBar',
'directive.markdowneditor',
// 'directive.sortable',
// 'filters.text',
'youtube',
'header',
'ui.bootstrap',
'discussion.services',
// 'discussion.services',
'ngFileUpload',
'ui.tinymce',
]);
......
......@@ -14,9 +14,8 @@
'youtubePlayerApi',
'MarkdownDirective',
'waitingScreen',
'Forum',
function($scope, $location, Course, CourseProfessor, Lesson, LessonUpdate, Unit, VideoData, youtubePlayerApi,
MarkdownDirective, waitingScreen, Forum) {
MarkdownDirective, waitingScreen) {
$scope.errors = {};
var httpErrors = {
'400': 'Os campos não foram preenchidos corretamente.',
......@@ -290,28 +289,28 @@
expected = [];
}
if(type === 'discussion'){
// if(type === 'discussion'){
// JSON pattern for the discussion type of activities
$scope.currentActivity = {
'type': type,
'data': {
'forum': null,
'content': '',
'start_date': null,
'end_date': null
},
'expected': ''
};
// Create a new forum to recieve the students answers
var new_forum = new Forum();
new_forum.title = 'Fórum de atividades: ' + $scope.lesson.name;
new_forum.forum_type = 'activity';
new_forum.$save(function(forum) {
$scope.currentActivity.data.forum = forum.id;
});
} else {
// $scope.currentActivity = {
// 'type': type,
// 'data': {
// 'forum': null,
// 'content': '',
// 'start_date': null,
// 'end_date': null
// },
// 'expected': ''
// };
// // Create a new forum to recieve the students answers
// var new_forum = new Forum();
// new_forum.title = 'Fórum de atividades: ' + $scope.lesson.name;
// new_forum.forum_type = 'activity';
// new_forum.$save(function(forum) {
// $scope.currentActivity.data.forum = forum.id;
// });
// } else {
// JSON pattern for other types of activities
$scope.currentActivity = {
'type': type,
......@@ -323,7 +322,7 @@
},
'expected': expected
};
}
// }
$scope.currentUnit.activities.push($scope.currentActivity);
$scope.newActivityType = null;
......
......@@ -15,6 +15,5 @@
'youtube',
'markdown',
'ui.bootstrap',
'header',
]);
})(window.angular);
......@@ -217,7 +217,7 @@
if (course_professor_picture_file){
// return a new promise that file will be uploaded
fu.sendTo('/api/course_professor_picture/' + course_professor.id)
fu.sendTo('legacy/api/course_professor_picture/' + course_professor.id)
.then(function(response){
course_professor.get_picture_url = '/media/' + response.data.picture;
course_professor.picture = '/media/' + response.data.picture;
......@@ -234,7 +234,7 @@
course_professor.$update({id: course_professor.id}, function (){
if (course_professor_picture_file){
// return a new promise that file will be uploaded
fu.sendTo('/api/course_professor_picture/' + course_professor.id)
fu.sendTo('legacy/api/course_professor_picture/' + course_professor.id)
.then(function(response){
course_professor.get_picture_url = '/media/' + response.data.picture;
course_professor.picture = '/media/' + response.data.picture;
......
(function (angular) {
'use strict';
// Declare app level module which depends on filters, and services
angular.module('markdown', ['markdown.filters']);
})(angular);
(function (angular, Markdown) {
'use strict';
angular.module('markdown.directives', []).
directive('markdowneditor', function(){
return {
"restrict": 'A',
"controller": ['$scope', '$element', function($scope, $element) {
$element.find('textarea').attr('id', "wmd-input");
$element.find('.js-button-bar').attr('id', "wmd-button-bar");
var editor = new Markdown.Editor(Markdown.getSanitizingConverter());
editor.run();
}],
"link": function(scope, element) {
var read = function read(evt){
scope.new_text = evt.currentTarget.value;
};
element.find('textarea').on('blur change', read);
}
};
});
})(angular, Markdown);
(function (angular, Markdown) {
'use strict';
angular.module('markdown.filters', ["ngSanitize"]).
filter('markdown', ['$window', function($window) {
return function(text) {
return text ? Markdown.getSanitizingConverter().makeHtml(text) : "";
};
}]);
})(angular, Markdown);
This diff is collapsed.
This diff is collapsed.
(function () {
var output, Converter;
if (typeof exports === "object" && typeof require === "function") { // we're in a CommonJS (e.g. Node.js) module
output = exports;
Converter = require("./Markdown.Converter").Converter;
} else {
output = window.Markdown;
Converter = output.Converter;
}
output.getSanitizingConverter = function () {
var converter = new Converter();
converter.hooks.chain("postConversion", sanitizeHtml);
converter.hooks.chain("postConversion", balanceTags);
return converter;
};
function sanitizeHtml(html) {
return html.replace(/<[^>]*>?/gi, sanitizeTag);
}
// (tags that can be opened/closed) | (tags that stand alone)
var basic_tag_whitelist = /^(<\/?(b|blockquote|code|del|dd|dl|dt|em|h1|h2|h3|i|kbd|li|ol|p|s|sup|sub|strong|strike|ul)>|<(br|hr)\s?\/?>)$/i;
// <a href="url..." optional title>|</a>
var a_white = /^(<a\shref="(https?:(\/\/|\/)|ftp:(\/\/|\/)|mailto:|magnet:)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+"(\stitle="[^"<>]+")+"(\starget="[^"<>]+")?\s?>|<\/a>)$/i;
// <img src="url..." optional width optional height optional alt optional title
var img_white = /^(<img\ssrc="(https?:\/\/|\/)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+"(\swidth="\d{1,3}")?(\sheight="\d{1,3}")?(\salt="[^"<>]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i;
// <pre optional class="prettyprint linenums">|</pre> for twitter bootstrap
var pre_white = /^(<pre(\sclass="prettyprint linenums")?>|<\/pre>)$/i;
function sanitizeTag(tag) {
if (tag.match(basic_tag_whitelist) || tag.match(a_white) || tag.match(img_white) || tag.match(pre_white))
return tag;
else
return "";
}
/// <summary>
/// attempt to balance HTML tags in the html string
/// by removing any unmatched opening or closing tags
/// IMPORTANT: we *assume* HTML has *already* been
/// sanitized and is safe/sane before balancing!
///
/// adapted from CODESNIPPET: A8591DBA-D1D3-11DE-947C-BA5556D89593
/// </summary>
function balanceTags(html) {
if (html == "")
return "";
var re = /<\/?\w+[^>]*(\s|$|>)/g;
// convert everything to lower case; this makes
// our case insensitive comparisons easier
var tags = html.toLowerCase().match(re);
// no HTML tags present? nothing to do; exit now
var tagcount = (tags || []).length;
if (tagcount == 0)
return html;
var tagname, tag;
var ignoredtags = "<p><img><br><li><hr>";
var match;
var tagpaired = [];
var tagremove = [];
var needsRemoval = false;
// loop through matched tags in forward order
for (var ctag = 0; ctag < tagcount; ctag++) {
tagname = tags[ctag].replace(/<\/?(\w+).*/, "$1");
// skip any already paired tags
// and skip tags in our ignore list; assume they're self-closed
if (tagpaired[ctag] || ignoredtags.search("<" + tagname + ">") > -1)
continue;
tag = tags[ctag];
match = -1;
if (!/^<\//.test(tag)) {
// this is an opening tag
// search forwards (next tags), look for closing tags
for (var ntag = ctag + 1; ntag < tagcount; ntag++) {
if (!tagpaired[ntag] && tags[ntag] == "</" + tagname + ">") {
match = ntag;
break;
}
}
}
if (match == -1)
needsRemoval = tagremove[ctag] = true; // mark for removal
else
tagpaired[match] = true; // mark paired
}
if (!needsRemoval)
return html;
// delete all orphaned tags from the string
var ctag = 0;
html = html.replace(re, function (match) {
var res = tagremove[ctag] ? "" : match;
ctag++;
return res;
});
return html;
}
})();
{% load i18n %}
{% load get_current_class %}
<div class="course-details">
<div><span class="label">{% trans 'By' %}:</span>
{% for course_professor in course.course.course_authors.all %}
<a class="course-instructor" {% if course_professor.user %}href="{% url 'profile' course_professor.user.username %}"{% endif %}>{{ course_professor.get_name }}</a>
{% endfor %}
</div>
{% get_current_class course as current_class %}
<div>{% if current_class.assistant %}<span class="label">{% trans 'Assistant Professor' %}:</span> {{ current_class.assistant.get_full_name }} {% endif %} {% if not course.default_class %} <span class="label">{% trans 'Class' %}:</span> {{ current_class.name }} {% endif %}</div>
</div>
......@@ -4,26 +4,24 @@
{% load compress %}
{% block js %} {{block.super}}
<script type="text/javascript" src="{% static 'tinymce-dist/tinymce.js' %}"></script>
<script src="https://unpkg.com/tinymce@4.5.10/tinymce.min.js"></script>
<script src="https://unpkg.com/ng-file-upload@12.0.4/dist/ng-file-upload.min.js"></script>
<script src="https://unpkg.com/angular-ui-tinymce@0.0.19/dist/tinymce.min.js"></script>
{% compress js %}
<script type="text/javascript" src="{% static 'app/admin.lesson.app.js' %}"></script>
<script type="text/javascript" src="{% static 'app/controllers/admin.lesson.controllers.js' %}"></script>
<script type="text/javascript" src="{% static 'app/services/admin.lesson.services.js' %}"></script>
<script type="text/javascript" src="{% static 'js/core-services.js' %}"></script>
<script type="text/javascript" src="{% static 'js/new-course/directives.js' %}"></script>
<script type="text/javascript" src="{% static 'js/filters/text.js' %}"></script>
<script type="text/javascript" src="{% static 'js/directives/alertPopup.js' %}"></script>
<script type="text/javascript" src="{% static 'js/directives/waiting-screen.js' %}"></script>
<script type="text/javascript" src="{% static 'js/directives/contenteditable.js' %}"></script>
<script type="text/javascript" src="{% static 'js/directives/fixedBar.js' %}"></script>
<script type="text/javascript" src="{% static 'js/directives/markdowneditor.js' %}"></script>
<script type="text/javascript" src="{% static 'js/directives/codemirror.js' %}"></script>
<script type="text/javascript" src="{% static 'js/directives/sortable.js' %}"></script>
<script type="text/javascript" src="{% static 'ng-file-upload/ng-file-upload.js' %}"></script>
<script type="text/javascript" src="{% static 'angular-ui-tinymce/src/tinymce.js' %}"></script>
<script type="text/javascript" src="{% static 'js/ui.tinymce.paralapraca.config.js' %}"></script>
<script src="{% static 'js/admin/lesson/admin.lesson.app.js' %}"></script>
<script src="{% static 'js/admin/lesson/admin.lesson.controllers.js' %}"></script>
<script src="{% static 'js/admin/lesson/admin.lesson.services.js' %}"></script>
<script src="{% static 'js/core-services.js' %}"></script>
<script src="{% static 'js/admin/new-course/directives.js' %}"></script>
<script src="{% static 'js/admin/filters/text.js' %}"></script>
<script src="{% static 'js/admin/directives/alertPopup.js' %}"></script>
<script src="{% static 'js/admin/directives/waiting-screen.js' %}"></script>
<script src="{% static 'js/admin/directives/contenteditable.js' %}"></script>
<script src="{% static 'js/admin/directives/fixedBar.js' %}"></script>
<script src="{% static 'js/admin/directives/markdowneditor.js' %}"></script>
<script src="{% static 'js/admin/directives/sortable.js' %}"></script>
<script src="{% static 'js/ui.tinymce.paralapraca.config.js' %}"></script>
{% endcompress %}
{% endblock %}
......
......@@ -11,16 +11,20 @@
{% if in_admin %}
{% block js %} {{block.super}}
{% compress js %}
<script type="text/javascript" src="{% static 'js/new-course/app.js' %}">// must be the 1º</script>
<script type="text/javascript" src="{% static 'js/factories/timtec-models.js' %}">// must be the 2º</script>
<script type="text/javascript" src="{% static 'js/filters/text.js' %}"></script>
<script type="text/javascript" src="{% static 'js/new-course/directives.js' %}"></script>
<script type="text/javascript" src="{% static 'js/directives/alertPopup.js' %}"></script>
<script type="text/javascript" src="{% static 'js/directives/contenteditable.js' %}"></script>
<script type="text/javascript" src="{% static 'js/directives/fixedBar.js' %}"></script>
<script type="text/javascript" src="{% static 'js/directives/markdowneditor.js' %}"></script>
<script type="text/javascript" src="{% static 'js/directives/sortable.js' %}"></script>
<script type="text/javascript" src="{% static 'js/new-course/controllers.js' %}"></script>
<script type="text/javascript" src="{% static 'js/admin/new-course/app.js' %}">// must be the 1º</script>
<script type="text/javascript" src="{% static 'js/admin/factories/timtec-models.js' %}">// must be the 2º</script>
<script type="text/javascript" src="{% static 'js/admin/filters/text.js' %}"></script>
<script type="text/javascript" src="{% static 'js/admin/new-course/directives.js' %}"></script>
<script type="text/javascript" src="{% static 'js/admin/directives/alertPopup.js' %}"></script>
<script type="text/javascript" src="{% static 'js/admin/directives/contenteditable.js' %}"></script>
<script type="text/javascript" src="{% static 'js/admin/directives/fixedBar.js' %}"></script>
<script type="text/javascript" src="{% static 'js/admin/directives/markdowneditor.js' %}"></script>
<script type="text/javascript" src="{% static 'js/admin/directives/sortable.js' %}"></script>
<script type="text/javascript" src="{% static 'js/admin/new-course/controllers.js' %}"></script>
<script type="text/javascript" src="{% static 'js/pagedown/Markdown.Converter.js' %}" ></script>
<script type="text/javascript" src="{% static 'js/pagedown/Markdown.Editor.js' %}" ></script>
<script type="text/javascript" src="{% static 'js/pagedown/Markdown.Sanitizer.js' %}" ></script>
<script type="text/javascript" src="{% static 'js/markdown/app.js' %}"></script>
<script type="text/javascript" src="{% static 'js/markdown/filters.js' %}"></script>
{% endcompress %}
......@@ -34,8 +38,6 @@
{% block body_attrs %}
{% if in_admin %}
ng-app="new-course"
{% else %}
ng-app="header"
{% endif %}
{% endblock %}
......@@ -392,7 +394,7 @@ wrapper-course-intro
<div class="primary-page-header">
<h3><i class="fa fa-angle-double-right"></i> Capítulos</h3>
<div class="pull-right">
<a class="btn btn-primary btn-inverse add" href="/admin/courses/{{ course.id }}/lessons/new">Adicionar capítulo</a>
<a class="btn btn-primary btn-inverse add" href="/legacy/admin/courses/{{ course.id }}/lessons/new">Adicionar aula</a>
</div>
<!-- <button class="btn btn-sm btn-primary btn-inverse sort" ng-click="organizingLessons=true" ng-show="!organizingLessons" >ordenar</button> -->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment