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
Commits
4b58ca30
Commit
4b58ca30
authored
Nov 20, 2020
by
Matheus Miranda
Browse files
Add config for logging Card access
parent
1e1d94a1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
9 deletions
+24
-9
courses/stats/apps.py
courses/stats/apps.py
+1
-0
courses/stats/serializers.py
courses/stats/serializers.py
+16
-9
courses/stats/views.py
courses/stats/views.py
+7
-0
No files found.
courses/stats/apps.py
View file @
4b58ca30
...
@@ -14,3 +14,4 @@ class CoursesStatsConfig(AppConfig):
...
@@ -14,3 +14,4 @@ class CoursesStatsConfig(AppConfig):
registry
.
register
(
'stats.AccessibleArea'
)
registry
.
register
(
'stats.AccessibleArea'
)
registry
.
register
(
'discussion.Topic'
)
registry
.
register
(
'discussion.Topic'
)
registry
.
register
(
'discussion.Forum'
)
registry
.
register
(
'discussion.Forum'
)
registry
.
register
(
'cards.Card'
)
courses/stats/serializers.py
View file @
4b58ca30
...
@@ -14,6 +14,8 @@ from courses.classroom.serializers import BasicClassroomSerializer
...
@@ -14,6 +14,8 @@ from courses.classroom.serializers import BasicClassroomSerializer
from
discussion.models
import
Comment
,
Topic
,
Forum
from
discussion.models
import
Comment
,
Topic
,
Forum
from
cards.models
import
Card
from
courses_learning_objects.models
import
LearningObject
,
Answer
from
courses_learning_objects.models
import
LearningObject
,
Answer
from
datetime
import
datetime
from
datetime
import
datetime
...
@@ -65,8 +67,8 @@ class ActionSerializer(serializers.ModelSerializer):
...
@@ -65,8 +67,8 @@ class ActionSerializer(serializers.ModelSerializer):
date
,
hour
=
tz_str
.
strftime
(
'%d-%m-%Y %H:%M:%S'
).
split
()
date
,
hour
=
tz_str
.
strftime
(
'%d-%m-%Y %H:%M:%S'
).
split
()
return
'{} às {}'
.
format
(
date
,
hour
)
return
'{} às {}'
.
format
(
date
,
hour
)
def
get_accesible_area_name
(
self
,
name
):
def
get_acces
s
ible_area_name
(
self
,
name
):
accesible_areas
=
{
acces
s
ible_areas
=
{
'Dashboard'
:
'a Página Inicial'
,
'Dashboard'
:
'a Página Inicial'
,
'Chat Main Page'
:
'os Chats'
,
'Chat Main Page'
:
'os Chats'
,
'Profile Page'
:
'a Página de perfil'
,
'Profile Page'
:
'a Página de perfil'
,
...
@@ -75,25 +77,30 @@ class ActionSerializer(serializers.ModelSerializer):
...
@@ -75,25 +77,30 @@ class ActionSerializer(serializers.ModelSerializer):
'Courses'
:
'a Lista de Espaços Formativos'
,
'Courses'
:
'a Lista de Espaços Formativos'
,
'Messages'
:
'os Avisos'
,
'Messages'
:
'os Avisos'
,
'Forums'
:
'os Fóruns'
,
'Forums'
:
'os Fóruns'
,
'Cards List'
:
'a Lista de Conteúdos'
}
}
return
accesible_areas
.
get
(
name
,
name
)
return
acces
s
ible_areas
.
get
(
name
,
name
)
def
get_object_type
(
self
,
obj
):
def
get_object_type
(
self
,
obj
):
if
isinstance
(
obj
,
Course
):
if
isinstance
(
obj
,
Course
):
return
' no curso
'
+
obj
.
name
return
' no curso
{}'
.
format
(
obj
.
name
)
if
isinstance
(
obj
,
Classroom
):
if
isinstance
(
obj
,
Classroom
):
return
' na sala
'
+
obj
.
name
return
' na sala
{}'
.
format
(
obj
.
name
)
if
isinstance
(
obj
,
Topic
):
if
isinstance
(
obj
,
Topic
):
return
' no tópico
'
+
obj
.
title
return
' no tópico
{}'
.
format
(
obj
.
title
)
if
isinstance
(
obj
,
Forum
):
if
isinstance
(
obj
,
Forum
):
return
' no fórum
'
+
obj
.
title
return
' no fórum
{}'
.
format
(
obj
.
title
)
if
isinstance
(
obj
,
AccessibleArea
):
if
isinstance
(
obj
,
AccessibleArea
):
return
'
'
+
self
.
get_accesible_area_name
(
obj
.
name
)
return
'
{}'
.
format
(
self
.
get_acces
s
ible_area_name
(
obj
.
name
)
)
if
isinstance
(
obj
,
LearningObject
):
if
isinstance
(
obj
,
LearningObject
):
unit
=
obj
.
unit
.
title
unit
=
obj
.
unit
.
title
step
=
obj
.
unit
.
lesson
.
name
step
=
obj
.
unit
.
lesson
.
name
course
=
obj
.
unit
.
lesson
.
course
.
name
course
=
obj
.
unit
.
lesson
.
course
.
name
return
' a atividade {} na etapa {} do curso {}'
.
format
(
unit
,
step
,
course
)
return
' a atividade {} na etapa {} do curso {}'
.
format
(
unit
,
step
,
course
)
if
isinstance
(
obj
,
Card
):
title
=
obj
.
title
group_name
=
obj
.
groups
.
first
().
name
return
' o conteúdo {} na {}'
.
format
(
title
,
group_name
)
return
''
return
''
def
get_action_phrase
(
self
,
obj
):
def
get_action_phrase
(
self
,
obj
):
...
@@ -108,7 +115,7 @@ class ActionSerializer(serializers.ModelSerializer):
...
@@ -108,7 +115,7 @@ class ActionSerializer(serializers.ModelSerializer):
action_phrase
=
''
action_phrase
=
''
action_phrase
+=
obj
.
actor
.
name
.
split
()[
0
]
action_phrase
+=
obj
.
actor
.
name
.
split
()[
0
]
action_phrase
+=
(
'
'
+
verbs
.
get
(
obj
.
verb
))
action_phrase
+=
(
'
{}'
.
format
(
verbs
.
get
(
obj
.
verb
))
)
if
obj
.
action_object
:
if
obj
.
action_object
:
action_phrase
+=
self
.
get_object_type
(
obj
.
action_object
)
action_phrase
+=
self
.
get_object_type
(
obj
.
action_object
)
...
...
courses/stats/views.py
View file @
4b58ca30
...
@@ -12,6 +12,10 @@ from .models import AccessibleArea
...
@@ -12,6 +12,10 @@ from .models import AccessibleArea
from
..models
import
Course
from
..models
import
Course
from
..classroom.models
import
Classroom
from
..classroom.models
import
Classroom
from
cards.models
import
Card
from
courses_learning_objects.models
import
LearningObject
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.contrib.auth
import
get_user_model
from
django.contrib.auth
import
get_user_model
...
@@ -28,6 +32,9 @@ class UserActionsView(views.APIView):
...
@@ -28,6 +32,9 @@ class UserActionsView(views.APIView):
'Classroom'
:
Classroom
,
'Classroom'
:
Classroom
,
'Topic'
:
Topic
,
'Topic'
:
Topic
,
'Forum'
:
Forum
,
'Forum'
:
Forum
,
'AccessibleArea'
:
AccessibleArea
,
'LearningObject'
:
LearningObject
,
'Card'
:
Card
,
}
}
# Validate incoming data
# Validate incoming data
...
...
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