Commit 33807456 by Vik Paruchuri

About to trim some lines

parent c6c89e42
...@@ -65,6 +65,7 @@ class PeerGradingModule(XModule): ...@@ -65,6 +65,7 @@ class PeerGradingModule(XModule):
#We need to set the location here so the child modules can use it #We need to set the location here so the child modules can use it
system.set('location', location) system.set('location', location)
log.debug("Location: {0}".format(location))
self.system = system self.system = system
self.peer_gs = peer_grading_service(self.system) self.peer_gs = peer_grading_service(self.system)
......
...@@ -140,12 +140,13 @@ def get_module(user, request, location, student_module_cache, course_id, ...@@ -140,12 +140,13 @@ def get_module(user, request, location, student_module_cache, course_id,
module. If there's an error, will try to return an instance of ErrorModule module. If there's an error, will try to return an instance of ErrorModule
if possible. If not possible, return None. if possible. If not possible, return None.
""" """
try: #try:
location = Location(location) location = Location(location)
descriptor = modulestore().get_instance(course_id, location, depth=depth) descriptor = modulestore().get_instance(course_id, location, depth=depth)
return get_module_for_descriptor(user, request, descriptor, student_module_cache, course_id, return get_module_for_descriptor(user, request, descriptor, student_module_cache, course_id,
position=position, not_found_ok=not_found_ok, position=position, not_found_ok=not_found_ok,
wrap_xmodule_display=wrap_xmodule_display) wrap_xmodule_display=wrap_xmodule_display)
"""
except ItemNotFoundError: except ItemNotFoundError:
if not not_found_ok: if not not_found_ok:
log.exception("Error in get_module") log.exception("Error in get_module")
...@@ -154,7 +155,7 @@ def get_module(user, request, location, student_module_cache, course_id, ...@@ -154,7 +155,7 @@ def get_module(user, request, location, student_module_cache, course_id,
# Something has gone terribly wrong, but still not letting it turn into a 500. # Something has gone terribly wrong, but still not letting it turn into a 500.
log.exception("Error in get_module") log.exception("Error in get_module")
return None return None
"""
def get_module_for_descriptor(user, request, descriptor, student_module_cache, course_id, def get_module_for_descriptor(user, request, descriptor, student_module_cache, course_id,
position=None, not_found_ok=False, wrap_xmodule_display=True): position=None, not_found_ok=False, wrap_xmodule_display=True):
......
...@@ -30,6 +30,7 @@ from xmodule import peer_grading_service ...@@ -30,6 +30,7 @@ from xmodule import peer_grading_service
from mitxmako.shortcuts import render_to_string from mitxmako.shortcuts import render_to_string
from xmodule.x_module import ModuleSystem from xmodule.x_module import ModuleSystem
from courseware import module_render from courseware import module_render
from xmodule.modulestore import Location
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from courseware.models import StudentModule, StudentModuleCache from courseware.models import StudentModule, StudentModuleCache
...@@ -103,6 +104,11 @@ def peer_grading(request, course_id): ...@@ -103,6 +104,11 @@ def peer_grading(request, course_id):
replace_urls = None replace_urls = None
anonymous_student_id= unique_id_for_user(request.user) anonymous_student_id= unique_id_for_user(request.user)
pg_ajax = _reverse_with_slash('peer_grading', course_id)
pg_url = re.sub("/courses", "i4x:/",pg_ajax)[:-1]
pg_location = request.GET.get('location', pg_url)
pg_location = "i4x://MITx/oe101x/peergrading/init"
system = ModuleSystem( system = ModuleSystem(
ajax_url, ajax_url,
track_function, track_function,
...@@ -113,14 +119,10 @@ def peer_grading(request, course_id): ...@@ -113,14 +119,10 @@ def peer_grading(request, course_id):
anonymous_student_id = anonymous_student_id anonymous_student_id = anonymous_student_id
) )
location = ""
definition = "<peergrading use_for_single_location = 'False'></peergrading>" definition = "<peergrading use_for_single_location = 'False'></peergrading>"
descriptor = peer_grading_module.PeerGradingDescriptor
instance_state = None instance_state = None
pg_ajax = _reverse_with_slash('peer_grading', course_id) descriptor = peer_grading_module.PeerGradingDescriptor(system)
pg_url = re.sub("/courses", "i4x:/",pg_ajax)[:-1]
pg_location = request.GET.get('location', pg_url)
pg_module = peer_grading_module.PeerGradingModule(system, pg_location, definition, descriptor, instance_state) pg_module = peer_grading_module.PeerGradingModule(system, pg_location, definition, descriptor, instance_state)
...@@ -138,11 +140,11 @@ def peer_grading(request, course_id): ...@@ -138,11 +140,11 @@ def peer_grading(request, course_id):
""" """
student_module_cache = StudentModuleCache(course_id, student_module_cache = StudentModuleCache(course_id,
request.user, descriptor) request.user, [descriptor])
pg_xmodule = module_render.get_module(request.user, request, pg_location, student_module_cache, course_id) pg_xmodule = module_render.get_module(request.user, request, Location(pg_location), student_module_cache, course_id)
return pg_xmodule.get_html() return HttpResponse(pg_xmodule.get_html())
@cache_control(no_cache=True, no_store=True, must_revalidate=True) @cache_control(no_cache=True, no_store=True, must_revalidate=True)
def peer_grading_ajax(request, course_id): def peer_grading_ajax(request, course_id):
......
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