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
bda345b3
Commit
bda345b3
authored
4 years ago
by
Fernando Ribeiro
Browse files
Options
Download
Email Patches
Plain Diff
Revert "Pagination activities discussion into develop"
This reverts commit
dc3a398b
.
parent
6e5135d4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
66 deletions
+39
-66
courses_legacy/core/serializers.py
courses_legacy/core/serializers.py
+15
-0
courses_legacy/core/views.py
courses_legacy/core/views.py
+0
-2
courses_legacy/static/js/activities/controllers.js
courses_legacy/static/js/activities/controllers.js
+17
-34
courses_legacy/static/js/lesson/services.js
courses_legacy/static/js/lesson/services.js
+0
-3
courses_legacy/static/templates/activity_discussion.html
courses_legacy/static/templates/activity_discussion.html
+6
-24
courses_legacy/urls.py
courses_legacy/urls.py
+1
-3
No files found.
courses_legacy/core/serializers.py
View file @
bda345b3
...
...
@@ -64,6 +64,21 @@ class ClassActivitySerializer(serializers.ModelSerializer):
model
=
Class
fields
=
[
'id'
,
'name'
,
'activity_answers'
,
'course'
]
def
get_activity_answers
(
self
,
obj
):
request
=
self
.
context
.
get
(
"request"
)
activity_id
=
request
.
query_params
.
get
(
'activity'
,
None
)
try
:
queryset
=
Answer
.
objects
.
filter
(
activity
=
activity_id
,
activity__unit__lesson__course
=
obj
.
course
,
user__in
=
obj
.
students
.
all
()
).
exclude
(
user
=
request
.
user
)
except
Answer
.
DoesNotExist
:
return
return
AnswerSerializer
(
queryset
,
many
=
True
,
**
{
'context'
:
self
.
context
}).
data
class
VideoSerializer
(
serializers
.
ModelSerializer
):
...
...
This diff is collapsed.
Click to expand it.
courses_legacy/core/views.py
View file @
bda345b3
...
...
@@ -18,8 +18,6 @@ from rest_framework import viewsets, mixins
from
rest_framework.response
import
Response
from
rest_framework
import
filters
from
rest_framework.permissions
import
IsAuthenticatedOrReadOnly
,
IsAuthenticated
from
rest_framework.pagination
import
PageNumberPagination
from
django_filters.rest_framework
import
DjangoFilterBackend
from
braces.views
import
LoginRequiredMixin
...
...
This diff is collapsed.
Click to expand it.
courses_legacy/static/js/activities/controllers.js
View file @
bda345b3
...
...
@@ -35,12 +35,11 @@
'
CommentLike
'
,
'
CommentFile
'
,
'
Progress
'
,
'
AnswerPage
'
,
'
ClassActivity
'
,
'
CurrentUser
'
,
'
AnswerNotification
'
,
'
ContentFile
'
,
function
(
$scope
,
$sce
,
$routeParams
,
$anchorScroll
,
$document
,
uiTinymceConfig
,
Forum
,
Topic
,
Comment
,
TopicLike
,
TopicFile
,
CommentLike
,
CommentFile
,
Progress
,
AnswerPage
,
ClassActivity
,
CurrentUser
,
AnswerNotification
,
ContentFile
)
{
function
(
$scope
,
$sce
,
$routeParams
,
$anchorScroll
,
$document
,
uiTinymceConfig
,
Forum
,
Topic
,
Comment
,
TopicLike
,
TopicFile
,
CommentLike
,
CommentFile
,
Progress
,
ClassActivity
,
CurrentUser
,
AnswerNotification
,
ContentFile
)
{
$scope
.
activity_open
=
true
;
$scope
.
activity_expired
=
false
;
var
now
=
Date
.
now
();
...
...
@@ -180,12 +179,12 @@
}
}
$scope
.
my_topic_activity
=
null
;
var
my_topic_activity
=
null
;
$scope
.
my_answer
=
true
;
// Load the given answer from other student on screen
$scope
.
viewAnswer
=
function
(
activity_topic
){
if
(
$scope
.
my_topic_activity
===
null
)
$scope
.
my_topic_activity
=
$scope
.
topic
;
if
(
my_topic_activity
===
null
)
my_topic_activity
=
$scope
.
topic
;
$scope
.
my_answer
=
false
;
$scope
.
topic
=
activity_topic
;
$scope
.
show_answer
=
true
;
...
...
@@ -200,7 +199,7 @@
};
$scope
.
viewMyAnswer
=
function
(){
$scope
.
topic
=
$scope
.
my_topic_activity
;
$scope
.
topic
=
my_topic_activity
;
$scope
.
my_answer
=
true
;
// If the user still hasn't created an answer, the editor must be reactivated too
if
(
!
$scope
.
topic
.
hasOwnProperty
(
'
id
'
)){
...
...
@@ -208,40 +207,24 @@
}
};
// Pagination Controls
$scope
.
pagination
=
{
classes_activities_pages_max
:
50
,
classes_activities_page_size
:
30
,
currentPage
:
1
,
}
// Load other students activities
$scope
.
answers_page
=
AnswerPage
.
get
({
$scope
.
classes_activities
=
ClassActivity
.
query
({
activity
:
$scope
.
currentActivity
.
id
,
course
:
$scope
.
lesson
.
course
,
ordering
:
'
-last_activity_at
'
,
exclude_cur_user
:
true
,
page
:
$scope
.
pagination
.
currentPage
,
},
function
(
response
)
{
$scope
.
activities_loaded
=
response
.
$resolved
$scope
.
activity_answers_total_items
=
response
.
count
$scope
.
answers_page_results
=
response
.
results
},
err
=>
console
.
error
(
err
)
},
function
(
response
){
// Check if there are any activities to show
var
acticvities
=
false
;
for
(
var
i
=
0
;
i
<
response
.
length
;
i
++
)
{
if
(
response
[
i
].
activity_answers
.
length
>
0
){
acticvities
=
true
;
break
;
}
}
$scope
.
activities_loaded
=
acticvities
;
}
);
$scope
.
classesActivitiesPageChanged
=
()
=>
{
$scope
.
answers_page
=
AnswerPage
.
get
({
activity
:
$scope
.
currentActivity
.
id
,
course
:
$scope
.
lesson
.
course
,
ordering
:
'
-last_activity_at
'
,
exclude_cur_user
:
true
,
page
:
$scope
.
pagination
.
currentPage
,
},
(
response
)
=>
{
$scope
.
forum_page_loaded
=
response
.
$resolved
;
$scope
.
activity_answers_total_items
=
response
.
count
$scope
.
answers_page_results
=
response
.
results
});
};
$scope
.
topic_like
=
function
(
topic
)
{
if
(
topic
.
user_like
)
{
...
...
This diff is collapsed.
Click to expand it.
courses_legacy/static/js/lesson/services.js
View file @
bda345b3
...
...
@@ -8,9 +8,6 @@
update
:
{
method
:
'
PUT
'
}
});
});
app
.
factory
(
'
AnswerPage
'
,
function
(
$resource
){
return
$resource
(
BASE_API_URL
+
'
/answer_page/
'
,
{},
{});
});
app
.
factory
(
'
Progress
'
,
[
'
$resource
'
,
function
(
$resource
){
var
Progress
=
$resource
(
BASE_API_URL
+
'
/student_progress/:unit
'
,
{},
{
...
...
This diff is collapsed.
Click to expand it.
courses_legacy/static/templates/activity_discussion.html
View file @
bda345b3
...
...
@@ -147,7 +147,7 @@
</form>
</div>
<!-- /Novo comentário -->
<div
class=
"comments"
ng-if=
"topic.comments.length > 0"
>
<div
class=
"comments"
>
<h3
class=
"comments-title"
>
Comentários
</h3>
<!-- Exibição de um comentário -->
<div
class=
"thread"
ng-repeat=
"comment in topic.comments"
>
...
...
@@ -289,13 +289,13 @@
<thead>
<tr>
<th>
autor
</th>
<!--
<th>turma</th>
-->
<th>
turma
</th>
<th>
atividade
</th>
<th>
reações
</th>
</tr>
</thead>
<tbody
ng-
if=
"activities_loaded"
>
<tr
class=
"new"
ng-repeat=
"answer in
answers_page_result
s"
>
<tbody
ng-
repeat=
"course_class in classes_activities"
>
<tr
class=
"new"
ng-repeat=
"answer in
course_class.activity_answer
s"
>
<td>
<div
class=
"user-icon"
>
<img
ng-src=
"{{ answer.topic.author.image || '/static/img/avatar-default.png'}}"
alt=
"{{answer.topic.author.name}}"
>
...
...
@@ -305,32 +305,14 @@
<a
ng-click=
"viewAnswer(answer.topic)"
><span
class=
"user-name"
>
{{answer.topic.author.name}}
</span></a>
</div>
</td>
<!--
<td><b>{{course_class.name}}</b></td>
-->
<td><b>
{{course_class.name}}
</b></td>
<td>
Última atividade
<b>
{{answer.topic.last_activity_at | date : 'dd/MM/yyyy' }}
</b></td>
<td>
<span
class=
"action liked"
>
{{ answer.topic.count_likes }} curtiram
</span>
<br/>
<!-- <span class="action liked">{{ activity.count_likes }} curtiram</span> -->
<span
class=
"action replies"
>
{{ answer.topic.count_replies }} comentaram
</span>
</td>
</tr>
</tbody>
</table>
<div
ng-show=
"activities_loaded"
class=
"pagination-wrapper"
>
<!-- Small screens -->
<ul
uib-pagination
boundary-links=
"true"
total-items=
"activity_answers_total_items"
ng-model=
"pagination.currentPage"
max-size=
"3"
items-per-page=
"pagination.classes_activities_page_size"
ng-change=
"classesActivitiesPageChanged()"
class=
"pagination pagination-sm"
previous-text=
"‹"
next-text=
"›"
first-text=
"«"
last-text=
"»"
></ul>
<!-- Medium screens -->
<ul
uib-pagination
boundary-links=
"true"
total-items=
"activity_answers_total_items"
ng-model=
"pagination.currentPage"
force-ellipses=
"false"
max-size=
"5"
items-per-page=
"pagination.classes_activities_page_size"
ng-change=
"classesActivitiesPageChanged()"
class=
"pagination pagination-md"
previous-text=
"‹"
next-text=
"›"
first-text=
"primeira"
last-text=
"última"
></ul>
<!-- Large screens -->
<ul
uib-pagination
boundary-links=
"true"
total-items=
"activity_answers_total_items"
ng-model=
"pagination.currentPage"
force-ellipses=
"false"
max-size=
"10"
items-per-page=
"pagination.classes_activities_page_size"
ng-change=
"classesActivitiesPageChanged()"
class=
"pagination pagination-lg"
previous-text=
"‹"
next-text=
"›"
first-text=
"primeira"
last-text=
"última"
></ul>
</div>
</div>
</div>
This diff is collapsed.
Click to expand it.
courses_legacy/urls.py
View file @
bda345b3
...
...
@@ -28,7 +28,7 @@ from .core.views import (CourseView, GenericCourseView,
RequestCertificateView
,
EmitReceiptView
,
ProfileViewSet
,
)
from
.activities.views
import
AnswerViewSet
,
AnswerPageViewSet
,
ActivityImageViewSet
,
SlidesRevealView
from
.activities.views
import
AnswerViewSet
,
ActivityImageViewSet
,
SlidesRevealView
from
.course_material.views
import
CourseMaterialView
,
FileUploadView
from
.notes.views
import
NotesViewSet
,
CourseNotesView
,
UserNotesView
from
.reports.views
import
(
UserCourseStats
,
CourseStatsByLessonViewSet
,
UserCourseLessonsStats
,
GeneralReportsView
,
)
...
...
@@ -85,8 +85,6 @@ router.register(r'lessons', LessonViewSet, base_name='lessons')
router
.
register
(
r
'simple_lessons'
,
SimpleLessonViewSet
,
base_name
=
'simple_lessons'
)
router
.
register
(
r
'unit'
,
UnitViewSet
,
base_name
=
'unit'
)
router
.
register
(
r
'answer'
,
AnswerViewSet
,
base_name
=
'answer'
)
router
.
register
(
r
'answer_page'
,
AnswerPageViewSet
,
base_name
=
'answer'
)
router
.
register
(
r
'activity_image'
,
ActivityImageViewSet
,
base_name
=
'activity_image'
)
router
.
register
(
r
'student_progress'
,
StudentProgressViewSet
,
base_name
=
'student_progress'
)
...
...
This diff is collapsed.
Click to expand it.
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