Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
MOOC packages by hacklab
django-courses-legacy
Commits
cc972f58
Commit
cc972f58
authored
Apr 26, 2019
by
Bruno Martin
Browse files
working couse and lesson admin
parent
16dc4315
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
3694 additions
and
62 deletions
+3694
-62
courses_legacy/static/js/admin/courses/controllers.js
courses_legacy/static/js/admin/courses/controllers.js
+1
-1
courses_legacy/static/js/admin/lesson/admin.lesson.app.js
courses_legacy/static/js/admin/lesson/admin.lesson.app.js
+1
-3
courses_legacy/static/js/admin/lesson/admin.lesson.controllers.js
...legacy/static/js/admin/lesson/admin.lesson.controllers.js
+23
-24
courses_legacy/static/js/admin/lesson/admin.lesson.services.js
...es_legacy/static/js/admin/lesson/admin.lesson.services.js
+0
-0
courses_legacy/static/js/admin/new-course/app.js
courses_legacy/static/js/admin/new-course/app.js
+0
-1
courses_legacy/static/js/admin/new-course/controllers.js
courses_legacy/static/js/admin/new-course/controllers.js
+2
-2
courses_legacy/static/js/markdown/app.js
courses_legacy/static/js/markdown/app.js
+7
-0
courses_legacy/static/js/markdown/directives.js
courses_legacy/static/js/markdown/directives.js
+24
-0
courses_legacy/static/js/markdown/filters.js
courses_legacy/static/js/markdown/filters.js
+11
-0
courses_legacy/static/js/pagedown/Markdown.Converter.js
courses_legacy/static/js/pagedown/Markdown.Converter.js
+1344
-0
courses_legacy/static/js/pagedown/Markdown.Editor.js
courses_legacy/static/js/pagedown/Markdown.Editor.js
+2128
-0
courses_legacy/static/js/pagedown/Markdown.Sanitizer.js
courses_legacy/static/js/pagedown/Markdown.Sanitizer.js
+111
-0
courses_legacy/templates/_course-details-inline.html
courses_legacy/templates/_course-details-inline.html
+11
-0
courses_legacy/templates/administration/lesson.html
courses_legacy/templates/administration/lesson.html
+16
-18
courses_legacy/templates/course.html
courses_legacy/templates/course.html
+15
-13
No files found.
courses_legacy/static/js/admin/courses/controllers.js
View file @
cc972f58
...
...
@@ -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
'
)
{
...
...
courses_legacy/static/js/admin/
app
/admin.lesson.app.js
→
courses_legacy/static/js/admin/
lesson
/admin.lesson.app.js
View file @
cc972f58
...
...
@@ -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
'
,
]);
...
...
courses_legacy/static/js/admin/
app/controllers
/admin.lesson.controllers.js
→
courses_legacy/static/js/admin/
lesson
/admin.lesson.controllers.js
View file @
cc972f58
...
...
@@ -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
;
...
...
courses_legacy/static/js/admin/
app/services
/admin.lesson.services.js
→
courses_legacy/static/js/admin/
lesson
/admin.lesson.services.js
View file @
cc972f58
File moved
courses_legacy/static/js/admin/new-course/app.js
View file @
cc972f58
...
...
@@ -15,6 +15,5 @@
'
youtube
'
,
'
markdown
'
,
'
ui.bootstrap
'
,
'
header
'
,
]);
})(
window
.
angular
);
courses_legacy/static/js/admin/new-course/controllers.js
View file @
cc972f58
...
...
@@ -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
;
...
...
courses_legacy/static/js/markdown/app.js
0 → 100644
View file @
cc972f58
(
function
(
angular
)
{
'
use strict
'
;
// Declare app level module which depends on filters, and services
angular
.
module
(
'
markdown
'
,
[
'
markdown.filters
'
]);
})(
angular
);
courses_legacy/static/js/markdown/directives.js
0 → 100644
View file @
cc972f58
(
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
);
courses_legacy/static/js/markdown/filters.js
0 → 100644
View file @
cc972f58
(
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
);
courses_legacy/static/js/pagedown/Markdown.Converter.js
0 → 100644
View file @
cc972f58
This diff is collapsed.
Click to expand it.
courses_legacy/static/js/pagedown/Markdown.Editor.js
0 → 100644
View file @
cc972f58
This diff is collapsed.
Click to expand it.
courses_legacy/static/js/pagedown/Markdown.Sanitizer.js
0 → 100644
View file @
cc972f58
(
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
\s
href="
(
https
?
:
(\/\/
|
\/)
|ftp:
(\/\/
|
\/)
|mailto:|magnet:
)[
-A-Za-z0-9+&@#
\/
%?=~_|!:,.;
\(\)]
+"
(\s
title="
[^
"<>
]
+"
)
+"
(\s
target="
[^
"<>
]
+"
)?\s?
>|<
\/
a>
)
$/i
;
// <img src="url..." optional width optional height optional alt optional title
var
img_white
=
/^
(
<img
\s
src="
(
https
?
:
\/\/
|
\/)[
-A-Za-z0-9+&@#
\/
%?=~_|!:,.;
\(\)]
+"
(\s
width="
\d{1,3}
"
)?(\s
height="
\d{1,3}
"
)?(\s
alt="
[^
"<>
]
*"
)?(\s
title="
[^
"<>
]
*"
)?\s?\/?
>
)
$/i
;
// <pre optional class="prettyprint linenums">|</pre> for twitter bootstrap
var
pre_white
=
/^
(
<pre
(\s
class="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
;
}
})();
courses_legacy/templates/_course-details-inline.html
0 → 100644
View file @
cc972f58
{% 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>
courses_legacy/templates/administration/lesson.html
View file @
cc972f58
...
...
@@ -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 %}
...
...
courses_legacy/templates/course.html
View file @
cc972f58
...
...
@@ -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ít
ul
o
</a>
<a
class=
"btn btn-primary btn-inverse add"
href=
"/
legacy/
admin/courses/{{ course.id }}/lessons/new"
>
Adicionar
a
ul
a
</a>
</div>
<!-- <button class="btn btn-sm btn-primary btn-inverse sort" ng-click="organizingLessons=true" ng-show="!organizingLessons" >ordenar</button> -->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment