-
Notifications
You must be signed in to change notification settings - Fork 58
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
2.6.2 Instructor Tool uses the Course Blocks REST API #129
Conversation
0a0fd92
to
b3be88b
Compare
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.
@pomegranited These changes look great overall, I just had a few small comments/questions.
I'll test when you're done addressing them and the sandbox is up-to-date.
}); | ||
} | ||
function updateBlockOptions(data) { | ||
|
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.
@pomegranited Nit: Move empty line up so it separates getCourseBlocks
and updateBlockOptions
functions.
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.
Addressed with a3dd42f.
@@ -172,3 +172,10 @@ def validate_field_data(self, validation, data): | |||
Validate this block's field data. | |||
""" | |||
super(SliderBlock, self).validate_field_data(validation, data) | |||
|
|||
def student_view_data(self): |
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.
@pomegranited Since SliderBlock
isn't an eligible block type, I'm wondering why it would need to define student_view_data
?
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.
@itsjeyd So my question is, why isn't SliderBlock
an eligible block type? And MRQBlock
too for that matter? But I didn't have enough time to look into that..
I'm happy to remove this change though.
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.
Reverted with 78f09e6.
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.
So my question is, why isn't SliderBlock an eligible block type? And MRQBlock too for that matter?
IIRC, we implemented these data exports for Harvard GSE, and at the time they only wanted support for specific question types. MRQ was not one of them, and sliders didn't exist yet :)
return $option; | ||
}, | ||
buildTree = function(block, ancestors) { | ||
|
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.
@pomegranited Same nit here: Empty line above start of function definition would be nice :)
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.
Addressed with a3dd42f.
|
||
// Find the best label attribute available for the block | ||
labelAttr = _.find(['question', 'name', 'display_name'], | ||
function(attr) {return block[attr]}), |
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.
@pomegranited Nit: This would be even more readable when formatted like this:
labelAttr = _.find(
['question', 'name', 'display_name'],
function(attr) { return block[attr] }
),
Or like this:
labelAttr = _.find(
['question', 'name', 'display_name'],
function(attr) {
return block[attr]
}
),
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.
Addressed with a3dd42f.
} | ||
function updateBlockOptions(data) { | ||
|
||
var appendBlock = function(block) { |
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.
@pomegranited You already added some nice comments explaining individual steps to the body of this function. It would be great to have a general comment that summarizes what this function does (and why it needs to return $option
).
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.
Addressed with a3dd42f.
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.
Those additional comments look great, @pomegranited! Thanks for adding them. Found a couple typos that will need to be fixed, but other than that the code is good to go.
@@ -253,8 +253,9 @@ function InstructorToolBlock(runtime, element) { | |||
// Block types with answers we can export | |||
var questionBlockTypes = ['pb-mcq', 'pb-rating', 'pb-answer']; | |||
|
|||
// Fetch this course's blocks from the REST API, and adds the to the | |||
// list of blocks in the Section/Question drop-down list. |
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.
@pomegranited Typos: "Fetch this course's blocks ..., and add the ??? to the list of blocks ..." (perhaps you meant to say "and add them"?)
function updateBlockOptions(data) { | ||
|
||
// Constructs an <option> element for the given block to the drop-down |
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.
@pomegranited "... to add to the drop-down ..."?
@pomegranited Thanks for the updates. The code is good to squash. I'll test when the new sandbox is ready. |
f295ec2
to
db6b076
Compare
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.
@pomegranited This is looking great! I have two more comments based on looking at the recent updates and testing on the sandbox, but they should be quick to address and this good to go once you've done that (I won't need to review again) 👍
- I tested this: Course trees are the same on the different sandboxes.
- I read through the code
-
I checked for accessibility issuesN/A (refactoring) -
Includes documentationN/A (refactoring)
) | ||
patched_loader.render_template.assert_called_once_with('templates/html/instructor_tool.html', { | ||
'block_choices': block_choices, | ||
'course_blocks_api': '/api/courses/v1/blocks/', |
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.
@pomegranited Instead of hard coding the API URL here, you could just import COURSE_BLOCKS_API
from problem_builder.instructor_tool
.
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.
@itsjeyd I've been smacked on the wrist for doing that before for some reason.. But I totally agree. Fixed here.
And since I squashed the commits, I also added a comment to the COURSE_BLOCKS_API
declaration to explain why the trailing slash is important. Seemed excessive to go into detail about the content switch proxy, but at least made a note.
// if it's found to have a descendant that is enabled. | ||
var appendBlock = function(block) { | ||
var blockId = block.id.split('+block@').pop(), | ||
padding = Array(block.depth).join(' '), |
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.
@pomegranited Can you increase the padding to two spaces? That's what the original implementation used (see instructor_tool.html#L35), and I think the tree looks slightly better/more readable with two spaces.
Sorry for not pointing this out sooner, I really had to see the two versions side-by-side to get a sense of the difference.
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.
…d drop-down. * Removes the python course tree traversal logic, and replaces it with Javascript. * Adds student_view_data() to downloadable block types to reveal the "question" text to the Course Blocks API
3369ad5
to
0f143d8
Compare
Moves the logic that populates the Instructor Tool's drop-down list of course blocks out of the server-side and into the client, using the Course Blocks API as the data source.
Discussions: In #119, @ormsbee raised concerns about performance and maintainability of the old server-side mechanism for traversing the course blocks via the runtime object's parents.
Sandbox URL:
Partner information: DavidsonX
Testing instructions:
master
.Features > Instructor Tool
unit, and note the list of course block options available for "Section/Question".Features > Instructor Tool
unit, and note that the list of course block options has not changed.Alternatively, you can compare the sandbox from this PR with the one for v2.6.1, https://github.com/edx/edx-platform/pull/13938.
Author notes and concerns:
Reviewers