| | |
| | | } |
| | | case .story1,.story2: |
| | | if let dict = noti.object as? Dictionary<String,Any>{ |
| | | weakSelf.storyComplete(storyId: dict["storyId"] as! Int, integral: dict["storyIntegral"] as! Int) |
| | | let type = weakSelf.viewModel.listenType.value == .story1 ? 1:0 |
| | | let accracy = Int(Double(weakSelf.viewModel.correctNum) / Double(weakSelf.viewModel.correctNum + weakSelf.viewModel.errorNum) * 100) |
| | | weakSelf.storyComplete(storyId: dict["storyId"] as! Int, accuracy: accracy, studyTime: weakSelf.viewModel.times, type: type, integral: dict["storyIntegral"] as! Int) |
| | | } |
| | | } |
| | | return |
| | |
| | | |
| | | viewModel.currentPage.subscribe(onNext: {[weak self]currentPage in |
| | | guard let weakSelf = self else { return } |
| | | self?.btn_forward.isHidden = currentPage <= 0 |
| | | self?.setPages() |
| | | weakSelf.btn_forward.isHidden = currentPage <= 0 |
| | | weakSelf.setPages() |
| | | }).disposed(by: disposeBag) |
| | | |
| | | viewModel.answerCount.subscribe(onNext: {[weak self] count in |
| | |
| | | label_pageNum.text = "已完成:\(viewModel.currentPage.value + 1)/\((data as! ListenNewModel).subjectList.count)" |
| | | case .lesson4: |
| | | //两题为一组:需要/2 |
| | | label_pageNum.text = "已完成:\(viewModel.answerCount.value)/\((data as! ListenNewModel).subjectList.flatMap({$0}).count / 2)" |
| | | label_pageNum.text = "已完成:\(viewModel.currentPage.value + 1)/\((data as! ListenNewModel).subjectList.count)" |
| | | case .game1,.game2: |
| | | btn_forward.isHidden = true |
| | | label_pageNum.isHidden = true |
| | |
| | | let count = (data as! Listen1Model).storyList.count |
| | | viewModel.maxPage.accept(count) |
| | | label_pageNum.text = "已完成:\(viewModel.currentPage.value + 1)/\(count)" |
| | | default:break |
| | | } |
| | | } |
| | | |
| | |
| | | /// - Parameter ignorePush: 是否忽略跳转(未完成答题 :true) |
| | | private func studyComplete(){ |
| | | var toalIntegral:Int = 0 |
| | | var ids:String = "" |
| | | |
| | | let ids:String = viewModel.answerItems_1.keys.sorted().joined(separator: ",") |
| | | switch viewModel.listenType.value { |
| | | case .lesson1,.lesson2,.lesson3,.lesson4,.lesson5: |
| | | let data = (data as! ListenNewModel).data |
| | |
| | | }).disposed(by: disposeBag) |
| | | |
| | | timer.invalidate() |
| | | |
| | | toalIntegral = floor(Double(toalIntegral) * (Double(accracy) / 100.0)).int |
| | | |
| | | let vc = HomeStudyCompleteVC(correctNum: viewModel.correctNum, errorNum: viewModel.errorNum, totalCoin: toalIntegral, listenType: viewModel.listenType.value) |
| | | vc.title = viewModel.listenType.value.rawTitle |
| | |
| | | push(vc: vc) |
| | | } |
| | | |
| | | private func storyComplete(storyId:Int,integral:Int){ |
| | | private func storyComplete(storyId:Int,accuracy:Int,studyTime:Int,type:Int,integral:Int){ |
| | | timer.invalidate() |
| | | |
| | | Services.completeStory(storyId: storyId, integral: integral).subscribe(onNext: {data in |
| | | Services.completeStory(storyId: storyId, accuracy: accuracy, studyTime: studyTime, type: type).subscribe(onNext: {data in |
| | | NotificationCenter.default.post(name: Refresh_ListenSchedule_Noti, object: nil) |
| | | }).disposed(by: disposeBag) |
| | | |
| | |
| | | if btn_exit.titleLabel?.text == "完成"{ |
| | | if viewModel.listenType.value == .story2{ |
| | | let v = data as! Listen1Model |
| | | storyComplete(storyId: v.data!.id, integral: v.data!.lookIntegral) |
| | | let accuracy = Int(Double(viewModel.correctNum) / Double(viewModel.correctNum + viewModel.errorNum) * 100) |
| | | storyComplete(storyId: v.data!.id, accuracy: accuracy, studyTime: viewModel.times, type: 1, integral: v.data!.lookIntegral) |
| | | } |
| | | }else{ |
| | | CommonAlertView.show(content: "未完成全部答题,确认退出吗?") {[weak self] () in |
| | |
| | | let topicIds = weakSelf.viewModel.answerItems_1.keys.sorted() |
| | | let temIds = weakSelf.viewModel.answerItems_1.values.flatMap({$0}).map({"\($0)"}) |
| | | |
| | | var schedule:Int = 0 |
| | | switch weakSelf.viewModel.listenType.value{ |
| | | case .lesson1,.lesson2,.lesson5:schedule = weakSelf.viewModel.answerCount.value |
| | | case .lesson3:schedule = weakSelf.viewModel.currentPage.value + 1 |
| | | case .lesson4:schedule = weakSelf.viewModel.currentPage.value + 1 |
| | | default:break |
| | | } |
| | | |
| | | switch weakSelf.viewModel.listenType.value{ |
| | | case .lesson1,.lesson2,.lesson3,.lesson4,.lesson5: |
| | | if temIds.count > 0 && topicIds.count > 0{ |
| | | let totalNum = weakSelf.viewModel.correctNum + weakSelf.viewModel.errorNum |
| | | Services.exitLearning(type:weakSelf.viewModel.listenType.value.rawValue,week: weakSelf.viewModel.week.value!, day: weakSelf.viewModel.day.value!, teamIds: temIds, topicIds: topicIds,answerNumber: totalNum,correctNumber:weakSelf.viewModel.correctNum,studyTime:weakSelf.viewModel.times).subscribe(onNext: { data in |
| | | Services.exitLearning(type:weakSelf.viewModel.listenType.value.rawValue,week: weakSelf.viewModel.week.value!, day: weakSelf.viewModel.day.value!, teamIds: temIds, topicIds: topicIds,answerNumber: totalNum,correctNumber:weakSelf.viewModel.correctNum,studyTime:weakSelf.viewModel.times,schedule: schedule).subscribe(onNext: { data in |
| | | |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | } |