{"id":16861621,"url":"https://github.com/irbekrm/quiz-game","last_synced_at":"2025-03-18T20:41:11.534Z","repository":{"id":57637490,"uuid":"140939919","full_name":"irbekrm/Quiz-Game","owner":"irbekrm","description":"Quiz Game in Go","archived":false,"fork":false,"pushed_at":"2020-02-20T14:54:12.000Z","size":17,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-24T23:13:38.965Z","etag":null,"topics":["channel","golang","gophercises","goroutine","quiz","time"],"latest_commit_sha":null,"homepage":"","language":"Go","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/irbekrm.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}},"created_at":"2018-07-14T11:16:35.000Z","updated_at":"2022-09-09T08:23:52.000Z","dependencies_parsed_at":"2022-08-30T10:30:47.134Z","dependency_job_id":null,"html_url":"https://github.com/irbekrm/Quiz-Game","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irbekrm%2FQuiz-Game","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irbekrm%2FQuiz-Game/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irbekrm%2FQuiz-Game/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irbekrm%2FQuiz-Game/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/irbekrm","download_url":"https://codeload.github.com/irbekrm/Quiz-Game/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244305349,"owners_count":20431730,"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":["channel","golang","gophercises","goroutine","quiz","time"],"created_at":"2024-10-13T14:32:41.757Z","updated_at":"2025-03-18T20:41:11.507Z","avatar_url":"https://github.com/irbekrm.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Quiz-Game\n===\nThe first exercise from https://gophercises.com/exercises/\n\n### Description\n\nA timed quiz. Asks user a number of questions and prints the score at the end.\n\nThe default version has a timeout of 30s and the quizzes are read from the *problems.csv* file included.\n\nUser can set a different timeout, provide another quiz file and shuffle quiz questions.\n\n### Use\n\n(If you don't have *go* installed and go workspace set up, follow the instructions here: https://golang.org/doc/install)\n\n*go get github.com/irbekrm/Quiz-Game* download and install this package\n\n*cd ~/go/src/github.com/irbekrm/Quiz-Game* go to the package directory\n\n*go run ./main.go -h* print help\n\n*go run ./main.go* run the default version\n\n*go run ./main.go -s* shuffle the questions\n\n*go run ./main.go -f \\\u003cfilename\\\u003e* provide own csv file with quizzes. File should be in format *question,answer*\n\n*go run ./main.go -t \\\u003cx\\\u003e* set timeout to x seconds\n\n### Implementation\n\nThe main challenge for me was to track the time. If the time runs out whilst the program is waiting for the user input\nfor a quiz question, the program should stop waiting for the user input, print the score and exit.\n\nTo solve this, I created two go subroutines, one runs the timer, the other waits for user input. Each has an associated channel-\nthe timeout subroutine sends *true* when the time runs out and the user input subroutine sends the user's answer,\nwhen it recieves one. When the user is ready,\nthe main process spins off both subroutines. It then runs a *for* loop for as long as a counter variable that I use to\nloop through the questions in the quiz list is less than the length of the list and a *timeout* variable is *false*. Inside the loop\nthere is a *select* statement that checks for data being sent from either channel. If a user's answer is sent,\nthat will be recorded and the counter variable incremented. If the timer subroutine sends *true*, the *timeout* variable will be set to *true*,\nwhich will cause the *for* loop to exit.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firbekrm%2Fquiz-game","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firbekrm%2Fquiz-game","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firbekrm%2Fquiz-game/lists"}