{
“cells”: [
{

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“# ricecooker exercisesn”, “n”, “n”, “This mini-tutorial will walk you through the steps of running a simple chef script ExercisesChef that creates two exercises nodes, and four exercises questions.n”, “n”, “n”, “### Running the notebooksn”, “To follow along and run the code in this notebook, you’ll need to clone the ricecooker repository, crate a virtual environement, install ricecooker using pip install ricecooker, install Jypyter notebook using pip install jupyter, then start the jupyter notebook server by running jupyter notebook. You will then be able to run all the code sections in this notebook and poke around.”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“### Creating a Sushi Chef classn”, “n”

]

}, {

“cell_type”: “code”, “execution_count”: 1, “metadata”: {}, “outputs”: [], “source”: [

“from ricecooker.chefs import SushiChefn”, “from ricecooker.classes.nodes import TopicNode, ExerciseNoden”, “from ricecooker.classes.questions import SingleSelectQuestion, MultipleSelectQuestion, InputQuestion, PerseusQuestionn”, “from ricecooker.classes.licenses import get_licensen”, “from le_utils.constants import licensesn”, “from le_utils.constants import exercisesn”, “from le_utils.constants.languages import getlangn”, “n”, “n”, “class ExercisesChef(SushiChef):n”, “ channel_info = {n”, “ ‘CHANNEL_TITLE’: ‘Sample Exercises’,n”, “ ‘CHANNEL_SOURCE_DOMAIN’: ‘<yourdomain.org>’, # where you got the contentn”, “ ‘CHANNEL_SOURCE_ID’: ‘<unique id for channel>’, # channel’s unique id CHANGE MEn”, “ ‘CHANNEL_LANGUAGE’: ‘en’, # le_utils language coden”, “ ‘CHANNEL_DESCRIPTION’: ‘A test channel with different types of exercise questions’, # (optional)n”, “ ‘CHANNEL_THUMBNAIL’: None, # (optional)n”, “ }n”, “n”, “ def construct_channel(self, **kwargs):n”, “ channel = self.get_channel(**kwargs)n”, “ topic = TopicNode(title="Math Exercises", source_id="folder-id")n”, “ channel.add_child(topic)n”, “n”, “ exercise_node = ExerciseNode(n”, “ source_id=’<some unique id>’,n”, “ title=’Basic questions’,n”, “ author=’LE content team’,n”, “ description=’Showcase of the simple question type supported by Ricecooker and Studio’,n”, “ language=getlang(‘en’).code,n”, “ license=get_license(licenses.PUBLIC_DOMAIN),n”, “ thumbnail=None,n”, “ exercise_data={n”, “ ‘mastery_model’: exercises.M_OF_N, # \n”, “ ‘m’: 2, # learners must get 2/3 questions correct to complete exercisen”, “ ‘n’: 3, # /n”, “ ‘randomize’: True, # show questions in random ordern”, “ },n”, “ questions=[n”, “ MultipleSelectQuestion(n”, “ id=’sampleEX_Q1’,n”, “ question = "Which numbers the following numbers are even?",n”, “ correct_answers = ["2", "4",],n”, “ all_answers = ["1", "2", "3", "4", "5"],n”, “ hints=[‘Even numbers are divisible by 2.’],n”, “ ),n”, “ SingleSelectQuestion(n”, “ id=’sampleEX_Q2’,n”, “ question = "What is 2 times 3?",n”, “ correct_answer = "6",n”, “ all_answers = ["2", "3", "5", "6"],n”, “ hints=[‘Multiplication of $a$ by $b$ is like computing the area of a rectangle with length $a$ and width $b$.’],n”, “ ),n”, “ InputQuestion(n”, “ id=’sampleEX_Q3’,n”, “ question = "Name one of the factors of 10.",n”, “ answers = ["1", "2", "5", "10"],n”, “ hints=[‘The factors of a number are the divisors of the number that leave a whole remainder.’],n”, “ )n”, “ ]n”, “ )n”, “ topic.add_child(exercise_node)n”, “n”, “ # LOAD JSON DATA (as string) FOR PERSEUS QUESTIONS n”, “ RAW_PERSEUS_JSON_STR = open(‘../../examples/exercises/chefdata/perseus_graph_question.json’, ‘r’).read()n”, “ # orn”, “ # import requestsn”, “ # RAW_PERSEUS_JSON_STR = requests.get(’https://raw.githubusercontent.com/learningequality/sample-channels/master/contentnodes/exercise/perseus_graph_question.json’).textn”, “ exercise_node2 = ExerciseNode(n”, “ source_id=’<another unique id>’,n”, “ title=’An exercise containing a perseus question’,n”, “ author=’LE content team’,n”, “ description=’An example exercise with a Persus question’,n”, “ language=getlang(‘en’).code,n”, “ license=get_license(licenses.CC_BY, copyright_holder=’Copyright holder name’),n”, “ thumbnail=None,n”, “ exercise_data={n”, “ ‘mastery_model’: exercises.M_OF_N,n”, “ ‘m’: 1,n”, “ ‘n’: 1,n”, “ },n”, “ questions=[n”, “ PerseusQuestion(n”, “ id=’ex2bQ4’,n”, “ raw_data=RAW_PERSEUS_JSON_STR,n”, “ source_url=’https://github.com/learningequality/sample-channels/blob/master/contentnodes/exercise/perseus_graph_question.json’n”, “ ),n”, “ ]n”, “ )n”, “ topic.add_child(exercise_node2)n”, “n”, “ return channeln”

]

}, {

“cell_type”: “markdown”, “metadata”: {

“collapsed”: true

}, “source”: [

“### Running the chefn”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“Run of you chef by creating an instance of the chef class and calling it’s run method:”

]

}, {

“cell_type”: “code”, “execution_count”: 2, “metadata”: {}, “outputs”: [

{

“name”: “stderr”, “output_type”: “stream”, “text”: [

“u001b[32mINFO u001b[0m u001b[34mIn SushiChef.run method. args={‘command’: ‘dryrun’, ‘reset’: True, ‘verbose’: True, ‘token’: ‘YOURTO…’} options={}u001b[0mn”, “u001b[32mINFO u001b[0m u001b[34mn”, “n”, “* Starting channel build process *n”, “n”, “u001b[0mn”, “u001b[32mINFO u001b[0m u001b[34mCalling construct_channel… u001b[0mn”, “u001b[32mINFO u001b[0m u001b[34m Setting up initial channel structure… u001b[0mn”, “u001b[32mINFO u001b[0m u001b[34m Validating channel structure…u001b[0mn”, “u001b[32mINFO u001b[0m u001b[34m Sample Exercises (ChannelNode): 3 descendantsu001b[0mn”, “u001b[32mINFO u001b[0m u001b[34m Math Exercises (TopicNode): 2 descendantsu001b[0mn”, “u001b[32mINFO u001b[0m u001b[34m Basic questions (ExerciseNode): 3 questionsu001b[0mn”, “u001b[32mINFO u001b[0m u001b[34m An exercise containing a perseus question (ExerciseNode): 1 questionu001b[0mn”, “u001b[32mINFO u001b[0m u001b[34m Tree is validn”, “u001b[0mn”, “u001b[32mINFO u001b[0m u001b[34mDownloading files…u001b[0mn”, “u001b[32mINFO u001b[0m u001b[34mProcessing content…u001b[0mn”, “u001b[32mINFO u001b[0m u001b[34mt*** Processing images for exercise: Basic questionsu001b[0mn”, “u001b[32mINFO u001b[0m u001b[34mt*** Images for Basic questions have been processedu001b[0mn”, “u001b[32mINFO u001b[0m u001b[34mt*** Processing images for exercise: An exercise containing a perseus questionu001b[0mn”, “u001b[32mINFO u001b[0m u001b[34mt*** Images for An exercise containing a perseus question have been processedu001b[0mn”, “u001b[32mINFO u001b[0m u001b[34m All files were successfully downloadedu001b[0mn”, “u001b[32mINFO u001b[0m u001b[34mCommand is dryrun so we are not uploading chanel.u001b[0mn”

]

}

], “source”: [

“chef = ExercisesChef()n”, “args = {n”, “ ‘command’: ‘dryrun’, # use ‘uploadchannel’ for real runn”, “ ‘verbose’: True,n”, “ ‘token’: ‘YOURTOKENHERE9139139f3a23232’n”, “}n”, “options = {}n”, “n”, “chef.run(args, options)”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“Congratulations, you put some math exercises on the internet!”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

Note: you will need to change the value of CHANNEL_SOURCE_ID if youn”, “before you try running this script with {‘command’: ‘uploadchannel’, …}.n”, “The combination of source domain and source id are used to compute the channel_idn”, “for the Kolibri channel you’re creating. If you keep the lines above unchanged,n”, “you’ll get an error because you don’t have edit rights on that channel.”

]

}, {

“cell_type”: “code”, “execution_count”: null, “metadata”: {}, “outputs”: [], “source”: []

}

], “metadata”: {

“kernelspec”: {

“display_name”: “Python 3”, “language”: “python”, “name”: “python3”

}, “language_info”: {

“codemirror_mode”: {

“name”: “ipython”, “version”: 3

}, “file_extension”: “.py”, “mimetype”: “text/x-python”, “name”: “python”, “nbconvert_exporter”: “python”, “pygments_lexer”: “ipython3”, “version”: “3.7.4”

}

}, “nbformat”: 4, “nbformat_minor”: 2

}