All Projects → steve228uk → QuizKit

steve228uk / QuizKit

Licence: MIT license
⁉️ A framework for developing local or remote quiz apps for iOS or tvOS

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to QuizKit

Swiftyviper
Swift Interaction with VIPER Architecture
Stars: ✭ 110 (+292.86%)
Mutual labels:  tvos, cocoapod
Xestimonitors
An extensible monitoring framework written in Swift
Stars: ✭ 269 (+860.71%)
Mutual labels:  tvos, cocoapod
SDWebImageHEIFCoder
A SDWebImage coder plugin to support HEIF image without Apple's Image/IO framework
Stars: ✭ 31 (+10.71%)
Mutual labels:  tvos
Columbus
A feature-rich country picker for iOS, tvOS and watchOS.
Stars: ✭ 23 (-17.86%)
Mutual labels:  tvos
Mechanica
A cross-platform library of Swift utils to ease your iOS | macOS | watchOS | tvOS and Linux development.
Stars: ✭ 27 (-3.57%)
Mutual labels:  tvos
UitzendingGemist
An *Unofficial* Uitzending Gemist application for Apple TV 4 (**deprecated, use TV Gemist ☝🏻**)
Stars: ✭ 48 (+71.43%)
Mutual labels:  tvos
MLH-Quizzet
This is a smart Quiz Generator that generates a dynamic quiz from any uploaded text/PDF document using NLP. This can be used for self-analysis, question paper generation, and evaluation, thus reducing human effort.
Stars: ✭ 23 (-17.86%)
Mutual labels:  quiz
javascript-questions
❔ Multiple choice JS questions as PWA
Stars: ✭ 12 (-57.14%)
Mutual labels:  quiz
SPConfetti
Show the confetti only when the user is having fun, and if not having fun, don't show it.
Stars: ✭ 187 (+567.86%)
Mutual labels:  tvos
sakubun
A tool that helps you improve your Japanese vocabulary and kanji skills with practice that's customized to your needs.
Stars: ✭ 20 (-28.57%)
Mutual labels:  quiz
Degu
🐭 Degu is debug utility for iOS, tvOS and macOS.
Stars: ✭ 24 (-14.29%)
Mutual labels:  tvos
Apple-Platform-Security-Guides
Every Apple Platform Security Guide
Stars: ✭ 106 (+278.57%)
Mutual labels:  tvos
GravityTagCloudView
A tag cloud view with gravity.
Stars: ✭ 22 (-21.43%)
Mutual labels:  cocoapod
SwiftUIFormValidator
Declarative form validator for SwiftUI.
Stars: ✭ 34 (+21.43%)
Mutual labels:  tvos
ivysilani tvOS
Neoficiální klient iVysílání pro sledování videoobsahu veřejnoprávní České televize na Apple TV
Stars: ✭ 41 (+46.43%)
Mutual labels:  tvos
OpenAPI-ObjectiveC
KKBOX Open API Developer SDK for iOS/macOS/watchOS/tvOS
Stars: ✭ 19 (-32.14%)
Mutual labels:  tvos
quizquickanswer-telegram-game-bot
🎮 Funny quiz game for telegram, play with friends on your group!
Stars: ✭ 15 (-46.43%)
Mutual labels:  quiz
DanMuPlayer
A ffmpeg based player for tvOS TVML support DanMu
Stars: ✭ 40 (+42.86%)
Mutual labels:  tvos
SwiftSimctl
Swift client-server tool to call xcrun simctl from your simulator. Automate push notification testing!
Stars: ✭ 50 (+78.57%)
Mutual labels:  tvos
carina-demo
Carina demo project.
Stars: ✭ 40 (+42.86%)
Mutual labels:  tvos

QuizKit for iOS and tvOS

License: MIT CocoaPods


About

QuizKit was built to enable rapid development of local or remote quiz apps. It allows for quizzes to be constructed from JSON and supports multiple question types. It handles randomisation of questions, sessions, and scoring.

It works great on iOS and tvOS.

UI is not currently included but an example application will be made available soon and I'm open to including drop-in view controllers in the future.

Docs

There are three core classes/structs that are visible to you when using QuizKit:

  • QKQuiz - This is the quiz that has been loaded from JSON. Its sole purpose is to be loaded into a QKSession. You may wish to build an app with multiple quizzes which could be separate JSON files or loaded from a JSON string fetched from a remote server.
  • QKSession - This is the main class that you will interact with. There is a shared instance that is accessible from QKSession.default. A quiz is loaded into the session, questions are retreived from here, and responses submitted.
  • QKQuestion - Individual questions are wrapped in this model. It houses information such as the question, type (using QKQuestionType), image, and responses.

Question types

QuizKit currently supports the following question types, definted on QKQuestionType:

  • singleAnswer - This is an open ended question that would be perfect for a text box.
  • multipleChoice - Used for questions with multiple text responses.
  • imageChoice - Similar to multipleChoice but the choices are instead image based instead of text.

Loading a quiz and starting a session

There are two initialisers for loading a quiz that work in the same way. The first you can pass the path to a JSON file included locally in your app and the second takes a JSON string directly.

The below example is how you would load a quiz on a UIViewController from a JSON file.

import QuizKit

class ExampleViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        loadQuiz()
    }

    func loadQuiz() {
        guard let path = Bundle.main.path(forResource: "quiz", ofType: "json") else {
            return
        }
        
        QKSession.default.limit = 10
        
        if let quiz = QKQuiz(loadFromJSONFile: path) {
            QKSession.default.load(quiz: quiz)
        }
    }
    
    @IBAction func startQuiz(_ sender: Any) {
        do {
            try QKSession.default.start()
        } catch {
            fatalError("Quiz started without quiz set on the session")
        }
        
        if let question = QKSession.default.nextQuestion() {
            // SHOW THE QUESTION VIEW HERE
        }
    }
    
}

The startQuiz method in this example has been wired up to a button in interface builder. When the user taps the button a new session is started.

The QKSession.default.nextQuestion() method accepts an optional question in order to return the next correctly. A QKQuestion or nil is returned dependent on whether its the last question in the session.

There is currently one option QKSession.default.limit to set the number of questions in a session.

Submitting a response

Entering a response to a question is done via the QKSession.default.submit(response: String, for: QKQuestion) method. The first parameter is the response the user has given as a string (for an image choice question submit the URL of the image). The second parameter is the QKQuestion instance the user is responding to.

QKSession.default.submit(response: "User Response Here", for: question)

Retreiving the score

When the user has finished the quiz a score can be obtained from QKSession.

An integer value of the number of questions the user got correct is available as well as a string formatted like 7 / 10.

let integerScore = QKSession.default.score
let stringScore = QKSession.default.formattedScore

Individual results for each question are also accessible should you wish to display to the user which questions they got right or wrong.

let individualResults = QKSession.default.responses

Examples

An example JSON file is available here.

An example app will be available soon.

Installation

Manual

QuizKit currently relies on SwiftyJSON to parse the JSON files and strings. If you wish to install QuizKit in your project manually you'll need to also include SwiftyJSON as well as the Sources directory from this repository.

CocoaPods

CocoaPods is an easier way to install QuizKit and its dependencies. Simply include the following in your project's Podfile.

pod 'QuizKit'

Todo

  • Potentially implement JSON parsing in-project to avoid SwiftyJSON dependency.
  • Add additional initialisers for quizzes such as CSV or Plist.
  • Add example application.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].