Commit e8f8d435 by Piotr Mitros

Modified to work with preview in CMS; non-stable for use as LMS (need to change directory refs)

parent 04f63c16
......@@ -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:
......
......@@ -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
......
import os
import os.path
from django.conf import settings
import capa_module
import html_module
import schematic_module
......
......@@ -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':
......
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):
......
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment