Merge remote-tracking branch 'origin/master' into 700x-sandbox
This commit is contained in:
@@ -633,9 +633,13 @@ class MultipleChoiceResponse(LoncapaResponse):
|
||||
# define correct choices (after calling secondary setup)
|
||||
xml = self.xml
|
||||
cxml = xml.xpath('//*[@id=$id]//choice', id=xml.get('id'))
|
||||
self.correct_choices = [contextualize_text(choice.get('name'),
|
||||
self.context) for choice in cxml if
|
||||
contextualize_text(choice.get('correct'), self.context) == "true"]
|
||||
|
||||
# contextualize correct attribute and then select ones for which
|
||||
# correct = "true"
|
||||
self.correct_choices = [
|
||||
contextualize_text(choice.get('name'), self.context)
|
||||
for choice in cxml
|
||||
if contextualize_text(choice.get('correct'), self.context) == "true"]
|
||||
|
||||
def mc_setup_response(self):
|
||||
'''
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
},
|
||||
smartIndent: false
|
||||
});
|
||||
$("#textbox_${id}").find('.CodeMirror-scroll').height(${int(13.5*eval(rows))});
|
||||
});
|
||||
</script>
|
||||
</section>
|
||||
|
||||
@@ -446,7 +446,7 @@ class CourseDescriptor(SequenceDescriptor):
|
||||
# utility function to get datetime objects for dates used to
|
||||
# compute the is_new flag and the sorting_score
|
||||
def to_datetime(timestamp):
|
||||
return datetime.fromtimestamp(time.mktime(timestamp))
|
||||
return datetime(*timestamp[:6])
|
||||
|
||||
def get_date(field):
|
||||
timetuple = self._try_parse_time(field)
|
||||
|
||||
@@ -2,6 +2,7 @@ import logging
|
||||
from xmodule.modulestore import Location
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from fs.osfs import OSFS
|
||||
from json import dumps
|
||||
|
||||
|
||||
def export_to_xml(modulestore, contentstore, course_location, root_dir, course_dir):
|
||||
@@ -27,6 +28,12 @@ def export_to_xml(modulestore, contentstore, course_location, root_dir, course_d
|
||||
# export the course updates
|
||||
export_extra_content(export_fs, modulestore, course_location, 'course_info', 'info', '.html')
|
||||
|
||||
# export the grading policy
|
||||
policies_dir = export_fs.makeopendir('policies')
|
||||
course_run_policy_dir = policies_dir.makeopendir(course.location.name)
|
||||
with course_run_policy_dir.open('grading_policy.json', 'w') as grading_policy:
|
||||
grading_policy.write(dumps(course.definition['data']['grading_policy']))
|
||||
|
||||
|
||||
def export_extra_content(export_fs, modulestore, course_location, category_type, dirname, file_suffix=''):
|
||||
query_loc = Location('i4x', course_location.org, course_location.course, category_type, None)
|
||||
|
||||
@@ -56,6 +56,10 @@ def update_templates():
|
||||
available from the installed plugins
|
||||
"""
|
||||
|
||||
# cdodge: build up a list of all existing templates. This will be used to determine which
|
||||
# templates have been removed from disk - and thus we need to remove from the DB
|
||||
templates_to_delete = modulestore('direct').get_items(['i4x', 'edx', 'templates', None, None, None])
|
||||
|
||||
for category, templates in all_templates().items():
|
||||
for template in templates:
|
||||
if 'display_name' not in template.metadata:
|
||||
@@ -85,3 +89,12 @@ def update_templates():
|
||||
modulestore('direct').update_item(template_location, template.data)
|
||||
modulestore('direct').update_children(template_location, template.children)
|
||||
modulestore('direct').update_metadata(template_location, template.metadata)
|
||||
|
||||
# remove template from list of templates to delete
|
||||
templates_to_delete = [t for t in templates_to_delete if t.location != template_location]
|
||||
|
||||
# now remove all templates which appear to have removed from disk
|
||||
if len(templates_to_delete) > 0:
|
||||
logging.debug('deleting dangling templates = {0}'.format(templates_to_delete))
|
||||
for template in templates_to_delete:
|
||||
modulestore('direct').delete_item(template.location)
|
||||
|
||||
@@ -86,8 +86,8 @@ class TimeLimitModule(XModule):
|
||||
modified_duration = self._get_accommodated_duration(duration)
|
||||
self.ending_at = self.beginning_at + modified_duration
|
||||
|
||||
def get_end_time_in_ms(self):
|
||||
return int(self.ending_at * 1000)
|
||||
def get_remaining_time_in_ms(self):
|
||||
return int((self.ending_at - time()) * 1000)
|
||||
|
||||
def get_instance_state(self):
|
||||
state = {}
|
||||
|
||||
Reference in New Issue
Block a user