-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure old problems work on new version. #98
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -638,25 +638,11 @@ def _expand_static_url(self, url): | |
def _get_user_state(self): | ||
""" Get all user-specific data, and any applicable feedback """ | ||
item_state = self._get_item_state() | ||
for item_id, item in item_state.iteritems(): | ||
# If information about zone is missing | ||
# (because problem was completed before a11y enhancements were implemented), | ||
# deduce zone in which item is placed from definition: | ||
if item.get('zone') is None: | ||
valid_zones = self._get_item_zones(int(item_id)) | ||
if valid_zones: | ||
# If we get to this point, then the item was placed prior to support for | ||
# multiple correct zones being added. As a result, it can only be correct | ||
# on a single zone, and so we can trust that the item was placed on the | ||
# zone with index 0. | ||
item['zone'] = valid_zones[0] | ||
else: | ||
item['zone'] = 'unknown' | ||
|
||
# In assessment mode, if item is placed correctly and than the page is refreshed, "correct" | ||
# will spill to the frontend, making item "disabled", thus allowing students to obtain answer by trial | ||
# and error + refreshing the page. In order to avoid that, we remove "correct" from an item here | ||
if self.mode == self.ASSESSMENT_MODE: | ||
# In assessment mode, if item is placed correctly and than the page is refreshed, "correct" | ||
# will spill to the frontend, making item "disabled", thus allowing students to obtain answer by trial | ||
# and error + refreshing the page. In order to avoid that, we remove "correct" from an item here | ||
if self.mode == self.ASSESSMENT_MODE: | ||
for item in item_state.values(): | ||
del item["correct"] | ||
|
||
overall_feedback_msgs, __ = self._get_feedback() | ||
|
@@ -682,11 +668,32 @@ def _get_item_state(self): | |
# handler and manipulated there to hide correctness of items placed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mtyaka "... and the data it returns is manipulated there ..."? (Again, this is an existing comment, but since there's a lot going on in this code I think it's worth being precise in any comments that explain what's going on.) |
||
state = {} | ||
|
||
for item_id, item in self.item_state.iteritems(): | ||
if isinstance(item, dict): | ||
state[item_id] = item.copy() # items are manipulated in _get_user_state, so we protect actual data | ||
for item_id, raw_item in self.item_state.iteritems(): | ||
if isinstance(raw_item, dict): | ||
# Items are manipulated in _get_user_state, so we protect actual data. | ||
item = copy.deepcopy(raw_item) | ||
else: | ||
state[item_id] = {'top': item[0], 'left': item[1]} | ||
item = {'top': raw_item[0], 'left': raw_item[1]} | ||
# If information about zone is missing | ||
# (because problem was completed before a11y enhancements were implemented), | ||
# deduce zone in which item is placed from definition: | ||
if item.get('zone') is None: | ||
valid_zones = self._get_item_zones(int(item_id)) | ||
if valid_zones: | ||
# If we get to this point, then the item was placed prior to support for | ||
# multiple correct zones being added. As a result, it can only be correct | ||
# on a single zone, and so we can trust that the item was placed on the | ||
# zone with index 0. | ||
item['zone'] = valid_zones[0] | ||
else: | ||
item['zone'] = 'unknown' | ||
# If correctness information is missing | ||
# (because problem was completed before assessment mode was implemented), | ||
# assume the item is in correct zone (in standard mode, only items placed | ||
# into correct zone are stored in item state). | ||
if item.get('correct') is None: | ||
item['correct'] = True | ||
state[item_id] = item | ||
|
||
return state | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mtyaka @mtyaka Typo: "than" should be "then"
And I know you just copied an existing comment, but I'm not sure what
means (esp. the first part)? It would be great if you could clarify :)