Skip to content
Merged
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
4 changes: 4 additions & 0 deletions common/lib/xmodule/xmodule/modulestore/mongo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ def load_item(self, location):
non_draft_loc = location.replace(revision=None)
metadata_to_inherit = self.cached_metadata.get(non_draft_loc.url(), {})
inherit_metadata(module, metadata_to_inherit)
# decache any computed pending field settings
module.save()
return module
except:
log.warning("Failed to load descriptor", exc_info=True)
Expand Down Expand Up @@ -630,6 +632,8 @@ def create_xmodule(self, location, definition_data=None, metadata=None, system=N
definition_data = {}
dbmodel = self._create_new_model_data(location.category, location, definition_data, metadata)
xmodule = xblock_class(system, dbmodel)
# decache any pending field settings from init
xmodule.save()
return xmodule

def save_xmodule(self, xmodule):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,6 @@ def xblock_from_json(self, class_, usage_id, json_data, course_entry_override=No
module.previous_version = json_data.get('previous_version')
module.update_version = json_data.get('update_version')
module.definition_locator = self.modulestore.definition_locator(definition)
# decache any pending field settings
module.save()
return module
13 changes: 11 additions & 2 deletions common/lib/xmodule/xmodule/x_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,14 @@ def xmodule(self, system):

system: Module system
"""
return self.module_class(
# save any field changes
module = self.module_class(
system,
self,
system.xblock_model_data(self),
)
module.save()
return module

def has_dynamic_children(self):
"""
Expand Down Expand Up @@ -613,7 +616,13 @@ def from_json(cls, json_data, system, parent_xblock=None):

new_block = system.xblock_from_json(cls, usage_id, json_data)
if parent_xblock is not None:
parent_xblock.children.append(new_block)
children = parent_xblock.children
children.append(new_block)
# trigger setter method by using top level field access
parent_xblock.children = children
# decache pending children field settings (Note, truly persisting at this point would break b/c
# persistence assumes children is a list of ids not actual xblocks)
parent_xblock.save()
return new_block

@classmethod
Expand Down
8 changes: 3 additions & 5 deletions lms/djangoapps/courseware/module_render.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import logging
import re
import sys
from functools import partial

Expand All @@ -13,7 +12,6 @@
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt

import pyparsing
from requests.auth import HTTPBasicAuth
from statsd import statsd

Expand Down Expand Up @@ -599,14 +597,14 @@ def _check_files_limits(files):

# Check number of files submitted
if len(inputfiles) > settings.MAX_FILEUPLOADS_PER_INPUT:
msg = 'Submission aborted! Maximum %d files may be submitted at once' %\
msg = 'Submission aborted! Maximum %d files may be submitted at once' % \
settings.MAX_FILEUPLOADS_PER_INPUT
return msg

# Check file sizes
for inputfile in inputfiles:
if inputfile.size > settings.STUDENT_FILEUPLOAD_MAX_SIZE: # Bytes
msg = 'Submission aborted! Your file "%s" is too large (max size: %d MB)' %\
if inputfile.size > settings.STUDENT_FILEUPLOAD_MAX_SIZE: # Bytes
msg = 'Submission aborted! Your file "%s" is too large (max size: %d MB)' % \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These edits (PEP8?) appear unrelated to the bug fix. I'm fine with it, but it seems extraneous.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it had some changes which I removed. I thought about taking it out but thought it didn't matter.

(inputfile.name, settings.STUDENT_FILEUPLOAD_MAX_SIZE / (1000 ** 2))
return msg

Expand Down