{"id":25982619,"url":"https://github.com/codesignal/learn_quiz-task","last_synced_at":"2025-12-05T06:06:11.966Z","repository":{"id":279300435,"uuid":"938326301","full_name":"CodeSignal/learn_quiz-task","owner":"CodeSignal","description":"A simple quiz engine to show quizes in our questions","archived":false,"fork":false,"pushed_at":"2025-02-24T20:56:58.000Z","size":380,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-24T21:35:25.299Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodeSignal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2025-02-24T19:23:36.000Z","updated_at":"2025-02-24T20:56:58.000Z","dependencies_parsed_at":"2025-02-24T21:35:28.292Z","dependency_job_id":"125cdf9a-495c-4cc0-90bb-db3c810f54b8","html_url":"https://github.com/CodeSignal/learn_quiz-task","commit_stats":null,"previous_names":["codesignal/learn_quiz-task"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSignal%2Flearn_quiz-task","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSignal%2Flearn_quiz-task/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSignal%2Flearn_quiz-task/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSignal%2Flearn_quiz-task/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeSignal","download_url":"https://codeload.github.com/CodeSignal/learn_quiz-task/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242002619,"owners_count":20056101,"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":"2025-03-05T09:36:55.861Z","updated_at":"2025-12-05T06:06:11.947Z","avatar_url":"https://github.com/CodeSignal.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A simple quiz experience to use inside of Learn\n\n## How to use\n\n1. Clone the repository\n2. Add questions to the `questions.json` file\n3. Run `node server.js` to start the server\n4. Open `localhost:3000` in your browser\n\nNote: the legacy way of doing it was `python server.py` but python does not support websockets out of the box where Node.js does.  So `server.py` is deprecated in favor of `server.js`.\n\n## How to add questions\n\nQuestions are stored in the `questions.json` file. The questions are stored in an array of objects. Each object represents a question and has the following properties:\n\n- `name`: The name of the question\n- `title`: The title of the question\n- `type`: The type of question \n\nSee the [SurveyJS documentation](https://surveyjs.io/form-library/examples/text-entry-question/reactjs) for the different question types and their properties. There are a lot of them, so I won't go into detail here.\n\n## How to run the solution\nAs the user interacts with the quiz, the answers are stored in the `answers.json` file. The answers are stored in an array of objects. Each object represents a question and has the following properties:\n\n- `name`: The name of the question\n- `value`: The value of the question\n- `correctAnswer`: The correct answer to the question\n- `isCorrect`: Whether the answer is correct\n\nTo run the solution, run `python format_answers.py`. This will read the `questions.json` and `answers.json` files and format the answers into a human readable format.\n\n## How to display the correct/incorrect state to the user\nFirst, you must use the `node` version of the server (`server.js`). It exposes a websocket and a `/validate` endpoint you can POST to. It will request the HTML to annotate the UX.\n\nIf you want the Web UX to display the correct/incorrect state to the user, you can make a request to the quiz server:\n```\ncurl -X POST localhost:3000/validate \u0026\u003e /dev/null\n```\n\n## How to use as a standalone solution\n\nThe 2 main dependencies required for this project are python and node. Both can be gotten in the python base images, since every base image contains node as well. A few files need to be created to make the solution work standalone.\n\nAn example can be found [here](https://app-staging.codesignal.dev/question/NzuLaf2PfcWuxhmAD/)\n### setup.sh\n\n```bash\nif [ -f questions.json ]; then\n    wget https://github.com/CodeSignal/learn_quiz-task/releases/latest/download/dist.tar.gz\n    \n    mkdir -p learn_quiz\n    cd learn_quiz\n    tar xzf ../dist.tar.gz \n    \n    cp ../questions.json questions.json\n    \n    npm start\n    exit 0\nfi\n```\n\n### run_solution.sh\n\n```bash\n#!/bin/bash\n\n# force all clients (just the one for the preview window) to update \n# their display and show the correctness of the answers\ncurl -X POST localhost:3000/validate \u0026\u003e /dev/null\n\n# process the answers given to assess if the learner correctly \n# completed the quiz\npython3 format_answers.py\n\nexit 0\n```\n\n### Questions.json Format\nThis is the format used by Survey.js and an example is in `questions.json`. But we sometimes want to use Markdown to define the questions (example: `questions.md`). You can convert the Markdown to JSON if you prefer.  In that case, you can convert it to JSON:\n\n```bash\nnode convert-questions-md-to-json.js -i questions.md -o questions.json\n```\n\n### View settings\n\nThe expected setup in the view settings (present either on the course level or on the task level):\n- Task Preview: \"Full Screen\"\n- Task Preview URL Header: \"Hidden\"\n- Refresh Preview on Run: \"Disabled\"\n- Preview Loading Message: \"Custom\"\n- Custom Preview Loading Message: \"Starting Quiz...\"\n- Reset Session Button Location: \"Preview\"\n- Preview Position: \"top:10px; right:10px\"\n\n## FAQ\n\n### my questions aren't showing up in the survey\nAre you sure you didn't store your particular questions in a path different than the one used in the `setup.sh` file?\n\n### I'm getting errors after copying the exact scripts provided here\nEnsure you are using the latest release of this repository. While the script assume version 0.7, it could very well be that a bug was fixed somewhere down the line and a newer release fixes the issues.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodesignal%2Flearn_quiz-task","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodesignal%2Flearn_quiz-task","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodesignal%2Flearn_quiz-task/lists"}