Skip to content

Commit 8a720cc

Browse files
authored
Move Student QuizDetails to Core (#2937)
[ignore-commit-lint]
1 parent bbd7048 commit 8a720cc

30 files changed

+214
-175
lines changed

Canvas.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Core/Core/Localizable.xcstrings

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42447,6 +42447,9 @@
4244742447
}
4244842448
}
4244942449
}
42450+
},
42451+
"Are you sure you want to leave this quiz?" : {
42452+
4245042453
},
4245142454
"Are you sure you want to remove this file?" : {
4245242455
"localizations" : {
@@ -129344,6 +129347,9 @@
129344129347
}
129345129348
}
129346129349
},
129350+
"Exit" : {
129351+
"comment" : "Exit button to leave the quiz"
129352+
},
129347129353
"Expand" : {
129348129354
"localizations" : {
129349129355
"ar" : {
@@ -170726,6 +170732,9 @@
170726170732
}
170727170733
}
170728170734
}
170735+
},
170736+
"Instructions" : {
170737+
170729170738
},
170730170739
"Interactions on this page are limited by your institution." : {
170731170740
"localizations" : {
@@ -180081,6 +180090,9 @@
180081180090
}
180082180091
}
180083180092
},
180093+
"Leave" : {
180094+
"comment" : "Leave the quiz"
180095+
},
180084180096
"Leave Student View" : {
180085180097
"localizations" : {
180086180098
"ar" : {
@@ -251197,6 +251209,9 @@
251197251209
}
251198251210
}
251199251211
}
251212+
},
251213+
"Questions:" : {
251214+
251200251215
},
251201251216
"quiz" : {
251202251217
"localizations" : {
@@ -263491,6 +263506,9 @@
263491263506
}
263492263507
}
263493263508
}
263509+
},
263510+
"Resume Quiz" : {
263511+
263494263512
},
263495263513
"Retake" : {
263496263514
"localizations" : {
@@ -263747,6 +263765,9 @@
263747263765
}
263748263766
}
263749263767
}
263768+
},
263769+
"Retake Quiz" : {
263770+
263750263771
},
263751263772
"Retry" : {
263752263773
"localizations" : {
@@ -290104,6 +290125,9 @@
290104290125
}
290105290126
}
290106290127
},
290128+
"Stay" : {
290129+
"comment" : "Stay on the quiz view"
290130+
},
290107290131
"Stone" : {
290108290132
"comment" : "This is a name of a color."
290109290133
},
@@ -298144,6 +298168,9 @@
298144298168
}
298145298169
}
298146298170
},
298171+
"Submitted %@" : {
298172+
"comment" : "Submitted date"
298173+
},
298147298174
"Subscribe" : {
298148298175
"localizations" : {
298149298176
"ar" : {
@@ -304032,6 +304059,9 @@
304032304059
}
304033304060
}
304034304061
}
304062+
},
304063+
"Take Quiz" : {
304064+
304035304065
},
304036304066
"Tap here for details" : {
304037304067
"localizations" : {
@@ -350761,6 +350791,9 @@
350761350791
}
350762350792
}
350763350793
}
350794+
},
350795+
"View Results" : {
350796+
350764350797
},
350765350798
"Viewed" : {
350766350799
"localizations" : {

Student/Student/Quizzes/QuizDetails/QuizDetailsViewController.storyboard renamed to Core/Core/Quizzes/QuizDetails/Student/StudentQuizDetailsViewController.storyboard

Lines changed: 22 additions & 22 deletions
Large diffs are not rendered by default.

Student/Student/Quizzes/QuizDetails/QuizDetailsViewController.swift renamed to Core/Core/Quizzes/QuizDetails/Student/StudentQuizDetailsViewController.swift

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818

1919
import Foundation
2020
import UIKit
21-
import Core
2221

23-
class QuizDetailsViewController: ScreenViewTrackableViewController, ColoredNavViewProtocol, CoreWebViewLinkDelegate {
22+
public class StudentQuizDetailsViewController: ScreenViewTrackableViewController, ColoredNavViewProtocol, CoreWebViewLinkDelegate {
2423
@IBOutlet weak var attemptsLabel: UILabel!
2524
@IBOutlet weak var attemptsValueLabel: UILabel!
2625
@IBOutlet weak var dueHeadingLabel: UILabel!
@@ -41,10 +40,10 @@ class QuizDetailsViewController: ScreenViewTrackableViewController, ColoredNavVi
4140
@IBOutlet weak var timeLimitLabel: UILabel!
4241
@IBOutlet weak var timeLimitValueLabel: UILabel!
4342
@IBOutlet weak var titleLabel: UILabel!
44-
let titleSubtitleView = TitleSubtitleView.create()
43+
public let titleSubtitleView = TitleSubtitleView.create()
4544
var offlineModeInteractor: OfflineModeInteractor?
4645

47-
var color: UIColor?
46+
public var color: UIColor?
4847
var courseID = ""
4948
let env = AppEnvironment.shared
5049
var quizID = ""
@@ -62,28 +61,28 @@ class QuizDetailsViewController: ScreenViewTrackableViewController, ColoredNavVi
6261
self?.update()
6362
}
6463

65-
static func create(
64+
public static func create(
6665
courseID: String,
6766
quizID: String,
68-
offlineModeInteractor: OfflineModeInteractor = OfflineModeAssembly.make()) -> QuizDetailsViewController {
67+
offlineModeInteractor: OfflineModeInteractor = OfflineModeAssembly.make()) -> StudentQuizDetailsViewController {
6968
let controller = loadFromStoryboard()
7069
controller.courseID = courseID
7170
controller.quizID = quizID
7271
controller.offlineModeInteractor = offlineModeInteractor
7372
return controller
7473
}
7574

76-
override func viewDidLoad() {
75+
public override func viewDidLoad() {
7776
super.viewDidLoad()
7877
view.backgroundColor = .backgroundLightest
79-
setupTitleViewInNavbar(title: String(localized: "Quiz Details", bundle: .student))
78+
setupTitleViewInNavbar(title: String(localized: "Quiz Details", bundle: .core))
8079

81-
attemptsLabel.text = String(localized: "Allowed Attempts:", bundle: .student)
82-
dueHeadingLabel.text = String(localized: "Due", bundle: .student)
83-
instructionsHeadingLabel.text = String(localized: "Instructions", bundle: .student)
84-
questionsLabel.text = String(localized: "Questions:", bundle: .student)
85-
settingsHeadingLabel.text = String(localized: "Settings", bundle: .student)
86-
timeLimitLabel.text = String(localized: "Time Limit:", bundle: .student)
80+
attemptsLabel.text = String(localized: "Allowed Attempts:", bundle: .core)
81+
dueHeadingLabel.text = String(localized: "Due", bundle: .core)
82+
instructionsHeadingLabel.text = String(localized: "Instructions", bundle: .core)
83+
questionsLabel.text = String(localized: "Questions:", bundle: .core)
84+
settingsHeadingLabel.text = String(localized: "Settings", bundle: .core)
85+
timeLimitLabel.text = String(localized: "Time Limit:", bundle: .core)
8786

8887
instructionsContainer.addSubview(instructionsWebView)
8988
instructionsWebView.pinWithThemeSwitchButton(inside: instructionsContainer)
@@ -109,7 +108,7 @@ class QuizDetailsViewController: ScreenViewTrackableViewController, ColoredNavVi
109108
quizzes.refresh(force: true)
110109
}
111110

112-
override func viewWillAppear(_ animated: Bool) {
111+
public override func viewWillAppear(_ animated: Bool) {
113112
super.viewWillAppear(animated)
114113
navigationController?.navigationBar.useContextColor(color)
115114
}
@@ -139,29 +138,29 @@ class QuizDetailsViewController: ScreenViewTrackableViewController, ColoredNavVi
139138
statusIconView.tintColor = .textSuccess
140139
statusLabel.textColor = .textSuccess
141140
statusLabel.text = String.localizedStringWithFormat(
142-
String(localized: "Submitted %@", bundle: .student, comment: "Submitted date"),
141+
String(localized: "Submitted %@", bundle: .core, comment: "Submitted date"),
143142
finishedAt.dateTimeString
144143
)
145144
} else if submission?.attempt ?? 0 > 1 {
146145
statusIconView.image = .completeSolid
147146
statusIconView.tintColor = .textSuccess
148147
statusLabel.textColor = .textSuccess
149-
statusLabel.text = String(localized: "Submitted", bundle: .student)
148+
statusLabel.text = String(localized: "Submitted", bundle: .core)
150149
} else {
151150
statusIconView.image = .noSolid
152151
statusIconView.tintColor = .textDark
153152
statusLabel.textColor = .textDark
154-
statusLabel.text = String(localized: "Not Submitted", bundle: .student)
153+
statusLabel.text = String(localized: "Not Submitted", bundle: .core)
155154
}
156155
dueLabel.text = quiz?.dueText
157156
attemptsValueLabel.text = quiz?.allowedAttemptsText
158157
questionsValueLabel.text = quiz?.questionCountText
159158
timeLimitValueLabel.text = quiz?.timeLimitText
160159
instructionsHeadingLabel.text = quiz?.lockedForUser == true
161-
? String(localized: "Locked", bundle: .student)
162-
: String(localized: "Instructions", bundle: .student)
160+
? String(localized: "Locked", bundle: .core)
161+
: String(localized: "Instructions", bundle: .core)
163162
var html = quiz?.lockExplanation ?? quiz?.details ?? ""
164-
if html.isEmpty { html = String(localized: "No Content", bundle: .student) }
163+
if html.isEmpty { html = String(localized: "No Content", bundle: .core) }
165164

166165
let offlinePath = URL.Paths.Offline.courseSectionResourceFolderURL(
167166
sessionId: env.currentSession?.uniqueID ?? "",
@@ -192,24 +191,24 @@ class QuizDetailsViewController: ScreenViewTrackableViewController, ColoredNavVi
192191
guard let quiz = quizzes.first, !quizzes.pending else { return nil }
193192
if quiz.canTake {
194193
guard let submission = quiz.submission else {
195-
return String(localized: "Take Quiz", bundle: .student)
194+
return String(localized: "Take Quiz", bundle: .core)
196195
}
197196
if submission.canResume {
198-
return String(localized: "Resume Quiz", bundle: .student)
197+
return String(localized: "Resume Quiz", bundle: .core)
199198
}
200199
return submission.finishedAt != nil || submission.attempt > 1
201-
? String(localized: "Retake Quiz", bundle: .student)
202-
: String(localized: "Take Quiz", bundle: .student)
200+
? String(localized: "Retake Quiz", bundle: .core)
201+
: String(localized: "Take Quiz", bundle: .core)
203202
} else if quiz.resultsURL != nil {
204-
return String(localized: "View Results", bundle: .student)
203+
return String(localized: "View Results", bundle: .core)
205204
}
206205
return nil
207206
}
208207

209208
@IBAction func take() {
210209
guard let quiz = quizzes.first else { return }
211210
if quiz.canTake {
212-
env.router.show(QuizWebViewController.create(
211+
env.router.show(StudentQuizWebViewController.create(
213212
courseID: courseID,
214213
quizID: quizID
215214
), from: self, options: .modal(.fullScreen, isDismissable: false, embedInNav: true))

Student/Student/Quizzes/QuizDetails/QuizWebViewController.swift renamed to Core/Core/Quizzes/QuizDetails/Student/StudentQuizWebViewController.swift

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,34 @@
1818

1919
import UIKit
2020
import WebKit
21-
import Core
2221

23-
class QuizWebViewController: UIViewController {
22+
public class StudentQuizWebViewController: UIViewController {
2423
var courseID = ""
2524
var quizID = ""
2625

2726
let env = AppEnvironment.shared
2827
let webView = CoreWebView(features: [.invertColorsInDarkMode, .skipJSInjection(CoreWebView.mathJaxJS)])
2928

30-
static func create(courseID: String, quizID: String) -> QuizWebViewController {
31-
let controller = QuizWebViewController()
29+
public static func create(courseID: String, quizID: String) -> StudentQuizWebViewController {
30+
let controller = StudentQuizWebViewController()
3231
controller.courseID = courseID
3332
controller.quizID = quizID
3433
return controller
3534
}
3635

37-
override func loadView() {
36+
public override func loadView() {
3837
view = webView
3938
}
4039

41-
override func viewDidLoad() {
40+
public override func viewDidLoad() {
4241
super.viewDidLoad()
4342

4443
webView.linkDelegate = self
4544
webView.uiDelegate = self
4645

47-
title = String(localized: "Take Quiz", bundle: .student)
46+
title = String(localized: "Take Quiz", bundle: .core)
4847
navigationItem.rightBarButtonItem = UIBarButtonItem(
49-
title: String(localized: "Exit", bundle: .student, comment: "Exit button to leave the quiz"),
48+
title: String(localized: "Exit", bundle: .core, comment: "Exit button to leave the quiz"),
5049
style: .plain, target: self, action: #selector(exitQuiz)
5150
)
5251

@@ -64,9 +63,9 @@ class QuizWebViewController: UIViewController {
6463

6564
@objc func exitQuiz() {
6665
if webView.url?.path.contains("/take") == true {
67-
let areYouSure = String(localized: "Are you sure you want to leave this quiz?", bundle: .student)
68-
let stay = String(localized: "Stay", bundle: .student, comment: "Stay on the quiz view")
69-
let leave = String(localized: "Leave", bundle: .student, comment: "Leave the quiz")
66+
let areYouSure = String(localized: "Are you sure you want to leave this quiz?", bundle: .core)
67+
let stay = String(localized: "Stay", bundle: .core, comment: "Stay on the quiz view")
68+
let leave = String(localized: "Leave", bundle: .core, comment: "Leave the quiz")
7069

7170
let alert = UIAlertController(title: nil, message: areYouSure, preferredStyle: .alert)
7271
alert.addAction(AlertAction(stay, style: .cancel))
@@ -88,20 +87,20 @@ class QuizWebViewController: UIViewController {
8887
}
8988
}
9089

91-
extension QuizWebViewController: WKUIDelegate {
92-
func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) {
90+
extension StudentQuizWebViewController: WKUIDelegate {
91+
public func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) {
9392
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
94-
alert.addAction(AlertAction(String(localized: "Cancel", bundle: .student), style: .cancel) { _ in
93+
alert.addAction(AlertAction(String(localized: "Cancel", bundle: .core), style: .cancel) { _ in
9594
completionHandler(false)
9695
})
97-
alert.addAction(AlertAction(String(localized: "OK", bundle: .student), style: .default) { _ in
96+
alert.addAction(AlertAction(String(localized: "OK", bundle: .core), style: .default) { _ in
9897
completionHandler(true)
9998
})
10099
env.router.show(alert, from: self, options: .modal())
101100
}
102101
}
103102

104-
extension QuizWebViewController: CoreWebViewLinkDelegate {
103+
extension StudentQuizWebViewController: CoreWebViewLinkDelegate {
105104
public func handleLink(_ url: URL) -> Bool {
106105
if let take = env.currentSession?.baseURL
107106
.appendingPathComponent("courses/\(courseID)/quizzes/\(quizID)/take"),

0 commit comments

Comments
 (0)