Content Library - Randomized Content Block

728 views
Skip to first unread message

Andrea Russo

unread,
Apr 28, 2015, 12:24:31 PM4/28/15
to edx-...@googlegroups.com
Hi.

I'm using content library to give teachers a set of questions that they can choose and insert in their courses. 
Unfortunately, i see that randomized content block allows to take questions only in a random way.

I'm a developer and i would like to develop a xblock that allows teacher to choose questions from content library. 
Is it possible?

Thanks a lot.

Andrea.

Xavier Antoviaque

unread,
Apr 29, 2015, 2:02:58 AM4/29/15
to edx-...@googlegroups.com, ma...@edx.org, par...@edx.org
Hi Andrea,
 
Glad you like the feature, and thank you for offering to contribute to it!
 
It is possible yes, and there are already elements in place to support different modes of selection (cf https://github.com/edx/edx-platform/blob/7b3bcef15549f5a803bcfd273a572fe88e3807bf/common/lib/xmodule/xmodule/library_content_module.py#L86 ). I can't speak for the product team (cc'ed Marco and Partha), but imho it would be a great contribution to content libraries, you aren't the first person to request this - that's certainly a PR we would be happy to review.
 
If you implement it, one of the things to consider will be the interface to select the blocks to include - you'll need to make sure it can handle libraries with hundreds of blocks inside.
 
Don't hesitate to send a PR for review/guidance - even if it's still in progress, we can provide guidance there, and help you fleshing it out.
 
--
Xavier
--
You received this message because you are subscribed to the Google Groups "General Open edX discussion" group.
 

Andrea Russo

unread,
Apr 29, 2015, 6:20:56 AM4/29/15
to edx-...@googlegroups.com, ma...@edx.org, par...@edx.org
Dear all.

I would to understand your code about randomized content block. 

I'm studying your xmodule code and i've seen that classes and methods about :
3) interaction between randomized content block and content libraries into library_tools.py. (https://github.com/edx/edx-platform/blob/5795ba3faf065ad43b1338eaad0b3c7dbcaedec3/common/lib/xmodule/xmodule/library_tools.py). 


Are there other python modules involved in randomized content block implementation and enabling into studio? 

In client side, where are javascript file about randomized content block?

I hope that someone help me. 

Thanks a lot.

Andrea

Braden MacDonald

unread,
Apr 29, 2015, 8:04:34 PM4/29/15
to edx-...@googlegroups.com, Marco Morales, par...@edx.org
Hi Andrea,

The .py files you've just listed are indeed the most important ones. You are just missing the test code and the client-side code. For a relatively complete list of the code involved, I'd suggest you look at the files changed in the original PR for the randomized content block: https://github.com/edx/edx-platform/pull/6155/files . As you can see there, the only JavaScript involved is in common/lib/xmodule/xmodule/public/js/library_content_edit.js, and it's relatively minor.

We did also have to implement a lot of changes to the "modulestore" code that stores course/library hierarchy and XBlock field data, but hopefully you won't need to make any changes to that code. You will want to understand how it's used in library_tools.py though.

Good luck, and as Xavier said, we're happy to look at a PR and offer guidance once you get to that point!

--
Braden MacDonald
@OpenCraft

Zachary Trabookis

unread,
May 7, 2015, 4:09:22 PM5/7/15
to edx-...@googlegroups.com, ma...@edx.org, par...@edx.org
I was just talking with someone on the IRC channel (#edx-code) and they referred me to this post.  Since you can added Videos and HTML components was the Random Content Blocks (http://edx.readthedocs.org/projects/edx-partner-course-staff/en/latest/exercises_tools/randomized_content_blocks.html) meant only to be used with Problem components?  It also looks like this component has Problem Type (http://edx.readthedocs.org/projects/edx-partner-course-staff/en/latest/_images/ContentLibraries_RCBSelectProblemType.png) property too which further suggests it's related to Problem components.  I would also like to pull from the Content Library and not randomize the components but I think a new component would need to be implemented.

Zach

Marco Morales

unread,
May 7, 2015, 11:43:00 PM5/7/15
to Zachary Trabookis, edx-...@googlegroups.com, Parthajit Baruah
Hi all,

We have talked about a couple other extensions to the existing Content Libraries and Randomized Content Block features, which I've briefly summarized below. Hopefully this helps! 

Metadata Tags and Schemas for Content Libraries
This would allow course authors to associate their content with learning objectives or other basic tags such as 'difficulty.' By extending these tags into the Randomized Content Block, authors would have richer ways to build randomized assessments.

Source (Component) from Library
This would be a variant of the existing Randomized Content Block that would let you pick a specific problem from a library you'd like to add to your course. This component would now be aware of any updates to the library component and be updatable (similar to what we currently have for the Randomized Content Block)

Move (Component) to Library
This reverses the authoring flow, letting course teams move existing organized content into content libraries.

Content Libraries Search / Filtering
In part to help support more complicated content libraries with tagged content, the ability to search or filter components in the library would help with larger library use cases.

We've talked about a number of other Libraries features but I at least wanted to share this in case it was helpful. 

Thanks!

Xavier Antoviaque

unread,
May 8, 2015, 4:24:47 AM5/8/15
to edx-...@googlegroups.com
Hi Zachary,
 
You can use the Randomized Content Blocks with any type of component added to the library - this includes videos and HTML components, not just problems. The filtering feature currently only allow to chose among problem types, though, yes. But you can still have a library made of different videos for example, and use the Randomized Content XBlock to display one of them randomly. As Marco pointed out, one of the potential future improvements would add better metadata support, and allow to filter other types of XBlocks from the RC XBlock.
 
--
Xavier.
 

Zachary Trabookis

unread,
May 8, 2015, 9:14:32 AM5/8/15
to edx-...@googlegroups.com
So it sounds like I would want to use the Move (Component) to Library to pull organized content from the Content Libaries into multiple existing Courses (to avoid the randomness of the blocks).  Has anyone started that effort or can anyone suggest what functionality to look at to create this component?

Zach

Zachary Trabookis

unread,
May 8, 2015, 9:25:51 AM5/8/15
to edx-...@googlegroups.com
I guess another import feature of the Move (Component) to Library may be the ability to reorder the Blocks.  It currently looks like the Content Library Blocks are currently "sorted by Date added descending" with no ability to drag and reorder the blocks like currently have with the Course Units. 

Zach

Andrea Russo

unread,
May 9, 2015, 7:05:08 AM5/9/15
to edx-...@googlegroups.com, par...@edx.org, ma...@edx.org
Hi Braden, 

I'm studying code about Randomized Content Block. I think that the better solution is to write another xblock (called Manual Content Block for example) that allows teacher to select xblock in libraries and insert them into the Content Block. 

According to you, is it possible to write my Manual Content Block as external xblock (using xblock-sdk) and insert it into edx-platform? 

Moreover, where is the python method that write the randomized content block in mongodb's collection called modulestore.structures ?

Thanks a lot.

Andrea

Braden MacDonald

unread,
May 11, 2015, 3:23:58 PM5/11/15
to edx-...@googlegroups.com
Zachary,

If I understand you correctly, "Move (Component) to Library" would not be what you want - it's an idea for moving content from a course to a library, not vice versa. What you want sounds more like the "Source (Component) from Library" which would let one pick a specific component that's in a library and copy it into a course.

Within a content library, the blocks are not intended to be orderable via dragging, nor is that planned for the future. Instead the plan is to implement sorting and filtering, so that the blocks can be sorted on any criteria (title, difficultly, subject, problem type, date added, date edited, etc.) as well as filtered on any of those criteria (e.g. "Show all blocks in this library that are multiple choice questions about thermodynamics").

However, with the "Source (Component) from Library" block, you would definitely be able to choose what blocks appear in the course and in what order.

--
Braden MacDonald
@OpenCraft

Braden MacDonald

unread,
May 11, 2015, 3:40:53 PM5/11/15
to edx-...@googlegroups.com
Hi Andrea,

Yes, that is what Marco was suggesting also: Create a new block called "Source (Component) from Library" that "allows teacher to select xblock in libraries and insert them into the Content Block". I think that's a great approach.

Yes, since the "library_tools" module is already implemented, I think it should be possible to write the code as an XBlock and insert it into the platform. It will definitely be easier to do if you write the code within the existing xmodules folder and submit it for inclusion in edx-platform rather than making it completely independent and in a separate repository. One potential difficultly is that the current implementation of the Randomized Content Block was done using the old XModule API, and we have not yet converted it to the newer XBlock API. Although I think the platform is now ready for that sort of thing to be done as an XBlock, there is a bit of uncertainty, and it's possible you'd encounter some unexpected difficulties. I'm sure there are people around who would be happy to help out with such issues, if any, though - including myself.

Now, you asked "where is the python method that write the randomized content block in ... modulestore.structures ?"

I don't think you'll actually have to dive down to the code at such a low level in order to implement this XBlock, but I'm sure it's useful to understand that. The answer is the copy_from_template method (and its helper method _copy_from_template) is what copies blocks from the library to become descendants of the randomized content in modulestore.structures. This copy_from_template method is wrapped by update_children in library_tools.py. To implement the "Source Component from Library" block you'd need to either modify update_children or write a similar method. You should not have to change copy_from_template or any of the modulestore code (I hope).

Hope this helps! 


--
Braden MacDonald
@OpenCraft

Andrea Russo

unread,
May 12, 2015, 12:38:39 PM5/12/15
to edx-...@googlegroups.com
Hi Braden,

thank you for detailed explanation. I study better the code and I believe that i haven't to modify modulestore. 

Actually, for many reason, i want to realize xmodule ( in xmodule folder) called "Manual Content Block", but i have some problems. 
1) creating file called "manual_content_block.py" in common/lib/xmodule/xmodule with class ManualContentFields,ManualContentModule,ManualContentDescriptor
2) adding "manual_content = xmodule.manual_content_module:ManualContentDescriptor" in file common/lib/xmodule/setup.py
3) adding 'manual_content' in cms/envs/common.py
4) adding ('manual_content','Manual Content')) in lms/djangoapps/courseware/models.py
5) adding [..'manual_content']: in lms/templates/staff_problem_info.html
6) adding "library_content", "manual_content"   Setting->Advanced Setting-> Advanced Module List  of my course

But, when i try to add "Manual Content Block" in an Unit from Advanced, i don't view "Manual Content Block".

Do I commit some mistake? Help me. 

Thanks a lot.

Andrea

Braden MacDonald

unread,
May 12, 2015, 3:50:13 PM5/12/15
to edx-...@googlegroups.com
Hi Andrea,

I think you're very close! The only thing missing is that you have to refresh the Python "entry points" for the xmodule package. Otherwise, Python's setuptools won't know that you did step 2 (adding the block to setup.py). To do this, run the following command on your devstack:

cd ~/edx-platform/common/lib/xmodule/ && python setup.py develop && cd -

Then restart the server and you should be able to add and use the new module.

--
Braden MacDonald
@OpenCraft

Calen Pennington

unread,
May 12, 2015, 4:49:22 PM5/12/15
to edx-...@googlegroups.com
Hi, Braden and Andrea,

We've been hard at work getting to the point where we can start using only XBlocks, rather than a mix of XModules and XBlocks. Is there anything specific to this ManualContentBlock that would prevent you writing a pure XBlock, rather than an XModule? If there isn't, I'd love to see this land as an XBlock, rather than an XModule that you'll have to convert to an XBlock later once we stop supporting XModules.

-Cale

Braden MacDonald

unread,
May 12, 2015, 7:18:04 PM5/12/15
to edx-...@googlegroups.com
Cale, that would definitely be my preference as well - I mentioned in passing it a bit earlier in this thread. I'm not aware of anything that would currently be blocking an XBlock implementation. It would just be a little less approachable since the existing randomized block was necessarily written with the XModule API. I'd love to be able to convert it to pure XBlock, and for the new additions to be pure XBlocks as well. Andrea, I'm not sure if that's something you'd be able to try out as part of your current project? Essentially you'd need to combine your new ManualContentFields, ManualContentModule, and ManualContentDescriptor into one single ManualContentBlock class that inherits from XBlock.

Cheers,
--
Braden MacDonald
@OpenCraft

Andrea Russo

unread,
May 19, 2015, 7:34:11 AM5/19/15
to edx-...@googlegroups.com
Dear Braden, 

I'm working about "Manual Content Block". My approach is : Teacher select library, so there is a loading of exercises' title, and teacher select title and insert exercise into Manual Content Block. I attach an image of my author view. How is it possibile to allow multiple select ? (such as multiple option in html tag select).

Thanks a lot,
Andrea
Metadata.png

Braden MacDonald

unread,
May 19, 2015, 8:34:28 PM5/19/15
to edx-...@googlegroups.com
Hi Andrea,

You would need to implement a custom widget in order to allow multiple select. You can do that by overriding the XBlock's studio_view to render a custom HTML template that includes a custom selection widget. Here's an example.

Cheers.
--
Braden MacDonald
@OpenCraft

Zachary Trabookis

unread,
Aug 25, 2015, 5:16:43 PM8/25/15
to General Open edX discussion
Is there a PR now for "Source (Component) from Library" functionality?

Zach

Xavier Antoviaque

unread,
Aug 26, 2015, 4:48:13 AM8/26/15
to edx-...@googlegroups.com
Hi Zachary,
 
I'm not sure I understand your question. Could you explain what you mean by "Source (Component) from Library"? Or, if you refer to a discussion from an existing thread, maybe reply to that thread so we can have the context?
 
