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
bd115f3d
Commit
bd115f3d
authored
Jul 06, 2012
by
Matthew Mongeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
workarounds for get_about_section
parent
2a6a894c
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
168 deletions
+63
-168
common/lib/xmodule/xmodule/modulestore/xml.py
+3
-1
lms/djangoapps/courseware/courses.py
+25
-0
lms/djangoapps/courseware/views.py
+6
-3
lms/djangoapps/student/views.py
+3
-2
lms/envs/common.py
+6
-0
lms/envs/dev.py
+1
-1
lms/templates/course.html
+2
-153
lms/urls.py
+17
-8
No files found.
common/lib/xmodule/xmodule/modulestore/xml.py
View file @
bd115f3d
import
logging
from
django.conf
import
settings
from
fs.osfs
import
OSFS
from
importlib
import
import_module
from
lxml
import
etree
...
...
@@ -128,7 +129,8 @@ class XMLModuleStore(ModuleStore):
"""
Returns a list of course descriptors
"""
return
self
.
courses
# return self.courses
return
settings
.
COURSES
def
create_item
(
self
,
location
):
raise
NotImplementedError
(
"XMLModuleStores are read-only"
)
...
...
lms/djangoapps/courseware/courses.py
View file @
bd115f3d
...
...
@@ -27,6 +27,31 @@ class Course(namedtuple('Course', _FIELDS)):
"""Course objects encapsulate general information about a given run of a
course. This includes things like name, grading policy, etc.
"""
@property
def
id
(
self
):
return
"{0.institution},{0.number},{0.run_id}"
.
format
(
self
)
.
replace
(
" "
,
"_"
)
def
get_about_section
(
self
,
section
):
if
section
==
"university"
:
section
=
"institution"
if
section
in
_FIELDS
:
getattr
(
self
,
section
)
else
:
return
section
@classmethod
def
load_from_path
(
cls
,
course_path
):
course_path
=
path
(
course_path
)
# convert it from string if necessary
try
:
with
open
(
course_path
/
"course_info.yaml"
)
as
course_info_file
:
course_info
=
yaml
.
load
(
course_info_file
)
summary
=
course_info
[
'course'
]
summary
.
update
(
path
=
course_path
,
grader
=
None
)
return
cls
(
**
summary
)
except
Exception
as
ex
:
log
.
exception
(
ex
)
raise
CourseInfoLoadError
(
"Could not read course info: {0}:{1}"
.
format
(
type
(
ex
)
.
__name__
,
ex
))
def
load_courses
(
courses_path
):
"""Given a directory of courses, returns a list of Course objects. For the
...
...
lms/djangoapps/courseware/views.py
View file @
bd115f3d
...
...
@@ -54,7 +54,9 @@ def format_url_params(params):
def
courses
(
request
):
csrf_token
=
csrf
(
request
)[
'csrf_token'
]
# TODO: Clean up how 'error' is done.
context
=
{
'courses'
:
modulestore
()
.
get_courses
(),
# context = {'courses': modulestore().get_courses(),
# 'csrf': csrf_token}
context
=
{
'courses'
:
settings
.
COURSES
,
'csrf'
:
csrf_token
}
return
render_to_response
(
"courses.html"
,
context
)
...
...
@@ -252,8 +254,9 @@ def course_info(request, course_id):
csrf_token
=
csrf
(
request
)[
'csrf_token'
]
try
:
course_location
=
CourseDescriptor
.
id_to_location
(
course_id
)
course
=
modulestore
()
.
get_item
(
course_location
)
# course_location = CourseDescriptor.id_to_location(course_id)
# course = modulestore().get_item(course_location)
course
=
settings
.
COURSES_BY_ID
[
course_id
]
except
KeyError
:
raise
Http404
(
"Course not found"
)
...
...
lms/djangoapps/student/views.py
View file @
bd115f3d
...
...
@@ -491,8 +491,9 @@ def accept_name_change(request):
def
course_info
(
request
,
course_id
):
# This is the advertising page for a student to look at the course before signing up
csrf_token
=
csrf
(
request
)[
'csrf_token'
]
course_loc
=
CourseDescriptor
.
id_to_location
(
course_id
)
course
=
modulestore
()
.
get_item
(
course_loc
)
# course_loc = CourseDescriptor.id_to_location(course_id)
# course = modulestore().get_item(course_loc)
course
=
settings
.
COURSES_BY_ID
[
course_id
]
# TODO: Couse should be a model
return
render_to_response
(
'portal/course_about.html'
,
{
'csrf'
:
csrf_token
,
'course'
:
course
})
...
...
lms/envs/common.py
View file @
bd115f3d
...
...
@@ -64,6 +64,12 @@ sys.path.append(PROJECT_ROOT / 'lib')
sys
.
path
.
append
(
COMMON_ROOT
/
'djangoapps'
)
sys
.
path
.
append
(
COMMON_ROOT
/
'lib'
)
######### EDX dormsbee/portal changes #################
from
courseware.courses
import
create_lookup_table
,
load_courses
COURSES
=
load_courses
(
ENV_ROOT
/
"data"
)
COURSES_BY_ID
=
create_lookup_table
(
COURSES
)
#######################################################
################################## MITXWEB #####################################
# This is where we stick our compiled template files. Most of the app uses Mako
# templates
...
...
lms/envs/dev.py
View file @
bd115f3d
...
...
@@ -11,7 +11,7 @@ from .common import *
from
.logsettings
import
get_logger_config
DEBUG
=
True
TEMPLATE_DEBUG
=
Fals
e
TEMPLATE_DEBUG
=
Tru
e
LOGGING
=
get_logger_config
(
ENV_ROOT
/
"log"
,
logging_env
=
"dev"
,
...
...
lms/templates/course.html
View file @
bd115f3d
...
...
@@ -2,8 +2,8 @@
<
%!
from
django
.
core
.
urlresolvers
import
reverse
%
>
<
%
page
args=
"course"
/>
%for course in courses:
<article
id=
"${course.id}"
class=
"course"
>
<div
class=
"inner-wrapper"
>
<header
class=
"course-preview"
>
...
...
@@ -20,158 +20,7 @@
<p
class=
"dates"
><span
class=
"start"
>
7/23/12
</span>
→
<span
class=
"end"
>
12/15/12
</span></p>
</div>
<div
class=
"cover-image"
>
<img
src=
"${static.url('images/courses/history.png')}"
>
</div>
<div
class=
"desc"
>
<p>
An advanced introduction to analog circuits.
</p>
</div>
</section>
</div>
</article>
%endfor
<article
id=
"${course.id}"
class=
"course"
>
<div
class=
"inner-wrapper"
>
<header
class=
"course-preview"
>
<a
href=
"${reverse('about_course', args=[course.id])}"
>
<hgroup>
<h2>
${course.title}
</h2>
</hgroup>
<div
class=
"info-link"
>
➔
</div>
</a>
</header>
<section
class=
"info"
>
<div
class=
"meta-info"
>
<p
class=
"university"
>
${course.institution}
</p>
<p
class=
"dates"
><span
class=
"start"
>
7/23/12
</span>
→
<span
class=
"end"
>
12/15/12
</span></p>
</div>
<div
class=
"cover-image"
>
<img
src=
"${static.url('images/courses/math.png')}"
>
</div>
<div
class=
"desc"
>
<p>
An advanced introduction to analog circuits.
</p>
</div>
</section>
</div>
</article>
<article
id=
"${course.id}"
class=
"course"
>
<div
class=
"inner-wrapper"
>
<header
class=
"course-preview"
>
<a
href=
"${reverse('about_course', args=[course.id])}"
>
<hgroup>
<h2>
${course.title}
</h2>
</hgroup>
<div
class=
"info-link"
>
➔
</div>
</a>
</header>
<section
class=
"info"
>
<div
class=
"meta-info"
>
<p
class=
"university"
>
${course.institution}
</p>
<p
class=
"dates"
><span
class=
"start"
>
7/23/12
</span>
→
<span
class=
"end"
>
12/15/12
</span></p>
</div>
<div
class=
"cover-image"
>
<img
src=
"${static.url('images/courses/python.png')}"
>
</div>
<div
class=
"desc"
>
<p>
An advanced introduction to analog circuits.
</p>
</div>
</section>
</div>
</article>
<article
id=
"${course.id}"
class=
"course"
>
<div
class=
"inner-wrapper"
>
<header
class=
"course-preview"
>
<a
href=
"${reverse('about_course', args=[course.id])}"
>
<hgroup>
<h2>
${course.title}
</h2>
</hgroup>
<div
class=
"info-link"
>
➔
</div>
</a>
</header>
<section
class=
"info"
>
<div
class=
"meta-info"
>
<p
class=
"university"
>
${course.institution}
</p>
<p
class=
"dates"
><span
class=
"start"
>
7/23/12
</span>
→
<span
class=
"end"
>
12/15/12
</span></p>
</div>
<div
class=
"cover-image"
>
<img
src=
"${static.url('images/courses/space1.jpg')}"
>
</div>
<div
class=
"desc"
>
<p>
An advanced introduction to analog circuits.
</p>
</div>
</section>
</div>
</article>
<article
id=
"${course.id}"
class=
"course"
>
<div
class=
"inner-wrapper"
>
<header
class=
"course-preview"
>
<a
href=
"${reverse('about_course', args=[course.id])}"
>
<hgroup>
<h2>
${course.title}
</h2>
</hgroup>
<div
class=
"info-link"
>
➔
</div>
</a>
</header>
<section
class=
"info"
>
<div
class=
"meta-info"
>
<p
class=
"university"
>
${course.institution}
</p>
<p
class=
"dates"
><span
class=
"start"
>
7/23/12
</span>
→
<span
class=
"end"
>
12/15/12
</span></p>
</div>
<div
class=
"cover-image"
>
<img
src=
"${static.url('images/courses/space2.jpg')}"
>
</div>
<div
class=
"desc"
>
<p>
An advanced introduction to analog circuits.
</p>
</div>
</section>
</div>
</article>
<article
id=
"${course.id}"
class=
"course"
>
<div
class=
"inner-wrapper"
>
<header
class=
"course-preview"
>
<a
href=
"${reverse('about_course', args=[course.id])}"
>
<hgroup>
<h2>
${course.title}
</h2>
</hgroup>
<div
class=
"info-link"
>
➔
</div>
</a>
</header>
<section
class=
"info"
>
<div
class=
"meta-info"
>
<p
class=
"university"
>
${course.institution}
</p>
<p
class=
"dates"
><span
class=
"start"
>
7/23/12
</span>
→
<span
class=
"end"
>
12/15/12
</span></p>
</div>
<div
class=
"cover-image"
>
<img
src=
"${static.url('images/courses/space4.jpg')}"
>
</div>
<div
class=
"desc"
>
<p>
An advanced introduction to analog circuits.
</p>
</div>
</section>
</div>
</article>
<article
id=
"${course.id}"
class=
"course"
>
<div
class=
"inner-wrapper"
>
<header
class=
"course-preview"
>
<a
href=
"${reverse('about_course', args=[course.id])}"
>
<hgroup>
<h2>
${course.title}
</h2>
</hgroup>
<div
class=
"info-link"
>
➔
</div>
</a>
</header>
<section
class=
"info"
>
<div
class=
"meta-info"
>
<p
class=
"university"
>
${course.institution}
</p>
<p
class=
"dates"
><span
class=
"start"
>
7/23/12
</span>
→
<span
class=
"end"
>
12/15/12
</span></p>
</div>
<div
class=
"cover-image"
>
<img
src=
"${static.url('images/courses/space3.jpg')}"
>
<img
src=
"${static.url('images/courses/circuits.jpeg')}"
>
</div>
<div
class=
"desc"
>
<p>
An advanced introduction to analog circuits.
</p>
...
...
lms/urls.py
View file @
bd115f3d
...
...
@@ -69,15 +69,24 @@ if settings.COURSEWARE_ENABLED:
# Multicourse related:
url
(
r'^courses/?$'
,
'courseware.views.courses'
,
name
=
"courses"
),
url
(
r'^courses/(?P<course_id>[^/]
+/[^/]+/[^/]
)/info$'
,
'courseware.views.course_info'
,
name
=
"info"
),
url
(
r'^courses/(?P<course_id>[^/]
+/[^/]+/[^/]
)/book$'
,
'staticbook.views.index'
,
name
=
"book"
),
url
(
r'^courses/(?P<course_id>[^/]
+/[^/]+/[^/]
)/enroll$'
,
'student.views.enroll'
,
name
=
"enroll"
),
url
(
r'^courses/(?P<course_id>[^/]
+/[^/]+/[^/]
)/courseware/?$'
,
'courseware.views.index'
,
name
=
"courseware"
),
url
(
r'^courses/(?P<course_id>[^/]
+/[^/]+/[^/]
)/courseware/(?P<chapter>[^/]*)/(?P<section>[^/]*)/$'
,
'courseware.views.index'
,
name
=
"courseware_section"
),
url
(
r'^courses/(?P<course_id>[^/]
+/[^/]+/[^/]
)/profile$'
,
'courseware.views.profile'
,
name
=
"profile"
),
url
(
r'^courses/(?P<course_id>[^/]
+/[^/]+/[^/]
)/profile/(?P<student_id>[^/]*)/$'
,
'courseware.views.profile'
),
url
(
r'^courses/(?P<course_id>[^/]
*
)/info$'
,
'courseware.views.course_info'
,
name
=
"info"
),
url
(
r'^courses/(?P<course_id>[^/]
*
)/book$'
,
'staticbook.views.index'
,
name
=
"book"
),
url
(
r'^courses/(?P<course_id>[^/]
*
)/enroll$'
,
'student.views.enroll'
,
name
=
"enroll"
),
url
(
r'^courses/(?P<course_id>[^/]
*
)/courseware/?$'
,
'courseware.views.index'
,
name
=
"courseware"
),
url
(
r'^courses/(?P<course_id>[^/]
*
)/courseware/(?P<chapter>[^/]*)/(?P<section>[^/]*)/$'
,
'courseware.views.index'
,
name
=
"courseware_section"
),
url
(
r'^courses/(?P<course_id>[^/]
*
)/profile$'
,
'courseware.views.profile'
,
name
=
"profile"
),
url
(
r'^courses/(?P<course_id>[^/]
*
)/profile/(?P<student_id>[^/]*)/$'
,
'courseware.views.profile'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/])/about$'
,
'courseware.views.course_info'
,
name
=
"about_course"
),
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/])/info$', 'courseware.views.course_info', name="info"),
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/])/book$', 'staticbook.views.index', name="book"),
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/])/enroll$', 'student.views.enroll', name="enroll"),
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/])/courseware/?$', 'courseware.views.index', name="courseware"),
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/])/courseware/(?P<chapter>[^/]*)/(?P<section>[^/]*)/$', 'courseware.views.index', name="courseware_section"),
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/])/profile$', 'courseware.views.profile', name="profile"),
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/])/profile/(?P<student_id>[^/]*)/$', 'courseware.views.profile'),
url
(
r'^courses/(?P<course_id>[^/]*)/about$'
,
'student.views.course_info'
,
name
=
"about_course"
),
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/])/about$', 'courseware.views.course_info', name="about_course"),
)
if
settings
.
ENABLE_MULTICOURSE
:
...
...
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