Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
1185fff1
Commit
1185fff1
authored
Mar 29, 2016
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added pacing field Course API
ECOM-3994
parent
84e88eba
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
2 deletions
+54
-2
lms/djangoapps/course_api/serializers.py
+1
-0
lms/djangoapps/course_api/tests/test_serializers.py
+14
-0
lms/djangoapps/course_api/views.py
+3
-1
openedx/core/djangoapps/content/course_overviews/migrations/0010_auto_20160329_2317.py
+23
-0
openedx/core/djangoapps/content/course_overviews/models.py
+13
-1
No files found.
lms/djangoapps/course_api/serializers.py
View file @
1185fff1
...
...
@@ -55,6 +55,7 @@ class CourseSerializer(serializers.Serializer): # pylint: disable=abstract-meth
start
=
serializers
.
DateTimeField
()
start_display
=
serializers
.
CharField
()
start_type
=
serializers
.
CharField
()
pacing
=
serializers
.
CharField
()
# 'course_id' is a deprecated field, please use 'id' instead.
course_id
=
serializers
.
CharField
(
source
=
'id'
,
read_only
=
True
)
...
...
lms/djangoapps/course_api/tests/test_serializers.py
View file @
1185fff1
...
...
@@ -2,8 +2,10 @@
Test data created by CourseSerializer and CourseDetailSerializer
"""
from
__future__
import
unicode_literals
from
datetime
import
datetime
import
ddt
from
openedx.core.djangoapps.models.course_details
import
CourseDetails
from
openedx.core.djangoapps.content.course_overviews.models
import
CourseOverview
from
rest_framework.test
import
APIRequestFactory
...
...
@@ -18,6 +20,7 @@ from ..serializers import CourseSerializer, CourseDetailSerializer
from
.mixins
import
CourseApiFactoryMixin
@ddt.ddt
class
TestCourseSerializer
(
CourseApiFactoryMixin
,
ModuleStoreTestCase
):
"""
Test CourseSerializer
...
...
@@ -54,6 +57,7 @@ class TestCourseSerializer(CourseApiFactoryMixin, ModuleStoreTestCase):
'enrollment_end'
:
u'2015-07-15T00:00:00Z'
,
'blocks_url'
:
u'http://testserver/api/courses/v1/blocks/?course_id=edX
%2
Ftoy
%2
F2012_Fall'
,
'effort'
:
u'6 hours'
,
'pacing'
:
'instructor'
,
# 'course_id' is a deprecated field, please use 'id' instead.
'course_id'
:
u'edX/toy/2012_Fall'
,
...
...
@@ -101,6 +105,16 @@ class TestCourseSerializer(CourseApiFactoryMixin, ModuleStoreTestCase):
self
.
assertEqual
(
result
[
'start_type'
],
u'empty'
)
self
.
assertIsNone
(
result
[
'start_display'
])
@ddt.unpack
@ddt.data
(
(
True
,
'self'
),
(
False
,
'instructor'
),
)
def
test_pacing
(
self
,
self_paced
,
expected_pacing
):
course
=
self
.
create_course
(
self_paced
=
self_paced
)
result
=
self
.
_get_result
(
course
)
self
.
assertEqual
(
result
[
'pacing'
],
expected_pacing
)
class
TestCourseDetailSerializer
(
TestCourseSerializer
):
# pylint: disable=test-inherits-tests
"""
...
...
lms/djangoapps/course_api/views.py
View file @
1185fff1
...
...
@@ -52,6 +52,7 @@ class CourseDetailView(DeveloperErrorViewMixin, RetrieveAPIView):
* `"string"`: manually set
* `"timestamp"`: generated form `start` timestamp
* `"empty"`: the start date should not be shown
* pacing: Course pacing. Possible values: instructor, self
Deprecated fields:
...
...
@@ -94,7 +95,8 @@ class CourseDetailView(DeveloperErrorViewMixin, RetrieveAPIView):
"overview: "<p>A verbose description of the course.</p>"
"start": "2015-07-17T12:00:00Z",
"start_display": "July 17, 2015",
"start_type": "timestamp"
"start_type": "timestamp",
"pacing": "instructor"
}
"""
...
...
openedx/core/djangoapps/content/course_overviews/migrations/0010_auto_20160329_2317.py
0 → 100644
View file @
1185fff1
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'course_overviews'
,
'0009_readd_facebook_url'
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
'courseoverview'
,
name
=
'facebook_url'
,
),
migrations
.
AddField
(
model_name
=
'courseoverview'
,
name
=
'self_paced'
,
field
=
models
.
BooleanField
(
default
=
False
),
),
]
openedx/core/djangoapps/content/course_overviews/models.py
View file @
1185fff1
...
...
@@ -45,7 +45,7 @@ class CourseOverview(TimeStampedModel):
app_label
=
'course_overviews'
# IMPORTANT: Bump this whenever you modify this model and/or add a migration.
VERSION
=
3
VERSION
=
4
# Cache entry versioning.
version
=
IntegerField
()
...
...
@@ -98,6 +98,7 @@ class CourseOverview(TimeStampedModel):
short_description
=
TextField
(
null
=
True
)
course_video_url
=
TextField
(
null
=
True
)
effort
=
TextField
(
null
=
True
)
self_paced
=
BooleanField
(
default
=
False
)
@classmethod
def
_create_from_course
(
cls
,
course
):
...
...
@@ -181,6 +182,7 @@ class CourseOverview(TimeStampedModel):
short_description
=
CourseDetails
.
fetch_about_attribute
(
course
.
id
,
'short_description'
),
effort
=
CourseDetails
.
fetch_about_attribute
(
course
.
id
,
'effort'
),
course_video_url
=
CourseDetails
.
fetch_video_url
(
course
.
id
),
self_paced
=
course
.
self_paced
,
)
@classmethod
...
...
@@ -551,6 +553,16 @@ class CourseOverview(TimeStampedModel):
return
self
.
apply_cdn_to_urls
(
urls
)
@property
def
pacing
(
self
):
""" Returns the pacing for the course.
Potential values:
self: Self-paced courses
instructor: Instructor-led courses
"""
return
'self'
if
self
.
self_paced
else
'instructor'
def
apply_cdn_to_urls
(
self
,
image_urls
):
"""
Given a dict of resolutions -> urls, return a copy with CDN applied.
...
...
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