--
Xavier
@OpenCraft
 
On Tue, Aug 25, 2015, at 23:16, Zachary Trabookis wrote:
> Is there a PR now for "Source (Component) from Library" functionality?
>
> Zach
>
> --
> You received this message because you are subscribed to the Google Groups
> "General Open edX discussion" group.
> To view this discussion on the web visit

c...@edisonx.academy

unread,
Jul 11, 2018, 9:33:34 AM7/11/18
to General Open edX discussion
Is there a way to stop the randomization and only pick the first n number of questions from the library? The question numbers are jumbled when it randomizes and I need the Xblock to always pick the first n number of questions without the randomization logic.

Alameh

unread,
Jul 18, 2018, 10:34:28 AM7/18/18
to General Open edX discussion
Hello
I am working on a smiliar problem
All you  have to do , is to modify the method that make this selection which is
make_selection
you can find it on:
edx-platform/common/lib/xmodule/xmodule/library_content_module.py

It is responsable of returning the random contents from a library.

Regards

Suryaprakash Kompalli

unread,
Dec 12, 2018, 9:21:57 AM12/12/18
to General Open edX discussion
Hello:
           Did this feature get implemented?

Regards,
SP

Ernesto Sanchez

unread,
Dec 13, 2018, 1:15:23 PM12/13/18
to General Open edX discussion

Suryaprakash Kompalli

unread,
Dec 17, 2018, 1:26:21 AM12/17/18
to edx-...@googlegroups.com
The OP had asked if there is a feature to add a specific question form a library. The randomized content block randomly selects a certain number of questions from a library.

We have a use case where there is a library of questions, and we want to select a specific question from that library. This thread says it is possible to modify the random content block. I could not figure out how to do this. Any help will be appreciated.

Regards,
SP

--
You received this message because you are subscribed to the Google Groups "General Open edX discussion" group.


--

Sivakumar

unread,
Jun 3, 2019, 4:46:24 AM6/3/19
to General Open edX discussion
Hi Alameh,

I tried multiple things, but I am not able to stop the randomization. Is there a way to stop the randomization and only pick the first n number of questions from the library? Looking forward.

Thanks.

On Wednesday, July 18, 2018 at 8:04:28 PM UTC+5:30, Alameh wrote:
Reply all
Reply to author
Forward
0 new messages