Skip to content

Commit ad84dd2

Browse files
authored
Fix table quiz presented like theory (#607)
* Make BlockType optional * Update can edit step text determination * Remove fill blanks from supported quizzes list * Hide step statistics for unsopported quizzes * Extend BlockType * Test all block types * Fix analytics * Review linter violations
1 parent 2083a74 commit ad84dd2

File tree

13 files changed

+46
-42
lines changed

13 files changed

+46
-42
lines changed

Stepic/Analytics/Events/AnalyticsEvents.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,6 @@ struct AnalyticsEvents {
135135
struct Edit {
136136
static let opened = "step_edit_opened"
137137
static let completed = "step_edit_completed"
138-
139-
static func makeParams(stepID: Int, type: String, position: Int) -> [String: Any] {
140-
return [
141-
"step": stepID,
142-
"type": type,
143-
"number": position
144-
]
145-
}
146138
}
147139
}
148140

Stepic/Block+CoreDataProperties.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ extension Block {
6868
}
6969
}
7070

71-
var type: BlockType {
72-
BlockType(rawValue: self.name) ?? .text
71+
var type: BlockType? {
72+
BlockType(rawValue: self.name)
7373
}
7474

7575
// MARK: - Types -
@@ -80,9 +80,6 @@ extension Block {
8080
case choice
8181
case code
8282
case dataset
83-
case fillBlanks = "fill-blanks"
84-
case freeAnswer = "free-answer"
85-
case linuxCode = "linux-code"
8683
case matching
8784
case math
8885
case number
@@ -94,13 +91,17 @@ extension Block {
9491
case text
9592
case video
9693
case admin
94+
case table
95+
case html
96+
case schulte
97+
case fillBlanks = "fill-blanks"
98+
case freeAnswer = "free-answer"
99+
case linuxCode = "linux-code"
100+
case randomTasks = "random-tasks"
101+
case manualScore = "manual-score"
97102

98103
var isTheory: Bool {
99104
return [BlockType.text, BlockType.video].contains(self)
100105
}
101-
102-
var isQuiz: Bool {
103-
return !self.isTheory
104-
}
105106
}
106107
}

Stepic/Sources/Controllers/StyledNavigationController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ class StyledNavigationController: UINavigationController {
331331
self.navigationBarAppearanceForController.removeValue(forKey: viewController.hashValue)
332332
}
333333

334+
// swiftlint:disable:next cyclomatic_complexity
334335
private func animateShadowView(transitionCoordinator: UIViewControllerTransitionCoordinator) {
335336
guard let fromViewController = self.transitionCoordinator?.viewController(forKey: .from),
336337
let toViewController = self.transitionCoordinator?.viewController(forKey: .to) else {

Stepic/Sources/Modules/CourseInfoSubmodules/CourseInfoTabSyllabus/Provider/SyllabusDownloadsService.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ final class SyllabusDownloadsService: SyllabusDownloadsServiceProtocol {
421421
return .cached(bytesTotal: unitSizeInBytes)
422422
}
423423

424+
// swiftlint:disable:next cyclomatic_complexity
424425
func getDownloadingStateForSection(_ section: Section) -> CourseInfoTabSyllabus.DownloadState {
425426
let units = section.units
426427

Stepic/Sources/Modules/Discussions/DiscussionsInteractor.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ final class DiscussionsInteractor: DiscussionsInteractorProtocol {
474474
return max(leftToLoad, 0)
475475
}
476476

477+
// TODO: Fix cyclomatic_complexity
477478
private func getLoadedDiscussionsWindow() -> (startIndex: Int, endIndex: Int) {
478479
let loadedDiscussionsIDs = Set(self.currentDiscussions.map({ $0.id }))
479480

Stepic/Sources/Modules/Discussions/Views/DiscussionsTableViewDataSource.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ extension DiscussionsTableViewDataSource: UITableViewDataSource {
128128
cell.isUpdating = viewModel.isFetchingMoreReplies
129129
}
130130

131+
// TODO: Refactor
131132
private func configureDiscussionCell(
132133
_ cell: DiscussionsTableViewCell,
133134
at indexPath: IndexPath,

Stepic/Sources/Modules/EditStep/EditStepInteractor.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,24 @@ final class EditStepInteractor: EditStepInteractorProtocol {
109109
return
110110
}
111111

112-
let params = AnalyticsEvents.Step.Edit.makeParams(
113-
stepID: step.id, type: step.block.type.rawValue, position: step.position
114-
)
112+
let params: [String: Any] = [
113+
"step": step.id,
114+
"type": step.block.name,
115+
"number": step.position
116+
]
115117

116118
switch event {
117119
case .opened:
118120
AmplitudeAnalyticsEvents.Steps.stepEditOpened(
119121
stepID: step.id,
120-
type: step.block.type.rawValue,
122+
type: step.block.name,
121123
position: step.position
122124
).send()
123125
AnalyticsReporter.reportEvent(AnalyticsEvents.Step.Edit.opened, parameters: params)
124126
case .completed:
125127
AmplitudeAnalyticsEvents.Steps.stepEditCompleted(
126128
stepID: step.id,
127-
type: step.block.type.rawValue,
129+
type: step.block.name,
128130
position: step.position
129131
).send()
130132
AnalyticsReporter.reportEvent(AnalyticsEvents.Step.Edit.completed, parameters: params)

Stepic/Sources/Modules/NewLesson/NewLessonPresenter.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ final class NewLessonPresenter: NewLessonPresenterProtocol {
112112
}()
113113
return .init(
114114
id: step.id,
115-
type: step.block.type,
116115
iconImage: iconImage ?? UIImage(),
117-
isPassed: progresses[safe: index]?.isPassed ?? false
116+
isPassed: progresses[safe: index]?.isPassed ?? false,
117+
canEdit: canEdit && step.block.type != .video
118118
)
119119
}
120120
return NewLessonViewModel(
@@ -123,8 +123,7 @@ final class NewLessonPresenter: NewLessonPresenterProtocol {
123123
stepLinkMaker: {
124124
"\(StepicApplicationsInfo.stepicURL)/lesson/\(lesson.id)/step/\($0)?from_mobile_app=true"
125125
},
126-
startStepIndex: startStepIndex,
127-
canEdit: canEdit
126+
startStepIndex: startStepIndex
128127
)
129128
}
130129

Stepic/Sources/Modules/NewLesson/NewLessonViewController.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,7 @@ final class NewLessonViewController: TabmanViewController, ControllerWithStepikP
322322
return
323323
}
324324

325-
let showEditStep = data.canEdit && step.type != .video
326-
327-
self.navigationItem.rightBarButtonItems = showEditStep
325+
self.navigationItem.rightBarButtonItems = step.canEdit
328326
? self.teacherRightBarButtonItems
329327
: self.studentRightBarButtonItems
330328
}

Stepic/Sources/Modules/NewLesson/NewLessonViewModel.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ import Foundation
33
struct NewLessonViewModel {
44
struct StepDescription {
55
let id: Step.IdType
6-
let type: Block.BlockType
76
let iconImage: UIImage
87
let isPassed: Bool
8+
let canEdit: Bool
99
}
1010

1111
let lessonTitle: String
1212
let steps: [StepDescription]
1313
let stepLinkMaker: (String) -> String
1414
let startStepIndex: Int
15-
let canEdit: Bool
1615
}

0 commit comments

Comments
 (0)