Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a Multiple Choice Questionnaire #2

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b41b986
Initial commit version1 in a new branch called Version1
ronaldngounou Apr 2, 2024
ab0f8cc
add comment in model
ronaldngounou Apr 3, 2024
2b955ec
Merge pull request #1 from ronaldngounou/Version1
ronaldngounou Apr 5, 2024
2e4ba58
change entry point to start from viewController instead of mainStoryB…
ronaldngounou Apr 5, 2024
525f6ff
Add entry to ViewController in Storyboard on App launch
ronaldngounou Apr 10, 2024
d118922
Add entry to ViewController instead of MainStoryBoard
ronaldngounou Apr 10, 2024
8ada50a
Delete force unwrap. The old version was not launching. In this new v…
ronaldngounou Apr 14, 2024
c896416
Modify usage of force unwrap
ronaldngounou Apr 14, 2024
ce37dfe
Remove mutating and public classes
ronaldngounou Apr 14, 2024
3c03ca6
Remove public class for ViewController
ronaldngounou Apr 15, 2024
94b81cf
Error with the screen launch stopped occuring but blocked with unwrap…
ronaldngounou Apr 15, 2024
b2f81f0
Error with the screen launch stopped occuring but blocked with unwrap…
ronaldngounou Apr 15, 2024
8e88973
Force unwrapping error
ronaldngounou Apr 17, 2024
58758cf
Merge remote-tracking branch 'refs/remotes/origin/Version1'
ronaldngounou Apr 17, 2024
fb0adb9
working version with a start from ViewController
ronaldngounou Apr 17, 2024
1a4f3dd
new commit
ronaldngounou Apr 17, 2024
391c07f
new commit
ronaldngounou Apr 17, 2024
dff41c1
initialize new branch
ronaldngounou Apr 18, 2024
e8ac24c
Merge branch 'master' into ChoicesFeature
ronaldngounou Apr 18, 2024
bdb549a
implement the models necessary for the mutliple choice questions
ronaldngounou Apr 18, 2024
fd036e5
Attempt to connect the new QuizViewController and its outlets
ronaldngounou Apr 18, 2024
2939505
start QuizViewController
ronaldngounou Apr 18, 2024
eef5f5f
improved the Model file given the reviews
ronaldngounou Apr 18, 2024
3b87dbf
Delete Quizzler-iOS13/Controller/ViewController2.swift
ronaldngounou Apr 18, 2024
7546ab9
add the 3 choices on the Main for the layout
ronaldngounou Apr 18, 2024
6bd21cd
Merge branch 'ChoicesFeature' of https://github.com/ronaldngounou/Qui…
ronaldngounou Apr 18, 2024
feec95e
updateUI with the 3 choices
ronaldngounou Apr 18, 2024
75b995f
implemented 3 choices with correct answers selections
ronaldngounou Apr 18, 2024
d75364c
Show Alert message with an explanation when the user didn't find the …
ronaldngounou Apr 18, 2024
b4dd243
Add a bank of 50 questions
ronaldngounou Apr 19, 2024
d30b78c
add my name
ronaldngounou Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Quizzler-iOS13.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
objects = {

/* Begin PBXBuildFile section */
52EE212A2BD16C5800B34D8A /* ChoicesQuestions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52EE21292BD16C5800B34D8A /* ChoicesQuestions.swift */; };
52EE212C2BD16D1900B34D8A /* QuizManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52EE212B2BD16D1900B34D8A /* QuizManager.swift */; };
52EE21302BD1763C00B34D8A /* QuizViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52EE212F2BD1763C00B34D8A /* QuizViewController.swift */; };
52F58ED62BCDD99200372298 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52F58ED52BCDD99200372298 /* SceneDelegate.swift */; };
AD4BDE4A22D878BA005BA4CC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD4BDE4922D878BA005BA4CC /* AppDelegate.swift */; };
AD4BDE4C22D878BA005BA4CC /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD4BDE4B22D878BA005BA4CC /* SceneDelegate.swift */; };
AD4BDE4E22D878BA005BA4CC /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD4BDE4D22D878BA005BA4CC /* ViewController.swift */; };
AD4BDE5122D878BA005BA4CC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AD4BDE4F22D878BA005BA4CC /* Main.storyboard */; };
AD4BDE5322D878BC005BA4CC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AD4BDE5222D878BC005BA4CC /* Assets.xcassets */; };
Expand All @@ -19,9 +22,12 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
52EE21292BD16C5800B34D8A /* ChoicesQuestions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChoicesQuestions.swift; sourceTree = "<group>"; };
52EE212B2BD16D1900B34D8A /* QuizManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizManager.swift; sourceTree = "<group>"; };
52EE212F2BD1763C00B34D8A /* QuizViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizViewController.swift; sourceTree = "<group>"; };
52F58ED52BCDD99200372298 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
AD4BDE4622D878BA005BA4CC /* Quizzler-iOS13.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Quizzler-iOS13.app"; sourceTree = BUILT_PRODUCTS_DIR; };
AD4BDE4922D878BA005BA4CC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
AD4BDE4B22D878BA005BA4CC /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
AD4BDE4D22D878BA005BA4CC /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
AD4BDE5022D878BA005BA4CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
AD4BDE5222D878BC005BA4CC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -64,7 +70,7 @@
isa = PBXGroup;
children = (
AD4BDE4922D878BA005BA4CC /* AppDelegate.swift */,
AD4BDE4B22D878BA005BA4CC /* SceneDelegate.swift */,
52F58ED52BCDD99200372298 /* SceneDelegate.swift */,
AD7631C222FC1F7500C6E71B /* Model */,
AD7631C322FC201E00C6E71B /* View */,
AD7631C422FC206D00C6E71B /* Controller */,
Expand All @@ -80,6 +86,8 @@
children = (
AD7631C022FB176100C6E71B /* Question.swift */,
AD7631C522FC227F00C6E71B /* QuizBrain.swift */,
52EE21292BD16C5800B34D8A /* ChoicesQuestions.swift */,
52EE212B2BD16D1900B34D8A /* QuizManager.swift */,
);
path = Model;
sourceTree = "<group>";
Expand All @@ -96,6 +104,7 @@
isa = PBXGroup;
children = (
AD4BDE4D22D878BA005BA4CC /* ViewController.swift */,
52EE212F2BD1763C00B34D8A /* QuizViewController.swift */,
);
path = Controller;
sourceTree = "<group>";
Expand Down Expand Up @@ -172,11 +181,14 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
52F58ED62BCDD99200372298 /* SceneDelegate.swift in Sources */,
AD7631C622FC227F00C6E71B /* QuizBrain.swift in Sources */,
AD4BDE4E22D878BA005BA4CC /* ViewController.swift in Sources */,
52EE21302BD1763C00B34D8A /* QuizViewController.swift in Sources */,
52EE212C2BD16D1900B34D8A /* QuizManager.swift in Sources */,
AD7631C122FB176100C6E71B /* Question.swift in Sources */,
52EE212A2BD16C5800B34D8A /* ChoicesQuestions.swift in Sources */,
AD4BDE4A22D878BA005BA4CC /* AppDelegate.swift in Sources */,
AD4BDE4C22D878BA005BA4CC /* SceneDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Quizzler-iOS13.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "D8893114-6875-4034-9B93-CE11CD6DC615"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "E1B34218-F56E-4A36-91F8-1C1916BFE0B3"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Quizzler-iOS13/AppDelegate.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "2"
endingLineNumber = "2"
landmarkName = "unknown"
landmarkType = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Quizzler-iOS13.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Binary file added Quizzler-iOS13/.DS_Store
Binary file not shown.
29 changes: 7 additions & 22 deletions Quizzler-iOS13/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,24 @@
// AppDelegate.swift
// Quizzler-iOS13
//
// Created by Angela Yu on 12/07/2019.
// Created by Ronald Ngounou on 4/18/24.
// Copyright © 2019 The App Brewery. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?



//Version 1
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

return true

}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}
Expand Down
20 changes: 14 additions & 6 deletions Quizzler-iOS13/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<viewController storyboardIdentifier="ViewController" id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
21 changes: 21 additions & 0 deletions Quizzler-iOS13/Controller/QuizViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// QuizViewController.swift
// Quizzler-iOS13
//
// Created by Ronald Ngounou on 4/18/24.
// Copyright © 2024 The App Brewery. All rights reserved.
//

import UIKit

class QuizViewController : UIViewController{

public override func viewDidLoad() {
super.viewDidLoad()

// updateUI()
}



}
48 changes: 37 additions & 11 deletions Quizzler-iOS13/Controller/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,69 @@ class ViewController: UIViewController {

@IBOutlet weak var questionLabel: UILabel!
@IBOutlet weak var progressBar: UIProgressView!
@IBOutlet weak var trueButton: UIButton!
@IBOutlet weak var falseButton: UIButton!
@IBOutlet weak var scoreLabel: UILabel!
@IBOutlet weak var choice1: UIButton!
@IBOutlet weak var choice2: UIButton!
@IBOutlet weak var choice3: UIButton!
//@IBOutlet var choiceButtons: [UIButton]! //could have been better with a list

var quizBrain = QuizManager()

var quizBrain = QuizBrain()

override func viewDidLoad() {
public override func viewDidLoad() {
super.viewDidLoad()

updateUI()
}

@IBAction func answerButtonPressed(_ sender: UIButton) {

let userAnswer = sender.currentTitle!
guard let selectedChoice = sender.currentTitle else {
questionLabel?.text = "An unexpected error occured."
assertionFailure("Unexpected case happened.")
return
}

let userGotItRight = quizBrain.checkAnswer(userAnswer: userAnswer)
let userGotItRight = quizBrain.checkAnswer(selectedChoice)

if userGotItRight {
if userGotItRight{
sender.backgroundColor = UIColor.green
} else {
sender.backgroundColor = UIColor.red
showAlert(message: quizBrain.getExplanation())
}

quizBrain.nextQuestion()
quizBrain.moveToNextQuestion()

Timer.scheduledTimer(timeInterval: 0.2, target: self, selector: #selector(updateUI), userInfo: nil, repeats: false)
}

@objc func updateUI() {

questionLabel.text = quizBrain.getQuestionText()

let currentQuestion = quizBrain.getCurrentQuestion()

choice1.setTitle(currentQuestion?.choices[0], for: .normal)
choice2.setTitle(currentQuestion?.choices[1], for: .normal)
choice3.setTitle(currentQuestion?.choices[2], for: .normal)


progressBar.progress = quizBrain.getProgress()
scoreLabel.text = "Score: \(quizBrain.getScore())"

trueButton.backgroundColor = UIColor.clear
falseButton.backgroundColor = UIColor.clear
choice1.backgroundColor = UIColor.clear
choice2.backgroundColor = UIColor.clear
choice3.backgroundColor = UIColor.clear


}

func showAlert(message: String) {
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Continue", style: .default, handler: nil))
present(alert, animated: true, completion: nil)
}

}

Expand Down
8 changes: 4 additions & 4 deletions Quizzler-iOS13/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsTabbedSceneCollection</key>
<false/>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
Expand All @@ -43,8 +45,6 @@
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
Expand Down
29 changes: 29 additions & 0 deletions Quizzler-iOS13/Model/ChoicesQuestions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// ChoicesQuestions.swift
// Quizzler-iOS13
//
// Created by Ronald Ngounou on 4/18/24.
// Copyright © 2024 The App Brewery. All rights reserved.
//

import Foundation

struct ChoicesQuestions{
let questionText: String
let choices: [String]
let correctAnswerIndex: Int
let explanation: String


init(
questionText: String,
choices: [String],
correctAnswerIndex: Int,
explanation: String
){
self.questionText = questionText
self.choices = choices
self.correctAnswerIndex = correctAnswerIndex
self.explanation = explanation
}
}
Loading