{"id":18330939,"url":"https://github.com/dataquestio/caravan","last_synced_at":"2026-03-16T07:07:56.647Z","repository":{"id":146402107,"uuid":"102657733","full_name":"dataquestio/caravan","owner":"dataquestio","description":"Let your blog visitors run code and get their answers checked using Dataquest.","archived":false,"fork":false,"pushed_at":"2018-03-21T12:49:56.000Z","size":26,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-09T18:54:09.018Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.dataquest.io","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dataquestio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-06T20:59:09.000Z","updated_at":"2019-01-14T23:09:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"b52a5a17-7084-488f-8580-ca98add8c410","html_url":"https://github.com/dataquestio/caravan","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dataquestio/caravan","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataquestio%2Fcaravan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataquestio%2Fcaravan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataquestio%2Fcaravan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataquestio%2Fcaravan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dataquestio","download_url":"https://codeload.github.com/dataquestio/caravan/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataquestio%2Fcaravan/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30571267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-16T06:02:37.763Z","status":"ssl_error","status_checked_at":"2026-03-16T06:02:14.913Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T19:27:14.664Z","updated_at":"2026-03-16T07:07:56.629Z","avatar_url":"https://github.com/dataquestio.png","language":null,"readme":"# Dataquest Caravan\n\nEmbed a code editor in your blog that allows your visitors to write code, run it, and get answer checked.  The same great interface that powers [Dataquest](https://www.dataquest.io) is now available to you!\n\n![Editor Screenshot](https://s3.amazonaws.com/dq-content/caravan/editor_screen.png)\n\n## Usage steps\n\nIn order to use the editor, you'll need to import a javascript library globally, then instantiate each editor with some HTML.\n\nHere's the import code for the javascript library:\n\n```html\n\u003cscript src=\"//dqeditor.dataquest.io/dq_post_box.js\"\u003e\u003c/script\u003e\n```\n\nMake sure to insert the code where your other javascript code is imported.\n\nFor each editor you want to instantiate, you just need to insert some HTML:\n\n```html\n\u003ciframe name=\"dq_editor\" width=\"100%\" height=\"350\" src=\"//dqeditor.dataquest.io/\" style=\"border: none\" \u003e\n  \u003cpre id=\"initialization-code\"\u003e\n  \u003c/pre\u003e\n  \u003cpre id=\"code\"\u003e\n  # Hello world!\n  \u003c/pre\u003e\n  \u003cpre id=\"hint\"\u003e\n  \u003c/pre\u003e\n  \u003cpre id=\"answer-code\" check-vars=\"\"\u003e\n  \u003c/pre\u003e\n\u003c/iframe\u003e\n```\n\nThe above code will give you an editor with a single line shown, where you can write and run code.  To customize the editor and add initial code and answer checking, see the next section.\n\n## Section details\n\n### Changing height\nTo change the height of the editor change the attribute `height=700` to a different pixel size.\n\n### `\u003cpre id=\"code\"\u003e`\nThe code provided in this section will be what the editor starts with when rendered to the student.  This is what the student will see when they first load the blog post or website page.\n\n### `\u003cpre id=\"initialization-code\"\u003e`\nThe code provided in this section will be prepended to the student code before running.  This can be used to import libraries or initialize data transparently to the student.\n\n### `\u003cpre id=\"hint\"\u003e`\nThe markdown text in this section will be shown when the student clicks on the \"Hint\" button in the editor.  This can be used to help students get an answer correct.\n\n### `\u003cpre id=\"answer-code\"\u003e`\nThe code provide here is the correct answer code.  This will be used to answer check the student, and to generate dynamic hints when students get the answer incorrect.\n\n#### Checking variables\nTo check variables between the answer code and student code list them, comma separated on the attribue `check-vars=\"\"` like `check-vars=\"x, count\"`.  Make sure that these variables are defined in the initial code, display code, or answer code.  This will check the variable values in the answer code against the variable values in the student code.\n\n#### Checking output\nTo check the output of a student's code, add the attribute `check-stdout`.  If you do not want to check the stdout remove the attribute.  This will match the output of the answer code with the output of the student code, and see if there are differences.\n\n## Loading datasets\nThere are two convenience functions you can use to create dataset files, either from the web or inline in your initialization code:\n\n```python\nDQ__download_dataset(url, filename)\n```\n\nwill download the file at `url` and save it in the user directory with the given `filename`.\n\nFor example:\n\n```python\nDQ__download_dataset(\n    'https://data.cityofnewyork.us/api/views/kku6-nxdu/rows.csv',\n    'demo_stats.csv')\n```\n\ndownloads the New York demographic statistics dataset and makes it available to the student as `demo_stats.csv`.\n\n```python\nDQ__load_dataset(data, filename)\n```\n\nallows you to create your own dataset file from a list of lists. For example:\n\n```python\nDQ__load_dataset([\n    ['date', 'min-temp', 'max-temp'],\n    ['1989-04-05', '-5', '8'],\n    ['1989-04-06', '-10', '0'],\n    ['1989-04-07', '-1', '8'],\n    ['1989-04-08', '7', '15'],\n]], 'day_temps.csv')\n```\n\ncreates a small table of temperatures in the csv file `day_temps.csv`.\n\n## Full example\n\nIn this example, you'd have the following setup text show on your blog before below editor:\n\n```\nNow that you understand NumPy arrays a bit, let's see if you can complete a challenge.  In the below code editor:\n\n* Create a 3 x 4 array filled with all zeros, and a 6 x 4 array filled with all 1s.\n* Concatenate both arrays vertically into a 9 x 4 array, with the all zeros array on top.\n* Assign the entire first column of the combined array to `first_column`.\n* Print out `first_column`.\n```\n\nAnd here's the editor html:\n\n```html\n\u003ciframe name=\"dq_editor\" width=\"100%\" height=\"350\" src=\"//dqeditor.dataquest.io/\" style=\"border: none\"\u003e\n  \u003cpre id=\"initialization-code\"\u003e\n      import numpy as np\n  \u003c/pre\u003e\n  \u003cpre id=\"code\"\u003e\n      array_one = np.zeros([3,4])\n  \u003c/pre\u003e\n  \u003cpre id=\"hint\"\u003e\n      Here are the steps you'll need to take:\n\n      * Create one array using `np.zeros`.\n      * Overwrite all the values in the second array with `1`.\n      * Use vstack to concatenate the arrays, with the first array on \"top\".\n      * Use indexing to assign the entire first column to `first_column`.\n      * Print out `first_column`.\n  \u003c/pre\u003e\n  \u003cpre id=\"answer-code\" check-vars=\"first_column\"\u003e\n      array_one = np.zeros([3,4])\n      array_two = np.zeros([6,4])\n      array_two[:,:] = 1\n\n      combined = np.vstack((array_one, array_two))\n      first_column = combined[:,1]\n      print(first_column)\n  \u003c/pre\u003e\n\u003c/iframe\u003e\n\n```\n\n## Wordpress\n\nIf you're using wordpress to host your site, see our plugin [here](https://github.com/dataquestio/caravan_wordpress) that makes things easier.\n\n## Live examples\n\nYou can find caravan editors embedded in a few places, including:\n\n* [NumPy Tutorial](https://www.dataquest.io/blog/numpy-tutorial-python/)\n* [Data Science Cheat Sheet](https://www.dataquest.io/blog/data-science-python-cheat-sheet/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataquestio%2Fcaravan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdataquestio%2Fcaravan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataquestio%2Fcaravan/lists"}