{ "info": { "author": "I. Chuang", "author_email": "ichuang@mit.edu", "bugtrack_url": null, "classifiers": [], "description": "latex2dnd\n=========\n\nGenerate an edX drag-and-drop problem, complete with draggable labels, problem image, and\nsolution image, from an input latex file.\n\n![Example dnd problem image](https://github.com/mitocw/latex2dnd/raw/master/examples/example2/example2_dnd.png \"Example drag-and-drop problem: quadratic formula\")\n\nInstallation\n------------\n\n pip install -e git+https://github.com/mitocw/latex2dnd.git#egg=latex2dnd\n\nNote that pdftoppm is needed. With osX and macbrew:\n\n brew install netpbm poppler\n\nA working latex installation is also required.\n\nUsage\n-----\n\nUsage: latex2dnd [options] [filename.tex | filename.dndspec]\n\nOptions:\n --version show program's version number and exit\n -h, --help show this help message and exit\n -v, --verbose verbose messages\n -V, --very-verbose very verbose messages\n -C, --can-reuse-labels\n allow draggable labels to be reusable\n -s, --skip-latex-compilation\n skip latex compilation\n -d OUTPUT_DIR, --output-directory=OUTPUT_DIR\n Directory name for output PNG files\n -c CONFIG_FILE, --config-file=CONFIG_FILE\n configuration file to load\n -u IMAGE_URL, --url-for-images=IMAGE_URL\n base URL for images\n -r RESOLUTION, --resolution=RESOLUTION\n Resolution of PNG files in DPI (default 300), can set\n to 'max' to auto-scale\n --cfn=CUSTOM_CFN Name of python script check function to use for drag-\n drop checking\n --output-tex Final output should be a tex file (works when input is\n a *.dndspec file)\n --cleanup Remove old solution image files, and tmp.pdf\n --nonrandom Do not use a random string in the solution filename\n\nExample\n-------\n\nSee *.tex and *.dndspec files in the [examples directory](https://github.com/mitocw/latex2dnd/tree/master/examples).\n\n![Another example dnd problem image](https://github.com/mitocw/latex2dnd/raw/master/examples/example5/example5_dnd.png \"Example drag-and-drop problem: bloch sphere\")\n\nOr: get quadratic.tex from the latex2dnd/testtex directory, and run this:\n\n latex2dnd quadratic.tex -r 220 -v\n\nthis will generate 220dpi images, with the files:\n\n quadratic_dnd.xml -- edX drag-and-drop question XML\n ./quadratic_dnd.png -- dnd problem image\n ./quadratic_dnd_sol.png -- dnd problem solution image\n 9 dnd draggable image labels:\n ./quadratic_dnd_label1.png -- label '1'\n ./quadratic_dnd_label2.png -- label '2'\n ./quadratic_dnd_label3.png -- label '3'\n ./quadratic_dnd_label4.png -- label '4'\n ./quadratic_dnd_label5.png -- label '5'\n ./quadratic_dnd_label6.png -- label '6'\n ./quadratic_dnd_label7.png -- label '7'\n ./quadratic_dnd_label8.png -- label '8'\n ./quadratic_dnd_label9.png -- label '9'\n\nInsert this into your course with (if you're using https://github.com/mitocw/latex2edx):\n\n \\begin{edXproblem}{Latex to drag and drop test}{}\n \n \\edXinclude{quadratic_dnd.xml}\n \n \\end{edXproblem} \n\nand copy the png files to /static/images/quadratic/\n\nLaTeX Macros\n------------\n\nlatex2dnd works by introducing three important new macros:\n\n1. \\DDlabel{label_name}{label_contents} \n -- label_name = alphanumeric name (no spaces) for the draggable label\n -- label_contents = latex string for contents of label (math ok, e.g. $\\sqrt{a+b}$)\n\n2. \\DDBox{box_name}{width}{height}{label_name}\n -- box_name = alphanumeric name (no spaces) for the target box\n -- width, height = size of target box\n -- label_name = name of label which gives correct label to go in this box (the answer)\n\n3. \\writeDDlabels[height]\n -- height = optional argument which specifies the height of the labels (widths are automatic)\n\nHere is an example, giving the LaTeX code for a drag-and-drop question asking for the\nquadratic equation roots formula to be filled in:\n\n \\documentclass{article}\n \\input{latex2dnd}\n \n \\begin{document}\n \n % define drag-drop labels\n \\DDlabel{term1}{$-b$}\n \\DDlabel{term1p}{$+b$}\n \\DDlabel{term2}{$b^2$}\n \\DDlabel{dubexp}{$b^{2^\\alpha}$}\n \\DDlabel{dubsub}{$b_{2_\\alpha}$}\n \\DDlabel{fac}{$-4ac$}\n \\DDlabel{facp}{$+4ac$}\n \\DDlabel{ta}{$+2a$}\n \\DDlabel{tam}{$-2a$}\n \n % shorthand macro to make all boxes the same size (6 by 4)\n \\newcommand\\DDB[2]{\\DDbox{#1}{6ex}{4ex}{#2}}\n \n % the formula with boxes\n $$\\lambda = \\frac{\\DDB{1}{term1}\\pm \\sqrt{\\DDB{2}{term2}\\DDB{3}{fac}}}{\\DDB{4}{ta}}$$\n \n % output labels, with fixed box heights\n \\writeDDlabels[4.3ex]\n \n \\end{document}\n\nNote that more labels are defined than just the correct ones. This is the XML generated from the above example:\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n caset = [{'term1': '1'}, {'term2': '2'}, {'fac': '3'}, {'ta': '4'}]\n ca = [ {\"draggables\": ca.keys(),\"targets\": ca.values(),\"rule\":\"exact\"} for ca in caset ]\n if draganddrop.grade(submission[0], ca):\n correct = [\"correct\"]\n else:\n correct = [\"incorrect\"]\n \n \n \n \n \n \n\nSimplified DND Specification\n----------------------------\n\nLaTeX is powerful, but can be fragile. A simpler way to write DND\nproblems is to use a \"dndspec\" specification file; this provides a\nsimple plain-text based representation of a DND problem.\n\nExample:\n\n MATCH_LABELS: G,m_1,m_2,R\n BEGIN_EXPRESSION\n \\bea\n \t\\frac{ G m_1 m_2 }{ R }\n \\nonumber\n \\eea\n END_EXPRESSION\n CHECK_FORMULA: G * m_1 * m_2 / R\n\nThis input.dndspec file describes a DND problem with the labels\n\n \\DDlabel[G]{G}{$G$}\n \\DDlabel[m1]{mone}{$m_1$}\n \\DDlabel[m2]{mtwo}{$m_2$}\n \\DDlabel[R]{R}{$R$}\n\nthe DND expression (with boxes):\n\n \\bea\n \t\\frac{ \\DDB{1}{G} \\DDB{2}{mone} \\DDB{3}{mtwo} }{ \\DDB{4}{R} }\n \\nonumber\n \\eea\n\nwhere this tex macro is automatically defined for the box:\n\n \\newcommand\\DDB[2]{\\DDbox{#1}{8ex}{4ex}{#2}}\n\nand this check formula:\n\n \\DDformula{ ([1]) * ([2]) * ([3]) / ([4]) }{ G,m1,m2,R@1,1,1,1:20,20,20,20\\#20 }{ G * m1 * m2 / R }{}\n\nCompile this using\n\n latex2dnd -v input.dndspec\n\nand you'll get input.tex as the DND latex file (which can be edited\nfor futher customizations), together with all the usual output of latex2dnd.\n\nMore formally:\n\n MATCH_LABELS: \n DISTRACTOR_LABELS: \n ALL_LABELS: \n BEGIN_EXPRESSION\n \n END_EXPRESSION\n CHECK_FORMULA: \n CHECK_FORMULA_BOXES: \n TEST_CORRECT: formula which should evaluate to being correct\n TEST_INCORRECT: formula which should evaluate to being incorrect\n BOX_HEIGHT: draggable label box height to use\n BOX_WIDTH: draggable label box width to use\n EXTRA_HEADER_TEX: a line with extra latex commands to be inserted into the header (may be used multiple times)\n\nThere should be no leading spaces / indentation on lines with keywords (like MATCH_LABELS).\n\nAdvanced usage\n--------------\n\nHere are some additional useful macros:\n\n`\\DDoptions{}` -- extra configuration parameters, e.g. HIDE_FORMULA_INPUT, CAN_REUSE, and ALLOW_EMPTY\n\n`\\DDformula{ pattern }{ samples }{ expected }` -- use formula checking to test correctness of drag-and-drop response. For example:\n\n \\DDformula{ [1] * [2] * [3] / [4] }{ G,m_1,m_2,d@1,1,1,1:20,20,20,20\\#40 }{G*m_1*m_2/d^2}{}\n\n`\\DDtest{ correct | incorrect }{ answer_box_ids }{ draggable_ids }` -- unit test to perform on DDformula expressions, e.g.\n\n \\DDtest{correct}{1,2,3,4}{G,m2,m1,d2}\n \\DDtest{incorrect}{1,2,3,4}{G,d2,m1,m2}\n\nNotes\n-----\n\nlatex2dnd uses the \"-region\" feature of imagemagick's convert command,\nto white out solution boxes and generate the problem image. Version\n7.0.4 of imagemagick appears to have a bug in how it handles\n\"-region\", causing the region specification to be ignored, and thus\nproducing blank problem images (everything whited out). If you\nencounter this problem, one workaround is to back out to version 6.9.1\nof imagemagick.\n\nHistory\n-------\n\n```\n* v0.9.0: python package, with unit tests\n* .1: add -C (can_reuse) flag\n* .2: improved box alignment and pixel position computation\n* .3: center labels in boxes; custom code when can_reuse=true\n* .4: add formula grading and gravity.tex example\n* .5: add \\DDoptions{HIDE_FORMULA_INPUT} handling to not display formula input\n* .6: add \\DDoptins{CUSTOM_CFN=xxx} and --cfn=xxx command line for custom DND result check function\n* v1.0.0: add unit tests for DDformula, which automatically verify expected response is checked properly\n* v1.1.0: implement dndspec, a simplified DND problem specification language\n* .1: more improvements to dndspec; use random string in solution image filename; add examples\n```\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/latex2dnd/", "keywords": "", "license": "LICENSE.txt", "maintainer": "", "maintainer_email": "", "name": "latex2dnd", "package_url": "https://pypi.org/project/latex2dnd/", "platform": "", "project_url": "https://pypi.org/project/latex2dnd/", "project_urls": { "Homepage": "http://pypi.python.org/pypi/latex2dnd/" }, "release_url": "https://pypi.org/project/latex2dnd/1.1.1/", "requires_dist": null, "requires_python": "", "summary": "Generate edX drag-and-drop problems using compilation from latex", "version": "1.1.1" }, "last_serial": 2809515, "releases": { "0.0.9": [ { "comment_text": "", "digests": { "md5": "e55362a6db72b812cbd236d66f606b39", "sha256": "2225df27269756b856428a4b8c30d74f508b55f9382169f2d3b0a3f8a8522f59" }, "downloads": -1, "filename": "latex2dnd-0.0.9.tar.gz", "has_sig": false, "md5_digest": "e55362a6db72b812cbd236d66f606b39", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11840, "upload_time": "2014-03-22T02:44:12", "url": "https://files.pythonhosted.org/packages/aa/19/41e91748e69eadafdc57e73014e57e75188b357c7cc84dd7d40f2b64907b/latex2dnd-0.0.9.tar.gz" } ], "0.9.1": [ { "comment_text": "", "digests": { "md5": "3b20ee742f2a41658449e2b0a23f4dd6", "sha256": "7cd6c4a458dc1d603ab865d4f11a0d41cd74adb2ea46a1eadb31f83d414d5965" }, "downloads": -1, "filename": "latex2dnd-0.9.1.tar.gz", "has_sig": false, "md5_digest": "3b20ee742f2a41658449e2b0a23f4dd6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11977, "upload_time": "2014-03-23T01:40:41", "url": "https://files.pythonhosted.org/packages/43/09/73c3c4ec6b715597d7556841a2bc6ba58fb624ba164414c4e43b634d4ad7/latex2dnd-0.9.1.tar.gz" } ], "0.9.2": [ { "comment_text": "", "digests": { "md5": "152c8dc40ab13bd7e757fdfe8a1e2089", "sha256": "1420966e42576f5c118cc3ccd9c54a38fa072f39fe699cc1a28f439417bcfca8" }, "downloads": -1, "filename": "latex2dnd-0.9.2.tar.gz", "has_sig": false, "md5_digest": "152c8dc40ab13bd7e757fdfe8a1e2089", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12235, "upload_time": "2014-03-23T19:40:39", "url": "https://files.pythonhosted.org/packages/2c/aa/7785ff1be668d2acde64f0785f875d1584df1d0b3c476c593298e49c962f/latex2dnd-0.9.2.tar.gz" } ], "0.9.3": [ { "comment_text": "", "digests": { "md5": "1c1417a17ab252477118536f6fe77e9d", "sha256": "476f2eb5a8fe2e850fbc5baf0cdd2ce6232c825468028132bc07180d824ddf81" }, "downloads": -1, "filename": "latex2dnd-0.9.3.tar.gz", "has_sig": false, "md5_digest": "1c1417a17ab252477118536f6fe77e9d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12508, "upload_time": "2014-03-26T22:25:47", "url": "https://files.pythonhosted.org/packages/3f/03/90d863b330b476775da23b7a9dba771906f06372e03a2293b9b425ae0771/latex2dnd-0.9.3.tar.gz" } ], "0.9.4": [ { "comment_text": "", "digests": { "md5": "75c8071d5d10100d351862273c8511bf", "sha256": "c854777ebaee7cd843bf480f6b7b944f604797e6b9436a07a5e27f0ce7dabe3f" }, "downloads": -1, "filename": "latex2dnd-0.9.4.tar.gz", "has_sig": false, "md5_digest": "75c8071d5d10100d351862273c8511bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15227, "upload_time": "2014-03-30T19:45:30", "url": "https://files.pythonhosted.org/packages/cd/5b/f1b4a22581e94c0c1de789a3c583ba031a2fea6bd8528042a371bf83b533/latex2dnd-0.9.4.tar.gz" } ], "0.9.6": [ { "comment_text": "", "digests": { "md5": "a67dabddaa61f0d87d6125acc166dee2", "sha256": "381c5d69571a83c01b7eb0fc3bb55f2053d6809c5fe16e03e13f907970205dda" }, "downloads": -1, "filename": "latex2dnd-0.9.6.tar.gz", "has_sig": false, "md5_digest": "a67dabddaa61f0d87d6125acc166dee2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16604, "upload_time": "2014-07-12T22:00:46", "url": "https://files.pythonhosted.org/packages/d3/79/1230ab91af17b85efec6021053029ed05585eaa3936b5c32da1578785eae/latex2dnd-0.9.6.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "8cd2d29ec7cc22d9c38048f2982dcebf", "sha256": "7a467b9d00b288d82564fdb0d8ae110c67be5e8348cde016d9274df9bbd8daab" }, "downloads": -1, "filename": "latex2dnd-1.0.0.tar.gz", "has_sig": false, "md5_digest": "8cd2d29ec7cc22d9c38048f2982dcebf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20086, "upload_time": "2017-04-15T22:14:49", "url": "https://files.pythonhosted.org/packages/44/aa/fff492679cf59bd0e3e46ccfd3c95071b25aa5998e5c67fa54c70ef409c4/latex2dnd-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "d1cb216013019f9728d4ec8074ee6286", "sha256": "93ba271858ba20a85550d11faeac0210a02c8a338f6621ae7b342fadb2e2734b" }, "downloads": -1, "filename": "latex2dnd-1.1.0.tar.gz", "has_sig": false, "md5_digest": "d1cb216013019f9728d4ec8074ee6286", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27974, "upload_time": "2017-04-17T02:17:46", "url": "https://files.pythonhosted.org/packages/c1/36/90e9539aa04130ae5fb35cb9b37f669a4e4ddf3144685f21f3fae1eb6a4f/latex2dnd-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "97411d8e3d2bd0a4eb442a35523b22e5", "sha256": "fbb59a084b12d4d7d051c17913f4666bab8de5f9c53142a4e4c121dd85a77b35" }, "downloads": -1, "filename": "latex2dnd-1.1.1.tar.gz", "has_sig": false, "md5_digest": "97411d8e3d2bd0a4eb442a35523b22e5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30586, "upload_time": "2017-04-17T20:09:49", "url": "https://files.pythonhosted.org/packages/30/7f/55f6b402623add0ee7aaf7cb2e6799c1ee36bbd8f9b4084292e97feccdd3/latex2dnd-1.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "97411d8e3d2bd0a4eb442a35523b22e5", "sha256": "fbb59a084b12d4d7d051c17913f4666bab8de5f9c53142a4e4c121dd85a77b35" }, "downloads": -1, "filename": "latex2dnd-1.1.1.tar.gz", "has_sig": false, "md5_digest": "97411d8e3d2bd0a4eb442a35523b22e5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30586, "upload_time": "2017-04-17T20:09:49", "url": "https://files.pythonhosted.org/packages/30/7f/55f6b402623add0ee7aaf7cb2e6799c1ee36bbd8f9b4084292e97feccdd3/latex2dnd-1.1.1.tar.gz" } ] }