{"id":18008571,"url":"https://github.com/mgree/sgbcourses","last_synced_at":"2025-04-04T12:11:08.482Z","repository":{"id":177493904,"uuid":"629117606","full_name":"mgree/SGBCourses","owner":"mgree","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-31T12:38:17.000Z","size":19361,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T21:43:51.028Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mgree.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-04-17T16:51:01.000Z","updated_at":"2023-07-31T12:38:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"2738d2d1-acea-4a03-9d10-f4cb88ea293f","html_url":"https://github.com/mgree/SGBCourses","commit_stats":null,"previous_names":["josh-hiz/sgbcourses"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgree%2FSGBCourses","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgree%2FSGBCourses/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgree%2FSGBCourses/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgree%2FSGBCourses/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mgree","download_url":"https://codeload.github.com/mgree/SGBCourses/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174456,"owners_count":20896078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-10-30T01:19:09.717Z","updated_at":"2025-04-04T12:11:08.465Z","avatar_url":"https://github.com/mgree.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sphinx-Greenberg-Courses\n\n## Slide format:\nAll documents/textbook slides are written in RST and NOT markdown, therefore if you want to add new documents in slides please update the `toctree` in the appropriate index\n\n## Spinning up a local server:\nRun the server script `run_livereload.py` to spin up the server\n\n## Please run the following lines in your termnial before spinning up the server:\nInstall node packages (its just one package):\n```\nnpm install\n```\nInstall python packages:\n```\npip install -r requirements.txt\n```\nThen run initial setup and debugging:\n```\nsphinx-build -M html ./ _build/ -W -a -j auto -n --keep-going\n```\nThen run the following to make production build\n```\nmake clean\nmake html\n```\n\n## Custom Directives and how to use them\n\nSphinx and RestructredText in general rely on directives to do a lot of the heavy lifting. Here are some of the most common directives that you can use and how to use them:\n\n### Challenges\nThe challenge directive when called will render a Python text editor for you to type in code and even run it using Pyodide. The text editor is from Ace. An additional feature is that it can run test scripts, here are a few examples:\n\nStandard usage with test script and having some initial code to put in the editor:\n```\n.. challenge::\n    :tester: /test/file/path/here.py\n\n    # Here is some initial code to put in your text editor\n\n    for i in range(10):\n        print(i)\n    \n    s = input(\"Random input!\")\n    print(s)\n```\n\nWhen you dont want a test script but still want to run code:\n```\n.. challenge::\n\n    # Here is some initial code to put in your text editor\n\n    for i in range(10):\n        print(i)\n    \n    s = input(\"Random input!\")\n    print(s)\n```\n\n### Code Runners\nCode runners, sometimes incorrectly referred to as REPL's is more or less identical to the challenge directive except its purely meant for code editing and running initial code you place in the editor. Here are is an example:\n\n```\n.. runner::\n\n    # Here is some initial code to put in your text editor\n\n    def foo(msg):\n        print(msg + 'bar')\n```\n\n### Free Response Questions\nThis is a very recent directive I made out of frustration on relying on Quizdown and a very amerture and disfunctional directive I once had to handle free response questions so I created a new directive that would allow for a more flexible and robust way of handling free response questions. It support the following:\n\n- Markdown syntax\n- Explanations\n- Allow you to use regular expressions as answers (this is a big one)\n- Default explanations (It will tell the user the answer)\n- Explanations only appear if a user gets a question wrong on first try\n\nHere are a few examples:\n\nHere is a standard quiz that does not use regex for answers and has explanation:\n\n```\n.. free-r::\n    :answer: 1\n\n    # Question\n\n    What does the following Python expression evaluate to? (For maximum learning, try to work it out yourself!)\n\n    ```41 // 2 ** 3 - 4 * 2 + ( 9 % 5 )```\n\n    \u003e\u003e\u003e\n    41 // 2 ** 3 - 4 * 2 + ( 9 % 5 ) evaluates to\u003cbr\u003e\n    41 // 2 ** 3 - 4 * 2 + 4 evaluates to\u003cbr\u003e\n    41 // 8 - 4 * 2 + 4 evaluates to\u003cbr\u003e\n    5 - 4 * 2 + 4 evaluates to\u003cbr\u003e\n    5 - 8 + 4 evaluates to\u003cbr\u003e\n    -3 + 4 evaluates to\u003cbr\u003e\n    1\n```\n\n**Everything below the \u003e\u003e\u003e will be concidered part of the custom explanation**\n\nExample that uses regex and explanation, **you need to specify \"regex: true\" so the directive knows to use regex**:\n\n\n```\n.. free-r::\n    :answer: '\"It\\\\'s a backslash,\" he said, \"you write it like \\\\'\\\\\\\\\\\\'\\.\"'|\"\\\\\"It\\\\?'s a backslash,\\\\\" he said, \\\\\"you write it like \\\\?'\\\\\\\\\\\\?'\\.\\\\\"\"\n    :regex: true\n\n    # Question 3\n\n    How would you write the following as a string in Python?\n\n    ```\"It's a backslash,\" he said, \"you write it like '\\'.\"```\n\n    Just write the string literal, as in ```\"this\\tis not  the answer\"```.\n\n    \u003e\u003e\u003e\n    ```'\"It\\'s a backslash,\" he said, \"you write it like \\'\\\\\\'.\"'```\u003cbr\u003e\n    or\u003cbr\u003e\n    ```\"\\\"It's a backslash,\\\" he said, \\\"you write it like '\\\\'.\\\"\"```\n```\nWhat if you want your answer to be multiple lines? You can do that too!\n\n```\n.. free-r:: \n    :answer:\n        func_a\n        func_d\n        func_c\n        func_b\n        func_e\n        func_b\n    \n    # Question 1\n\n    What order will the functions be called in? Write each function name once per line. If a function is called more than once, list it once for each time its called.\n    \n    \u003e\u003e\u003e\n    The functions will be called in this order:\u003cbr\u003e\n    ```func_a\u003cbr\u003e\n    func_d\u003cbr\u003e\n    func_c\u003cbr\u003e\n    func_b\u003cbr\u003e\n    func_e\u003cbr\u003e\n    func_b```\n```\n\n### Quizdown\nQuizdown is a custom directive that I did not make and simply use it for single choice and free response, its pretty good, here are some examples of usage:\n\nTake note that 1. [ ] indicates single choice and - [ ] indicates multiple choice, where things marked with 'x' are the correct answers\n\nHere is one where you want to put images AND have the question answers be multi line and have code blocks\n```\n.. quizdown::\n        \n    ### The following 3x4 image is given as a 2D list ```rgb_rows```.\n\n    ![](https://i.ibb.co/dMJ6J8R/rgbrows.png)\n\n    \u003cbr\u003e\n\n    What code will print the RGB information in the following image:\n\n    ![](https://i.ibb.co/djbYVY1/bluerow.png)\n\n    1. [ ] ```\n        for column in range(4):\n            print(rgb_rows[1][column])\n        ```\n    2. [ ] ```\n        for column in range(4):\n            print(rgb_rows[3][column])\n        ```\n    3. [x] ```\n        for column in range(4):\n            print(rgb_rows[2][column])\n        ```\n    4. [ ] ```\n        for column in range(4):\n            print(rgb_rows[0][column])\n        ```\n```\n\nHere is a more standard quiz without explanations\n```\n.. quizdown::\n\n    ### What is this color?\n\n    R = 100, G = 100, B = 100\n\n    Hint: Test it out with the color picker tool if you are unsure.\n\n    1. [ ] white\n    2. [ ] brown\n    3. [ ] black\n    4. [ ] gray \n\n\n    ### What is this color?\n\n    R = 255, G = 255, B = 0\n\n    Hint: Test it out with the color picker tool if you are unsure.\n\n    1. [x] yellow\n    2. [ ] red\n    3. [ ] purple\n    4. [ ] green \n```\n\nMore directives can be added over time, otherwise, that is all!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgree%2Fsgbcourses","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgree%2Fsgbcourses","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgree%2Fsgbcourses/lists"}