From ef80fd160088e4f02036035a7f910a923d6735c4 Mon Sep 17 00:00:00 2001 From: Akshat Poddar Date: Thu, 19 Aug 2021 17:28:17 -0700 Subject: [PATCH] Changed file name in examples for easier import and added some code --- .../PL to Markdown testing-checkpoint.ipynb | 221 ++++++++++++++++++ pl_to_md/PL to Markdown testing.ipynb | 186 ++++++++++++++- .../.ipynb_checkpoints/info-checkpoint.json | 7 + .../question-checkpoint.html | 20 ++ .../.ipynb_checkpoints/server-checkpoint.py | 68 ++++++ .../__pycache__/server.cpython-39.pyc | Bin 0 -> 2343 bytes .../.ipynb_checkpoints/server-checkpoint.py} | 0 .../__pycache__/server.cpython-39.pyc | Bin 0 -> 1526 bytes .../clientFilesQuestion/q7_2012Final.png | Bin .../info.json | 0 .../question.html | 0 .../server.py | 54 +++++ .../Exploding_Asteroid-checkpoint.md | 120 ++++++++++ 13 files changed, 674 insertions(+), 2 deletions(-) create mode 100644 pl_to_md/.ipynb_checkpoints/PL to Markdown testing-checkpoint.ipynb create mode 100644 pl_to_md/examples/Exploding_Asteroid/.ipynb_checkpoints/info-checkpoint.json create mode 100644 pl_to_md/examples/Exploding_Asteroid/.ipynb_checkpoints/question-checkpoint.html create mode 100644 pl_to_md/examples/Exploding_Asteroid/.ipynb_checkpoints/server-checkpoint.py create mode 100644 pl_to_md/examples/Exploding_Asteroid/__pycache__/server.cpython-39.pyc rename pl_to_md/examples/{Two blocks connected by a string/server.py => Two_blocks_connected_by_a_string/.ipynb_checkpoints/server-checkpoint.py} (100%) create mode 100644 pl_to_md/examples/Two_blocks_connected_by_a_string/__pycache__/server.cpython-39.pyc rename pl_to_md/examples/{Two blocks connected by a string => Two_blocks_connected_by_a_string}/clientFilesQuestion/q7_2012Final.png (100%) rename pl_to_md/examples/{Two blocks connected by a string => Two_blocks_connected_by_a_string}/info.json (100%) rename pl_to_md/examples/{Two blocks connected by a string => Two_blocks_connected_by_a_string}/question.html (100%) create mode 100644 pl_to_md/examples/Two_blocks_connected_by_a_string/server.py create mode 100644 pl_to_md/expected_md/Exploding_Asteroid/.ipynb_checkpoints/Exploding_Asteroid-checkpoint.md diff --git a/pl_to_md/.ipynb_checkpoints/PL to Markdown testing-checkpoint.ipynb b/pl_to_md/.ipynb_checkpoints/PL to Markdown testing-checkpoint.ipynb new file mode 100644 index 00000000..fd4aaebb --- /dev/null +++ b/pl_to_md/.ipynb_checkpoints/PL to Markdown testing-checkpoint.ipynb @@ -0,0 +1,221 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Convert from PrairieLearn format to a Markdown format" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import yaml" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Python Code section" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": {}, + "outputs": [], + "source": [ + "from inspect import getmembers, isfunction\n", + "import importlib\n", + "import examples.Two_blocks_connected_by_a_string.server as server_module" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": {}, + "outputs": [], + "source": [ + "path = 'examples/Two_blocks_connected_by_a_string/server.py'\n" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "metadata": {}, + "outputs": [], + "source": [ + "functions_list = getmembers(server_module, isfunction)" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[('generate',\n", + " ),\n", + " ('grade',\n", + " ),\n", + " ('nested_dict',\n", + " ()>),\n", + " ('parse',\n", + " ),\n", + " ('prepare',\n", + " )]" + ] + }, + "execution_count": 84, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "functions_list" + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'generate'" + ] + }, + "execution_count": 85, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "functions_list[0][0]" + ] + }, + { + "cell_type": "code", + "execution_count": 86, + "metadata": {}, + "outputs": [], + "source": [ + "code = []\n", + "with open(path,'r') as f:\n", + " code = f.readlines()" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['import random as rd\\n',\n", + " 'import problem_bank_helpers as pbh\\n',\n", + " 'from collections import defaultdict\\n',\n", + " 'nested_dict = lambda: defaultdict(nested_dict)\\n',\n", + " '\\n',\n", + " 'def generate(data):\\n',\n", + " ' # Start problem code\\n',\n", + " ' \\n',\n", + " ' data2 = nested_dict()\\n',\n", + " ' \\n',\n", + " ' # store phrases etc\\n',\n", + " ' data2[\"params\"][\"vars\"][\"title\"] = \\'Two Blocks Connected by a String\\'\\n',\n", + " ' data2[\"params\"][\"vars\"][\"units\"] = \"N\"\\n',\n", + " ' \\n',\n", + " ' # Define variables in case the image is randomized in the future.\\n',\n", + " ' m1 = 1\\n',\n", + " ' m2 = 1.2\\n',\n", + " ' g = 9.81\\n',\n", + " ' \\n',\n", + " ' # store the variables in the dictionary \"params\". \\n',\n", + " ' data2[\"params\"][\"m1\"] = m1\\n',\n", + " ' \\n',\n", + " ' # define possible answers\\n',\n", + " ' # round in traditional way using pbh.roundp() and then convert to int\\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans1\"][\"value\"] = int(pbh.roundp(m1*g, decimals = 0)) \\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans1\"][\"correct\"] = False\\n',\n", + " ' \\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans2\"][\"value\"] = int(pbh.roundp(m2*g, decimals = 0))\\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans2\"][\"correct\"] = True\\n',\n", + " ' \\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans3\"][\"value\"] = int(pbh.roundp(2*m2*g, decimals = 0))\\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans3\"][\"correct\"] = False\\n',\n", + " ' \\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans4\"][\"value\"] = int(pbh.roundp(2*m1*g, decimals = 0))\\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans4\"][\"correct\"] = False\\n',\n", + " ' \\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans5\"][\"value\"] = int(pbh.roundp(m2*g, decimals = 0)) + 1\\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans5\"][\"correct\"] = False\\n',\n", + " ' \\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans6\"][\"value\"] = int(pbh.roundp(m2*g, decimals = 0)) - 1\\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans6\"][\"correct\"] = False\\n',\n", + " ' \\n',\n", + " ' # Update the data object with a new dict\\n',\n", + " ' data.update(data2)\\n',\n", + " ' \\n',\n", + " 'def prepare(data):\\n',\n", + " ' pass\\n',\n", + " ' \\n',\n", + " 'def parse(data):\\n',\n", + " ' pass\\n',\n", + " ' \\n',\n", + " 'def grade(data):\\n',\n", + " ' pass\\n',\n", + " ' \\n']" + ] + }, + "execution_count": 87, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "code " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for line in code:\n", + " if 'data.update(data2)' in line:\n", + " " + ] + } + ], + "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.9.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/pl_to_md/PL to Markdown testing.ipynb b/pl_to_md/PL to Markdown testing.ipynb index 01b5e4b3..fd4aaebb 100644 --- a/pl_to_md/PL to Markdown testing.ipynb +++ b/pl_to_md/PL to Markdown testing.ipynb @@ -7,12 +7,194 @@ "# Convert from PrairieLearn format to a Markdown format" ] }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import yaml" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Python Code section" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": {}, + "outputs": [], + "source": [ + "from inspect import getmembers, isfunction\n", + "import importlib\n", + "import examples.Two_blocks_connected_by_a_string.server as server_module" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": {}, + "outputs": [], + "source": [ + "path = 'examples/Two_blocks_connected_by_a_string/server.py'\n" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "metadata": {}, + "outputs": [], + "source": [ + "functions_list = getmembers(server_module, isfunction)" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[('generate',\n", + " ),\n", + " ('grade',\n", + " ),\n", + " ('nested_dict',\n", + " ()>),\n", + " ('parse',\n", + " ),\n", + " ('prepare',\n", + " )]" + ] + }, + "execution_count": 84, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "functions_list" + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'generate'" + ] + }, + "execution_count": 85, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "functions_list[0][0]" + ] + }, + { + "cell_type": "code", + "execution_count": 86, + "metadata": {}, + "outputs": [], + "source": [ + "code = []\n", + "with open(path,'r') as f:\n", + " code = f.readlines()" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['import random as rd\\n',\n", + " 'import problem_bank_helpers as pbh\\n',\n", + " 'from collections import defaultdict\\n',\n", + " 'nested_dict = lambda: defaultdict(nested_dict)\\n',\n", + " '\\n',\n", + " 'def generate(data):\\n',\n", + " ' # Start problem code\\n',\n", + " ' \\n',\n", + " ' data2 = nested_dict()\\n',\n", + " ' \\n',\n", + " ' # store phrases etc\\n',\n", + " ' data2[\"params\"][\"vars\"][\"title\"] = \\'Two Blocks Connected by a String\\'\\n',\n", + " ' data2[\"params\"][\"vars\"][\"units\"] = \"N\"\\n',\n", + " ' \\n',\n", + " ' # Define variables in case the image is randomized in the future.\\n',\n", + " ' m1 = 1\\n',\n", + " ' m2 = 1.2\\n',\n", + " ' g = 9.81\\n',\n", + " ' \\n',\n", + " ' # store the variables in the dictionary \"params\". \\n',\n", + " ' data2[\"params\"][\"m1\"] = m1\\n',\n", + " ' \\n',\n", + " ' # define possible answers\\n',\n", + " ' # round in traditional way using pbh.roundp() and then convert to int\\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans1\"][\"value\"] = int(pbh.roundp(m1*g, decimals = 0)) \\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans1\"][\"correct\"] = False\\n',\n", + " ' \\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans2\"][\"value\"] = int(pbh.roundp(m2*g, decimals = 0))\\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans2\"][\"correct\"] = True\\n',\n", + " ' \\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans3\"][\"value\"] = int(pbh.roundp(2*m2*g, decimals = 0))\\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans3\"][\"correct\"] = False\\n',\n", + " ' \\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans4\"][\"value\"] = int(pbh.roundp(2*m1*g, decimals = 0))\\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans4\"][\"correct\"] = False\\n',\n", + " ' \\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans5\"][\"value\"] = int(pbh.roundp(m2*g, decimals = 0)) + 1\\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans5\"][\"correct\"] = False\\n',\n", + " ' \\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans6\"][\"value\"] = int(pbh.roundp(m2*g, decimals = 0)) - 1\\n',\n", + " ' data2[\"params\"][\"part1\"][\"ans6\"][\"correct\"] = False\\n',\n", + " ' \\n',\n", + " ' # Update the data object with a new dict\\n',\n", + " ' data.update(data2)\\n',\n", + " ' \\n',\n", + " 'def prepare(data):\\n',\n", + " ' pass\\n',\n", + " ' \\n',\n", + " 'def parse(data):\\n',\n", + " ' pass\\n',\n", + " ' \\n',\n", + " 'def grade(data):\\n',\n", + " ' pass\\n',\n", + " ' \\n']" + ] + }, + "execution_count": 87, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "code " + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "for line in code:\n", + " if 'data.update(data2)' in line:\n", + " " + ] } ], "metadata": { @@ -31,7 +213,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.3" + "version": "3.9.5" } }, "nbformat": 4, diff --git a/pl_to_md/examples/Exploding_Asteroid/.ipynb_checkpoints/info-checkpoint.json b/pl_to_md/examples/Exploding_Asteroid/.ipynb_checkpoints/info-checkpoint.json new file mode 100644 index 00000000..da7dc2a9 --- /dev/null +++ b/pl_to_md/examples/Exploding_Asteroid/.ipynb_checkpoints/info-checkpoint.json @@ -0,0 +1,7 @@ +{ + "uuid": "ae574feb-fa63-44c5-86e7-732faf5e5ca4", + "title": "Exploding Asteroid", + "topic": "Energy", + "tags": ["AK"], + "type": "v3" + } \ No newline at end of file diff --git a/pl_to_md/examples/Exploding_Asteroid/.ipynb_checkpoints/question-checkpoint.html b/pl_to_md/examples/Exploding_Asteroid/.ipynb_checkpoints/question-checkpoint.html new file mode 100644 index 00000000..89e1dcbd --- /dev/null +++ b/pl_to_md/examples/Exploding_Asteroid/.ipynb_checkpoints/question-checkpoint.html @@ -0,0 +1,20 @@ + +{{ params.vars.name }} and {{ params.vars.name2 }} are both standing in their space ships, each one moving with a constant (but different) velocity. They carefully watch and measure, from their two space ships, an asteroid exploding into two parts. When they compare their final numbers, which of their numbers will agree? + + + + + {{ params.part1.ans1.value }} + {{ params.part1.ans2.value }} + {{ params.part1.ans3.value }} + {{ params.part1.ans4.value }} + {{ params.part1.ans5.value }} + {{ params.part1.ans6.value }} + + + + +--- +Problem is licensed under the [CC-BY-NC-SA 4.0 license](https://creativecommons.org/licenses/by-nc-sa/4.0/).
![The Creative Commons 4.0 license requiring attribution-BY, non-commercial-NC, and share-alike-SA license.](https://raw.githubusercontent.com/firasm/bits/master/by-nc-sa.png) +
+
diff --git a/pl_to_md/examples/Exploding_Asteroid/.ipynb_checkpoints/server-checkpoint.py b/pl_to_md/examples/Exploding_Asteroid/.ipynb_checkpoints/server-checkpoint.py new file mode 100644 index 00000000..b1123143 --- /dev/null +++ b/pl_to_md/examples/Exploding_Asteroid/.ipynb_checkpoints/server-checkpoint.py @@ -0,0 +1,68 @@ +import random +import pandas as pd +import problem_bank_helpers as pbh +from collections import defaultdict +nested_dict = lambda: defaultdict(nested_dict) + +def generate(data): + # Start problem code + + data2 = nested_dict() + + # define or load names/items/objects + names = pd.read_csv(data["options"]["client_files_course_path"]+"/data/names.csv")["Names"].tolist() + + # store phrases etc + data2["params"]["vars"]["title"] = 'Exploding Asteroid' + data2["params"]["vars"]["name"] = random.choice(names) + data2["params"]["vars"]["name2"] = random.choice(names) + + # define useful variables/lists + + # create list of answers and shuffle + answers = [ + "The momentum vectors they use to describe each of the two asteroid pieces will be the same.", + "The total momentum vectors they use to describe the asteroid system (both pieces) will be the same.", + "The CHANGE in the momentum vector they determine for each piece of the asteroid before and after the explosion will be the same.", + "The FORCE vector they determine that each piece of the asteroid felt during the explosion will be the same.", + "The final velocity vectors they use to describe the two asteroid pieces will be the same.", + "The final speeds they measure for the two asteroid pieces will be the same.", + "They will both agree on how much kinetic energy each of the asteroid pieces has.", + "They will both agree on how the kinetic energy of each of the pieces has changed.", + "They will both agree on how the TOTAL kinetic energy of the system has changed.", + "They will both agree on how the internal energy of the system has changed." + ] + + correct_answers = [ + "The momentum vectors they use to describe each of the two asteroid pieces will be the same.", + "The total momentum vectors they use to describe the asteroid system (both pieces) will be the same.", + "The final velocity vectors they use to describe the two asteroid pieces will be the same.", + "The final speeds they measure for the two asteroid pieces will be the same.", + "They will both agree on how much kinetic energy each of the asteroid pieces has.", + ] + + random.shuffle(answers) + + # Create ans_choices + num_choices = 6 + + for i,this_answer in enumerate(random.sample(answers,num_choices)): + + choice = f"ans{i+1}" + + data2["params"]["part1"][choice]["value"] = this_answer + + if this_answer in correct_answers: + data2["params"]["part1"][choice]["correct"] = False + else: + data2["params"]["part1"][choice]["correct"] = True + +def prepare(data): + pass + +def parse(data): + pass + +def grade(data): + pass + diff --git a/pl_to_md/examples/Exploding_Asteroid/__pycache__/server.cpython-39.pyc b/pl_to_md/examples/Exploding_Asteroid/__pycache__/server.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e8eadd8eb1bd04820329ec287b18cdbd10898d94 GIT binary patch literal 2343 zcmb_e&2QsG6d&8M<0SpsQrazt%Hm7p(ukF~MGK|d1p#UowtK)ViYA^(Y}NLdnMt~- z5(%lC`3DeE%dP(q2a5v|r(O^ex1M;e}-<$W|%!JO))(L#S{kcYe zhuR<5nEp&?d;~>30l^3}V&b1`!#9hzk(IbT4b$62sMmaDv(j8RV#}-T67ZD;xA~D z#ay+vUSzRgQQGfp0I(DhYXQ!X%k^xOyX}}JT}B@w&)-mptbzy(td?I5G!7S5{{8G_7Vu~>)Ux%WI7V5^6v+6#8chrMc~{{ zAO=$LPDXWjFyCTS(^g6ouGRxJ^zCh|9xPr)z`KY*?qpQbMCFwsl`6M&q+^~}aH(&j ze9)|)eX|>KFA)i_4H9q211+TTbjU~EKygnCk8uopmwTKBp(lDc=;?jo(K6Cr7V&^9 zZ$FA-59Z;x0{Hc_0Kv7;G=4=2TzUzsMnI5w?{$R^OOEEhNe;e8lFd&ywm;eOqO@SY zwx9FuFb;{CL@D=rLY{A?F#KXmm%LpL6Tps?d9(*>3P_F#t{^x!Sg?l{Jl^?gbE|aV zbwUki={Ck5kG01J63)+EWM^L^SuaY#r$Zi#Akw4T!-hV6wQzlY1+6m9S(yh3r)mHW zLASj+*b@L7mCnKd(!S)}1OJ6$-%AFNN_!9s9R(gwx$KW#O0UaUl&KX`wSMsBZHQ>t zH9$z!>6E>K@`8}2ea_YocJ6}Q-Pzsv;s#)(EAta-jKbiRyDrbu4OmTE z&cQt>=TR)6xQAj9#Hj-!w`i(P@ecKEIOzKQ+#b?+z#se7Ku8HEdAC`U6`W~i%y%WH ztOGYj?r0H5O6QJ*6cx^k==I==sPS}=a7i`K9XQBv!8dDp1@9f-M)@Ew zt`C)0!Ge8wF8ukDv2)SU0EEstuF8$bZ|E>m<*0lEY`S`LWU(2yj}8G!d>Pal2x2+b znzdjo8_Tvk>$-KTV%|6B%q7z`mQDF4%y{VqK~G>QUJ%?igIiTvP${@h42h`Md8?V^ z;62`kF@}l#+WGnA&gwWzVpAp_9bQf<0;s8q28R4tDx}4PZ?Em z1seWRCPg>qNvBKGy-vvE3`1pQ-7s$iB90+L@UbcW5fph+__Wx)L|Y{yPi+gI=Q3FB aM6f~3AELh%=B8`lZ^m#<_XF2*t$zSKV2 z3rIW%MiIp^YGWg^14fl18BnwX!($&$oeu2TUS~4*`6HcbXR0CRI(DkcUYu z|CL}|_@pQHiS(Z`(UV#3Cs`&2kuO3X09LOw4sL$S!B#)W!_ughfC(gp22*NB) zS*X2t4gwMg$)mLEgVzD$EBS%)S}{pFlx#Zi*Ha+G%fLdcr{_Zlq{-xP3>JwF(FjvK z#MD}Vk^wm_MBT!=1nct1qTa}+6C-D6o!crc$X{A-Y|uD$q|5oqIvjhdfu|{;X+Y1M zBgVQL7fAaWDrsX+Qh;r@< zwANjVo-d;3uRv=Zpoi#-GsIspG&X{UUD$cwfaYjCG0oA~9ydp$bI>4-UDF(@loL)8 zp_~EXLb)=MF;jR)x&1Vf;zV~wcioKB$K9omKVBSvzPF{UWR+_ZTn3M_FiJ=aU~nZ@ z+YU*^s&WS;?z3mA9A=zDPa5^w-if{gX1;FthT#tlf7EojZcJrIsZ@5}*;gf=^;4Rw zQa`6evZkvXkVLtfukmTU+e+3H?*6$*9G(QEye>-_2aH~cWnjoI*)w>?b})SQq;ntF zElm$Dlg;nI-b+_PXR66u2_2y>FSlW0{(6M@!gzibhKZn@a|RV*D_|2kZG`y}@PBd5 z7Xk2hYP!yXt%7Cjw((!wb~&MJqu}-~%$rp>1d`G$Q5L7Fp7X2|vn1${v={8NIEN>T z&%#Dk4YN3gla8`fn5WJhrm3dMn>Sz=*FFmgndk59z*{;Hj HXM6T<=+HQ> literal 0 HcmV?d00001 diff --git a/pl_to_md/examples/Two blocks connected by a string/clientFilesQuestion/q7_2012Final.png b/pl_to_md/examples/Two_blocks_connected_by_a_string/clientFilesQuestion/q7_2012Final.png similarity index 100% rename from pl_to_md/examples/Two blocks connected by a string/clientFilesQuestion/q7_2012Final.png rename to pl_to_md/examples/Two_blocks_connected_by_a_string/clientFilesQuestion/q7_2012Final.png diff --git a/pl_to_md/examples/Two blocks connected by a string/info.json b/pl_to_md/examples/Two_blocks_connected_by_a_string/info.json similarity index 100% rename from pl_to_md/examples/Two blocks connected by a string/info.json rename to pl_to_md/examples/Two_blocks_connected_by_a_string/info.json diff --git a/pl_to_md/examples/Two blocks connected by a string/question.html b/pl_to_md/examples/Two_blocks_connected_by_a_string/question.html similarity index 100% rename from pl_to_md/examples/Two blocks connected by a string/question.html rename to pl_to_md/examples/Two_blocks_connected_by_a_string/question.html diff --git a/pl_to_md/examples/Two_blocks_connected_by_a_string/server.py b/pl_to_md/examples/Two_blocks_connected_by_a_string/server.py new file mode 100644 index 00000000..8b22cec3 --- /dev/null +++ b/pl_to_md/examples/Two_blocks_connected_by_a_string/server.py @@ -0,0 +1,54 @@ +import random as rd +import problem_bank_helpers as pbh +from collections import defaultdict +nested_dict = lambda: defaultdict(nested_dict) + +def generate(data): + # Start problem code + + data2 = nested_dict() + + # store phrases etc + data2["params"]["vars"]["title"] = 'Two Blocks Connected by a String' + data2["params"]["vars"]["units"] = "N" + + # Define variables in case the image is randomized in the future. + m1 = 1 + m2 = 1.2 + g = 9.81 + + # store the variables in the dictionary "params". + data2["params"]["m1"] = m1 + + # define possible answers + # round in traditional way using pbh.roundp() and then convert to int + data2["params"]["part1"]["ans1"]["value"] = int(pbh.roundp(m1*g, decimals = 0)) + data2["params"]["part1"]["ans1"]["correct"] = False + + data2["params"]["part1"]["ans2"]["value"] = int(pbh.roundp(m2*g, decimals = 0)) + data2["params"]["part1"]["ans2"]["correct"] = True + + data2["params"]["part1"]["ans3"]["value"] = int(pbh.roundp(2*m2*g, decimals = 0)) + data2["params"]["part1"]["ans3"]["correct"] = False + + data2["params"]["part1"]["ans4"]["value"] = int(pbh.roundp(2*m1*g, decimals = 0)) + data2["params"]["part1"]["ans4"]["correct"] = False + + data2["params"]["part1"]["ans5"]["value"] = int(pbh.roundp(m2*g, decimals = 0)) + 1 + data2["params"]["part1"]["ans5"]["correct"] = False + + data2["params"]["part1"]["ans6"]["value"] = int(pbh.roundp(m2*g, decimals = 0)) - 1 + data2["params"]["part1"]["ans6"]["correct"] = False + + # Update the data object with a new dict + data.update(data2) + +def prepare(data): + pass + +def parse(data): + pass + +def grade(data): + pass + diff --git a/pl_to_md/expected_md/Exploding_Asteroid/.ipynb_checkpoints/Exploding_Asteroid-checkpoint.md b/pl_to_md/expected_md/Exploding_Asteroid/.ipynb_checkpoints/Exploding_Asteroid-checkpoint.md new file mode 100644 index 00000000..8d10ae86 --- /dev/null +++ b/pl_to_md/expected_md/Exploding_Asteroid/.ipynb_checkpoints/Exploding_Asteroid-checkpoint.md @@ -0,0 +1,120 @@ +--- +title: Exploding Asteroid +topic: Energy +author: Jake Bobowski +source: Final 2016 Q6 +template_version: 1.0 +attribution: standard +outcomes: +- 8.2.1.1 +difficulty: +- undefined +randomization: +- undefined +taxonomy: +- undefined +tags: +- AK +assets: +server: + imports: | + import random + import pandas as pd + import problem_bank_helpers as pbh + from collections import defaultdict + nested_dict = lambda: defaultdict(nested_dict) + generate: | + # Start problem code + + data2 = nested_dict() + + # define or load names/items/objects + names = pd.read_csv("data/names.csv")["Names"].tolist() + + # store phrases etc + data2["params"]["vars"]["title"] = 'Exploding Asteroid' + data2["params"]["vars"]["name"] = random.choice(names) + data2["params"]["vars"]["name2"] = random.choice(names) + + # define useful variables/lists + + # create list of answers and shuffle + answers = [ + "The momentum vectors they use to describe each of the two asteroid pieces will be the same.", + "The total momentum vectors they use to describe the asteroid system (both pieces) will be the same.", + "The CHANGE in the momentum vector they determine for each piece of the asteroid before and after the explosion will be the same.", + "The FORCE vector they determine that each piece of the asteroid felt during the explosion will be the same.", + "The final velocity vectors they use to describe the two asteroid pieces will be the same.", + "The final speeds they measure for the two asteroid pieces will be the same.", + "They will both agree on how much kinetic energy each of the asteroid pieces has.", + "They will both agree on how the kinetic energy of each of the pieces has changed.", + "They will both agree on how the TOTAL kinetic energy of the system has changed.", + "They will both agree on how the internal energy of the system has changed." + ] + + correct_answers = [ + "The momentum vectors they use to describe each of the two asteroid pieces will be the same.", + "The total momentum vectors they use to describe the asteroid system (both pieces) will be the same.", + "The final velocity vectors they use to describe the two asteroid pieces will be the same.", + "The final speeds they measure for the two asteroid pieces will be the same.", + "They will both agree on how much kinetic energy each of the asteroid pieces has.", + ] + + random.shuffle(answers) + + # Create ans_choices + num_choices = 6 + + for i,this_answer in enumerate(random.sample(answers,num_choices)): + + choice = f"ans{i+1}" + + data2["params"]["part1"][choice]["value"] = this_answer + + if this_answer in correct_answers: + data2["params"]["part1"][choice]["correct"] = False + else: + data2["params"]["part1"][choice]["correct"] = True + prepare: | + pass + parse: | + pass + grade: | + pass +part1: + type: checkbox + pl-customizations: + weight: 1 + partial-credit: true + partial-credit-method: EDC +--- +# {{ params.vars.title }} + +## Question Text + +{{ params.vars.name }} and {{ params.vars.name2 }} are both standing in their space ships, each one moving with a constant (but different) velocity. They carefully watch and measure, from their two space ships, an asteroid exploding into two parts. When they compare their final numbers, which of their numbers will agree? + +### Answer Section + +Select all the choices that apply. + +Note: You will be awarded full marks only if you select all the correct choices, and none of the incorrect choices. Choosing incorrect choices as well as not choosing correct choices will result in deductions. + +- {{ params.part1.ans1.value }} +- {{ params.part1.ans2.value }} +- {{ params.part1.ans3.value }} +- {{ params.part1.ans4.value }} +- {{ params.part1.ans5.value }} +- {{ params.part1.ans6.value }} + +## Rubric + +This should be hidden from students until after the deadline. + +## Solution + +This should never be revealed to students. + +## Comments + +These are random comments associated with this question.