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
e8f8d435
Commit
e8f8d435
authored
May 14, 2012
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified to work with preview in CMS; non-stable for use as LMS (need to change directory refs)
parent
04f63c16
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
13 deletions
+35
-13
djangoapps/courseware/capa/capa_problem.py
+6
-5
djangoapps/courseware/module_render.py
+2
-1
djangoapps/courseware/modules/__init__.py
+0
-2
djangoapps/courseware/modules/capa_module.py
+1
-1
djangoapps/courseware/modules/template_module.py
+8
-4
djangoapps/courseware/modules/x_module.py
+18
-0
No files found.
djangoapps/courseware/capa/capa_problem.py
View file @
e8f8d435
...
...
@@ -72,12 +72,12 @@ html_skip = ["numericalresponse", "customresponse", "schematicresponse", "formul
# removed in MC
## These should be transformed
html_special_response
=
{
"textline"
:
inputtypes
.
textline
.
render
,
"schematic"
:
inputtypes
.
schematic
.
render
,
"textbox"
:
inputtypes
.
textbox
.
render
,
"formulainput"
:
inputtypes
.
jstextline
.
render
,
#
html_special_response = {"textline":inputtypes.textline.render,
#
"schematic":inputtypes.schematic.render,
#
"textbox":inputtypes.textbox.render,
#
"formulainput":inputtypes.jstextline.render,
# "solution":inputtypes.solution.render,
}
#
}
class
LoncapaProblem
(
object
):
def
__init__
(
self
,
fileobject
,
id
,
state
=
None
,
seed
=
None
,
system
=
None
):
...
...
@@ -280,6 +280,7 @@ class LoncapaProblem(object):
'''
response_id
=
1
for
response
in
tree
.
xpath
(
'//'
+
"|//"
.
join
(
response_types
)):
print
self
.
problem_id
response_id_str
=
self
.
problem_id
+
"_"
+
str
(
response_id
)
response
.
attrib
[
'id'
]
=
response_id_str
if
response_id
not
in
correct_map
:
...
...
djangoapps/courseware/module_render.py
View file @
e8f8d435
...
...
@@ -15,7 +15,6 @@ from mitxmako.shortcuts import render_to_string
from
models
import
StudentModule
import
track.views
import
courseware.modules
...
...
@@ -47,6 +46,8 @@ def make_track_function(request):
tracking function to them. This generates a closure for each request
that gives a clean interface on both sides.
'''
import
track.views
def
f
(
event_type
,
event
):
return
track
.
views
.
server_track
(
request
,
event_type
,
event
,
page
=
'x_module'
)
return
f
...
...
djangoapps/courseware/modules/__init__.py
View file @
e8f8d435
import
os
import
os.path
from
django.conf
import
settings
import
capa_module
import
html_module
import
schematic_module
...
...
djangoapps/courseware/modules/capa_module.py
View file @
e8f8d435
...
...
@@ -186,7 +186,7 @@ class Module(XModule):
if
state
!=
None
and
'attempts'
in
state
:
self
.
attempts
=
state
[
'attempts'
]
self
.
filename
=
"problems/"
+
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@filename'
))
+
".xml"
self
.
filename
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@filename'
))
#
"problems/"+content_parser.item(dom2.xpath('/problem/@filename'))+".xml"
self
.
name
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@name'
))
self
.
weight
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@weight'
))
if
self
.
rerandomize
==
'never'
:
...
...
djangoapps/courseware/modules/template_module.py
View file @
e8f8d435
import
json
import
os
## TODO: Abstract out from Django
from
django.conf
import
settings
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
x_module
import
XModule
...
...
@@ -14,8 +12,14 @@ class Module(XModule):
@classmethod
def
get_xml_tags
(
c
):
## TODO: Abstract out from filesystem
tags
=
os
.
listdir
(
settings
.
DATA_DIR
+
'/custom_tags'
)
## TODO: Abstract out from filesystem and Django
## HACK: For now, this lets us import without abstracting out
try
:
from
django.conf
import
settings
tags
=
os
.
listdir
(
settings
.
DATA_DIR
+
'/custom_tags'
)
except
:
print
"Could not open tags directory."
tags
=
[]
return
tags
def
get_html
(
self
):
...
...
djangoapps/courseware/modules/x_module.py
View file @
e8f8d435
...
...
@@ -7,6 +7,8 @@ class XModule(object):
''' Implements a generic learning module.
Initialized on access with __init__, first time with state=None, and
then with state
See the HTML module for a simple example
'''
id_attribute
=
'id'
# An attribute guaranteed to be unique
...
...
@@ -16,18 +18,31 @@ class XModule(object):
return
[]
def
get_completion
(
self
):
''' This is mostly unimplemented.
It gives a progress indication -- e.g. 30 minutes of 1.5 hours watched. 3 of 5 problems done, etc. '''
return
courseware
.
progress
.
completion
()
def
get_state
(
self
):
''' State of the object, as stored in the database
'''
return
""
def
get_score
(
self
):
''' Score the student received on the problem.
'''
return
None
def
max_score
(
self
):
''' Maximum score. Two notes:
* This is generic; in abstract, a problem could be 3/5 points on one randomization, and 5/7 on another
* In practice, this is a Very Bad Idea, and (a) will break some code in place (although that code
should get fixed), and (b) break some analytics we plan to put in place.
'''
return
None
def
get_html
(
self
):
''' HTML, as shown in the browser. This is the only method that must be implemented
'''
return
"Unimplemented"
def
get_init_js
(
self
):
...
...
@@ -38,6 +53,9 @@ class XModule(object):
return
""
def
get_destroy_js
(
self
):
''' JavaScript called to destroy the problem (e.g. when a user switches to a different tab).
We make an attempt, but not a promise, to call this when the user closes the web page.
'''
return
""
def
handle_ajax
(
self
,
dispatch
,
get
):
...
...
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