Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions common/lib/xmodule/xmodule/conditional_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import json
import logging
from lazy import lazy
from lxml import etree
from pkg_resources import resource_string

Expand Down Expand Up @@ -97,10 +98,12 @@ def _get_condition(self):
return xml_value, attr_name
raise Exception('Error in conditional module: unknown condition "%s"' % xml_attr)

def is_condition_satisfied(self):
self.required_modules = [self.system.get_module(descriptor) for
descriptor in self.descriptor.get_required_module_descriptors()]
@lazy
def required_modules(self):
return [self.system.get_module(descriptor) for
descriptor in self.descriptor.get_required_module_descriptors()]

def is_condition_satisfied(self):
xml_value, attr_name = self._get_condition()

if xml_value and self.required_modules:
Expand Down
2 changes: 1 addition & 1 deletion common/lib/xmodule/xmodule/lti_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def get_html(self):
]

# Obtains client_key and client_secret credentials from current course:
course_id = self.runtime.course_id
course_id = self.course_id
course_location = CourseDescriptor.id_to_location(course_id)
course = self.descriptor.runtime.modulestore.get_item(course_location)
client_key = client_secret = ''
Expand Down
6 changes: 3 additions & 3 deletions common/lib/xmodule/xmodule/peer_grading_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def peer_grading(self, _data=None):
error_text = ""
problem_list = []
try:
problem_list_json = self.peer_gs.get_problem_list(self.system.course_id, self.system.anonymous_student_id)
problem_list_json = self.peer_gs.get_problem_list(self.course_id, self.system.anonymous_student_id)
problem_list_dict = problem_list_json
success = problem_list_dict['success']
if 'error' in problem_list_dict:
Expand Down Expand Up @@ -569,7 +569,7 @@ def peer_grading(self, _data=None):

ajax_url = self.ajax_url
html = self.system.render_template('peer_grading/peer_grading.html', {
'course_id': self.system.course_id,
'course_id': self.course_id,
'ajax_url': ajax_url,
'success': success,
'problem_list': good_problem_list,
Expand Down Expand Up @@ -603,7 +603,7 @@ def peer_grading_problem(self, data=None):
html = self.system.render_template('peer_grading/peer_grading_problem.html', {
'view_html': '',
'problem_location': problem_location,
'course_id': self.system.course_id,
'course_id': self.course_id,
'ajax_url': ajax_url,
# Checked above
'staff_access': False,
Expand Down
5 changes: 5 additions & 0 deletions common/lib/xmodule/xmodule/x_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ class XModuleMixin(XBlockMixin):
default=None
)

@property
def course_id(self):
return self.runtime.course_id

@property
def id(self):
return self.location.url()
Expand Down Expand Up @@ -743,6 +747,7 @@ def _xmodule(self):
self.xmodule_runtime.xmodule_instance = descriptor._xmodule # pylint: disable=protected-access
return self.xmodule_runtime.xmodule_instance

course_id = module_attr('course_id')
displayable_items = module_attr('displayable_items')
get_display_items = module_attr('get_display_items')
get_icon_class = module_attr('get_icon_class')
Expand Down
8 changes: 2 additions & 6 deletions lms/templates/conditional_module.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<%
from django.core.urlresolvers import reverse

# course_id = module.location.course_id
def get_course_id(module):
return module.location.org +'/' + module.location.course +'/' + \
module.system.ajax_url.split('/')[4]
from django.core.urlresolvers import reverse

def _message(reqm, message):
return message.format(link="<a href={url}>{url_name}</a>".format(
url = reverse('jump_to', kwargs=dict(course_id=get_course_id(reqm),
url = reverse('jump_to', kwargs=dict(course_id=reqm.course_id,
location=reqm.location.url())),
url_name = reqm.display_name_with_default))
%>
Expand Down