// // RQYDTQuestionModule.m // jiaPei // // Created by 张嵘 on 2022/3/28. // Copyright © 2022 JCZ. All rights reserved. // #import "RQYDTQuestionModule.h" #import "RQYDTXCQuestionModule.h" #import "RQYDTHCQuestionModule.h" #import "RQYDTKCQuestionModule.h" #import "RQYDTMTCQuestionModule.h" #import "RQYDTZGZJLYQuestionModule.h" #import "RQYDTZGZKYQuestionModule.h" #import "RQYDTZGZHYQuestionModule.h" #import "RQYDTZGZWXPQuestionModule.h" #import "RQYDTZGZCZCQuestionModule.h" #import "RQYDTZGZWYCQuestionModule.h" NSString * const RQCarTypeChangeNotification = @"RQCarTypeChangeNotification"; /// 正式环境key static NSString * const RQYDTQuestionCarTypeKey = @"RQYDTQuestionCarTypeKey"; @interface RQYDTQuestionModule () /// 科目一顺序练习 @property (nonatomic, readwrite, copy) NSArray *subjectOneArr; /// 科目四顺序练习 @property (nonatomic, readwrite, copy) NSArray *subjectFourArr; @property (nonatomic, readwrite, strong) NSString *downloadUrl; @property (nonatomic, readwrite, strong) NSString *jsDownloadUrl; @property (nonatomic, readwrite, strong) NSString *jqDownloadUrl; @end @implementation RQYDTQuestionModule static id rq_ydtQuestionModule = nil; #pragma mark - init + (instancetype)sharedInstance { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ rq_ydtQuestionModule = [[self alloc] init]; }); return rq_ydtQuestionModule; } - (instancetype)init { if (self = [super init]) { NSInteger userVersion = [RQ_YDT_USER_Question_Module getQuestionVersion]; NSLog(@"用户题库版本号:%ld",userVersion); NSInteger xcVersion = [RQ_YDT_XC_Question_Module getQuestionVersion]; NSLog(@"小车题库版本号:%ld",xcVersion); NSInteger hcVersion = [RQ_YDT_HC_Question_Module getQuestionVersion]; NSLog(@"货车题库版本号:%ld",hcVersion); NSInteger kcVersion = [RQ_YDT_KC_Question_Module getQuestionVersion]; NSLog(@"客车题库版本号:%ld",kcVersion); NSInteger mtcVersion = [RQ_YDT_MTC_Question_Module getQuestionVersion]; NSLog(@"摩托车题库版本号:%ld",mtcVersion); NSInteger zgzJlyVersion = [RQ_YDT_ZGZ_JLY_Question_Module getQuestionVersion]; NSLog(@"资格证教练员题库版本号:%ld",zgzJlyVersion); } return self; } - (void)saveQuestionsWithSubjectOneArr:(NSArray *)subjectOneArr { self.subjectOneArr = subjectOneArr; } - (void)saveQuestionsWithSubjectFourArr:(NSArray *)subjectFourArr { self.subjectFourArr = subjectFourArr; } - (void)setCarType:(RQHomePageCarType)carType { NSString *carTypeStr = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:carType]]; [[NSUserDefaults standardUserDefaults] setObject:carTypeStr forKey:RQYDTQuestionCarTypeKey]; [[NSUserDefaults standardUserDefaults] synchronize]; } - (RQHomePageCarType)carType { NSString *carTypeStr = [[NSUserDefaults standardUserDefaults] objectForKey:RQYDTQuestionCarTypeKey]; carTypeStr = [carTypeStr rq_stringValueExtension]; return carTypeStr.integerValue; } - (NSString *)carTypeStr { return [self getCarTypeNameWithCarType:self.carType]; } - (NSString *)carTypeStrNew { switch (self.carType) { case RQHomePageCarType_Car: return @"cart"; case RQHomePageCarType_Bus: return @"bus"; case RQHomePageCarType_Truck: return @"truck"; case RQHomePageCarType_Motorcycle: return @"mtc"; case RQHomePageCarType_ZGZ_JLY: return @"zgzjl"; case RQHomePageCarType_ZGZ_KY: return @"zgzky"; case RQHomePageCarType_ZGZ_HY: return @"zgzhy"; case RQHomePageCarType_ZGZ_WXP: return @"zgzwxp"; case RQHomePageCarType_ZGZ_CZC: return @"zgzcz"; case RQHomePageCarType_ZGZ_WYC: return @"zgzwyc"; default: return @"cart"; } } - (NSString *)subjectStr { return [self getSubjectNameWithSubject:self.subject]; } #pragma mark - PublicMethods /// 更新题库 - (void)rq_updateQuestion { @weakify(self) [[[RQ_HTTP_Service getUpdateQuestion] deliverOnMainThread] subscribeNext:^(NSArray *arr) { [[arr.rac_sequence.signal filter:^BOOL(RQDictInfoModel *dictInfoModel) { return [dictInfoModel.dictLabel isEqualToString:[RQ_YDTQuestion_Module getCarTypeCNTiKuUpdateNameWithCarType:RQ_YDTQuestion_Module.carType]]; }] subscribeNext:^(RQDictInfoModel *dictInfoModel) { @strongify(self) NSInteger netVersion = dictInfoModel.remark.integerValue; NSInteger localVersion = [RQ_YDTQuestion_Module getQuestionVersion]; self.downloadUrl = dictInfoModel.dictValue; if (netVersion > localVersion) { NSLog(@"题库需要更新!"); [self rq_showDBUpdateView]; } else { NSLog(@"题库不需要更新!"); } }]; [[arr.rac_sequence.signal filter:^BOOL(RQDictInfoModel *dictInfoModel) { return [dictInfoModel.dictLabel isEqualToString:@"题库解释"]; }] subscribeNext:^(RQDictInfoModel *dictInfoModel) { @strongify(self) NSInteger netVersion = dictInfoModel.remark.integerValue; NSInteger localVersion = [RQ_YDT_JS_Question_Module getQuestionVersion]; self.jsDownloadUrl = dictInfoModel.dictValue; if (netVersion > localVersion) { NSLog(@"解释题库需要更新!"); [self rq_showJSUpdateView]; } else { NSLog(@"解释题库不需要更新!"); } }]; [[arr.rac_sequence.signal filter:^BOOL(RQDictInfoModel *dictInfoModel) { return [dictInfoModel.dictLabel isEqualToString:@"快通解释"]; }] subscribeNext:^(RQDictInfoModel *dictInfoModel) { @strongify(self) NSInteger netVersion = dictInfoModel.remark.integerValue; NSInteger localVersion = [YN_YDT_JQ_Question_Module getQuestionVersion]; self.jqDownloadUrl = dictInfoModel.dictValue; if (netVersion > localVersion) { NSLog(@"快通解释题库需要更新!"); [self rq_showJQUpdateView]; } else { NSLog(@"快通解释题库不需要更新!"); } }]; }]; } - (NSInteger)getQuestionVersion { switch (self.carType) { case RQHomePageCarType_Car: return [RQ_YDT_XC_Question_Module getQuestionVersion]; case RQHomePageCarType_Truck: return [RQ_YDT_HC_Question_Module getQuestionVersion]; case RQHomePageCarType_Bus: return [RQ_YDT_KC_Question_Module getQuestionVersion]; case RQHomePageCarType_Motorcycle: return [RQ_YDT_MTC_Question_Module getQuestionVersion]; case RQHomePageCarType_ZGZ_JLY: return [RQ_YDT_ZGZ_JLY_Question_Module getQuestionVersion]; case RQHomePageCarType_ZGZ_KY: return [RQ_YDT_ZGZ_KY_Question_Module getQuestionVersion]; case RQHomePageCarType_ZGZ_HY: return [RQ_YDT_ZGZ_HY_Question_Module getQuestionVersion]; case RQHomePageCarType_ZGZ_WXP: return [RQ_YDT_ZGZ_WXP_Question_Module getQuestionVersion]; case RQHomePageCarType_ZGZ_CZC: return [RQ_YDT_ZGZ_CZC_Question_Module getQuestionVersion]; case RQHomePageCarType_ZGZ_WYC: return [RQ_YDT_ZGZ_WYC_Question_Module getQuestionVersion]; default: return [RQ_YDT_XC_Question_Module getQuestionVersion]; } } - (NSString *)getSubjectNameWithSubject:(RQHomePageSubjectType)subject { switch (subject) { case RQHomePageSubjectType_SubjectOne: return @"1"; case RQHomePageSubjectType_SubjectTwo: return @"2"; case RQHomePageSubjectType_SubjectThree: return @"3"; case RQHomePageSubjectType_SubjectFour: return @"4"; default: return @"1"; } } - (RQHomePageSubjectType)getSubjectWithSubjectName:(NSString *)subjectName { if ([subjectName isEqualToString:@"1"]) { return RQHomePageSubjectType_SubjectOne; } else if ([subjectName isEqualToString:@"2"]) { return RQHomePageSubjectType_SubjectTwo; } else if ([subjectName isEqualToString:@"3"]) { return RQHomePageSubjectType_SubjectThree; } else if ([subjectName isEqualToString:@"4"]) { return RQHomePageSubjectType_SubjectFour; } else { return RQHomePageSubjectType_SubjectOne; } } - (RQHomePageCarType)getCarTypeWithCarTypeName:(NSString *)carTypeName { if ([carTypeName isEqualToString:@"C1"]) { return RQHomePageCarType_Car; } else if ([carTypeName isEqualToString:@"A2"]) { return RQHomePageCarType_Truck; } else if ([carTypeName isEqualToString:@"A1"]) { return RQHomePageCarType_Bus; } else if ([carTypeName isEqualToString:@"D"]) { return RQHomePageCarType_Motorcycle; } else if ([carTypeName isEqualToString:@"4"]) { return RQHomePageCarType_ZGZ_JLY; } else if ([carTypeName isEqualToString:@"1"]) { return RQHomePageCarType_ZGZ_KY; } else if ([carTypeName isEqualToString:@"2"]) { return RQHomePageCarType_ZGZ_HY; } else if ([carTypeName isEqualToString:@"3"]) { return RQHomePageCarType_ZGZ_WXP; } else if ([carTypeName isEqualToString:@"5"]) { return RQHomePageCarType_ZGZ_CZC; } else if ([carTypeName isEqualToString:@"6"]) { return RQHomePageCarType_ZGZ_WYC; } else { return RQHomePageCarType_Car; } } - (NSString *)getCarTypeCNNameWithCarType:(RQHomePageCarType)carType { switch (carType) { case RQHomePageCarType_Car: return @"小车"; case RQHomePageCarType_Truck: return @"货车"; case RQHomePageCarType_Bus: return @"客车"; case RQHomePageCarType_Motorcycle: return @"摩托车"; case RQHomePageCarType_ZGZ_JLY: return @"教练员"; case RQHomePageCarType_ZGZ_HY: return @"货运"; case RQHomePageCarType_ZGZ_WXP: return @"危险品"; case RQHomePageCarType_ZGZ_KY: return @"客运"; case RQHomePageCarType_ZGZ_CZC: return @"出租车"; case RQHomePageCarType_ZGZ_WYC: return @"网约车"; default: return @"小车"; } } - (NSString *)getCarTypeCNTiKuUpdateNameWithCarType:(RQHomePageCarType)carType { switch (carType) { case RQHomePageCarType_Car: return @"小车"; case RQHomePageCarType_Truck: return @"货车"; case RQHomePageCarType_Bus: return @"客车"; case RQHomePageCarType_Motorcycle: return @"摩托车"; case RQHomePageCarType_ZGZ_JLY: return @"教练员资格证"; case RQHomePageCarType_ZGZ_HY: return @"货运资格证"; case RQHomePageCarType_ZGZ_WXP: return @"危险品资格证"; case RQHomePageCarType_ZGZ_KY: return @"客运资格证"; case RQHomePageCarType_ZGZ_CZC: return @"出租车资格证"; case RQHomePageCarType_ZGZ_WYC: return @"网约车资格证"; default: return @"小车"; } } - (NSString *)getCarTypeExamNameWithCarType:(RQHomePageCarType)carType { switch (carType) { case RQHomePageCarType_Car: return @"小车C1/C2/C3"; case RQHomePageCarType_Bus: return @"客车A1/A3/B1"; case RQHomePageCarType_Truck: return @"货车A2/B2"; case RQHomePageCarType_Motorcycle: return @"摩托车D/E/F"; case RQHomePageCarType_ZGZ_JLY: return @"教练员"; case RQHomePageCarType_ZGZ_KY: return @"客运"; case RQHomePageCarType_ZGZ_HY: return @"货运"; case RQHomePageCarType_ZGZ_WXP: return @"危险品"; case RQHomePageCarType_ZGZ_CZC: return @"出租车"; case RQHomePageCarType_ZGZ_WYC: return @"网约车"; default: return @"小车"; } } - (NSString *)getCar_TypeNameWithCarType:(RQHomePageCarType)carType { switch (carType) { case RQHomePageCarType_Car: return @"C1"; case RQHomePageCarType_Truck: return @"A2"; case RQHomePageCarType_Bus: return @"A1"; case RQHomePageCarType_Motorcycle: return @"D"; case RQHomePageCarType_ZGZ_JLY: return @"4"; case RQHomePageCarType_ZGZ_HY: return @"2"; case RQHomePageCarType_ZGZ_WXP: return @"3"; case RQHomePageCarType_ZGZ_KY: return @"1"; case RQHomePageCarType_ZGZ_CZC: return @"5"; case RQHomePageCarType_ZGZ_WYC: return @"6"; default: return @"C1"; } } - (NSArray *)getQuestionWithExerciseType:(RQExerciseType)exerciseType questionIds:(NSString*)questionIds { switch (self.carType) { case RQHomePageCarType_Car: return [RQ_YDT_XC_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType questionIds:questionIds]; default: return [RQ_YDT_XC_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType]; } return @[]; } - (NSArray *)getQuestionWithExerciseType:(RQExerciseType)exerciseType code:(NSInteger)code { switch (self.carType) { case RQHomePageCarType_Car: return [RQ_YDT_XC_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType code:code]; default: return [RQ_YDT_XC_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType]; } return @[]; } - (NSArray *)getQuestionWithExerciseType:(RQExerciseType)exerciseType { switch (self.carType) { case RQHomePageCarType_Car: return [RQ_YDT_XC_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType]; case RQHomePageCarType_Truck: return [RQ_YDT_HC_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType]; case RQHomePageCarType_Bus: return [RQ_YDT_KC_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType]; case RQHomePageCarType_Motorcycle: return [RQ_YDT_MTC_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType]; case RQHomePageCarType_ZGZ_JLY: return [RQ_YDT_ZGZ_JLY_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType]; case RQHomePageCarType_ZGZ_KY: return [RQ_YDT_ZGZ_KY_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType]; case RQHomePageCarType_ZGZ_HY: return [RQ_YDT_ZGZ_HY_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType]; case RQHomePageCarType_ZGZ_WXP: return [RQ_YDT_ZGZ_WXP_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType]; case RQHomePageCarType_ZGZ_CZC: return [RQ_YDT_ZGZ_CZC_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType]; case RQHomePageCarType_ZGZ_WYC: return [RQ_YDT_ZGZ_WYC_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType]; default: return [RQ_YDT_XC_Question_Module getQuestionWithSubject:self.subject exerciseType:exerciseType]; } } - (NSArray *)getQuestionWithSubject:(RQHomePageSubjectType)subject exerciseType:(RQExerciseType)exerciseType { switch (self.carType) { case RQHomePageCarType_Car: return [RQ_YDT_XC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_Truck: return [RQ_YDT_HC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_Bus: return [RQ_YDT_KC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_Motorcycle: return [RQ_YDT_MTC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_ZGZ_JLY: return [RQ_YDT_ZGZ_JLY_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_ZGZ_KY: return [RQ_YDT_ZGZ_KY_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_ZGZ_HY: return [RQ_YDT_ZGZ_HY_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_ZGZ_WXP: return [RQ_YDT_ZGZ_WXP_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_ZGZ_CZC: return [RQ_YDT_ZGZ_CZC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_ZGZ_WYC: return [RQ_YDT_ZGZ_WYC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType]; default: return [RQ_YDT_XC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType]; } } - (NSArray *)getQuestionWithSubject:(RQHomePageSubjectType)subject exerciseType:(RQExerciseType)exerciseType isNeedMediaData:(BOOL)isNeedMediaData { switch (self.carType) { case RQHomePageCarType_Car: return [RQ_YDT_XC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_Truck: return [RQ_YDT_HC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType ]; case RQHomePageCarType_Bus: return [RQ_YDT_KC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType ]; case RQHomePageCarType_Motorcycle: return [RQ_YDT_MTC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType ]; case RQHomePageCarType_ZGZ_JLY: return [RQ_YDT_ZGZ_JLY_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType ]; case RQHomePageCarType_ZGZ_KY: return [RQ_YDT_ZGZ_KY_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType ]; case RQHomePageCarType_ZGZ_HY: return [RQ_YDT_ZGZ_HY_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType ]; case RQHomePageCarType_ZGZ_WXP: return [RQ_YDT_ZGZ_WXP_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType ]; case RQHomePageCarType_ZGZ_CZC: return [RQ_YDT_ZGZ_CZC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType ]; case RQHomePageCarType_ZGZ_WYC: return [RQ_YDT_ZGZ_WYC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType ]; default: return [RQ_YDT_XC_Question_Module getQuestionWithSubject:subject exerciseType:exerciseType]; } } - (NSInteger)getQuestionNumWithWithSubject:(RQHomePageSubjectType)subject exerciseType:(RQExerciseType)exerciseType { switch (self.carType) { case RQHomePageCarType_Car: return [RQ_YDT_XC_Question_Module getQuestionNumWithWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_Truck: return [RQ_YDT_HC_Question_Module getQuestionNumWithWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_Bus: return [RQ_YDT_KC_Question_Module getQuestionNumWithWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_Motorcycle: return [RQ_YDT_MTC_Question_Module getQuestionNumWithWithSubject:subject exerciseType:exerciseType]; case RQHomePageCarType_ZGZ_JLY: return [RQ_YDT_ZGZ_JLY_Question_Module getQuestionNumWithExerciseType:exerciseType]; case RQHomePageCarType_ZGZ_KY: return [RQ_YDT_ZGZ_KY_Question_Module getQuestionNumWithExerciseType:exerciseType]; case RQHomePageCarType_ZGZ_HY: return [RQ_YDT_ZGZ_HY_Question_Module getQuestionNumWithExerciseType:exerciseType]; case RQHomePageCarType_ZGZ_WXP: return [RQ_YDT_ZGZ_WXP_Question_Module getQuestionNumWithExerciseType:exerciseType]; case RQHomePageCarType_ZGZ_CZC: return [RQ_YDT_ZGZ_CZC_Question_Module getQuestionNumWithExerciseType:exerciseType]; case RQHomePageCarType_ZGZ_WYC: return [RQ_YDT_ZGZ_WYC_Question_Module getQuestionNumWithExerciseType:exerciseType]; default: return [RQ_YDT_XC_Question_Module getQuestionNumWithWithSubject:subject exerciseType:exerciseType]; } } - (NSArray *)getChapterArr { switch (self.carType) { case RQHomePageCarType_Car: return [RQ_YDT_XC_Question_Module getChapter]; case RQHomePageCarType_Truck: return [RQ_YDT_HC_Question_Module getChapter]; case RQHomePageCarType_Bus: return [RQ_YDT_KC_Question_Module getChapter]; case RQHomePageCarType_Motorcycle: return [RQ_YDT_MTC_Question_Module getChapter]; case RQHomePageCarType_ZGZ_JLY: return [RQ_YDT_ZGZ_JLY_Question_Module getChapter]; case RQHomePageCarType_ZGZ_KY: return [RQ_YDT_ZGZ_KY_Question_Module getChapter]; case RQHomePageCarType_ZGZ_HY: return [RQ_YDT_ZGZ_HY_Question_Module getChapter]; case RQHomePageCarType_ZGZ_WXP: return [RQ_YDT_ZGZ_WXP_Question_Module getChapter]; case RQHomePageCarType_ZGZ_CZC: return [RQ_YDT_ZGZ_CZC_Question_Module getChapter]; case RQHomePageCarType_ZGZ_WYC: return [RQ_YDT_ZGZ_WYC_Question_Module getChapter]; default: return [RQ_YDT_XC_Question_Module getChapter]; } } - (NSArray *)getChapterQuestionWithChapterName:(NSString *)chapterName { switch (self.carType) { case RQHomePageCarType_Car: return [RQ_YDT_XC_Question_Module getChapterQuestionWithChapterName:chapterName]; case RQHomePageCarType_Truck: return [RQ_YDT_HC_Question_Module getChapterQuestionWithChapterName:chapterName]; case RQHomePageCarType_Bus: return [RQ_YDT_KC_Question_Module getChapterQuestionWithChapterName:chapterName]; case RQHomePageCarType_Motorcycle: return [RQ_YDT_MTC_Question_Module getChapterQuestionWithChapterName:chapterName]; case RQHomePageCarType_ZGZ_JLY: return [RQ_YDT_ZGZ_JLY_Question_Module getChapterQuestionWithChapterName:chapterName]; case RQHomePageCarType_ZGZ_KY: return [RQ_YDT_ZGZ_KY_Question_Module getChapterQuestionWithChapterName:chapterName]; case RQHomePageCarType_ZGZ_HY: return [RQ_YDT_ZGZ_HY_Question_Module getChapterQuestionWithChapterName:chapterName]; case RQHomePageCarType_ZGZ_WXP: return [RQ_YDT_ZGZ_WXP_Question_Module getChapterQuestionWithChapterName:chapterName]; case RQHomePageCarType_ZGZ_CZC: return [RQ_YDT_ZGZ_CZC_Question_Module getChapterQuestionWithChapterName:chapterName]; case RQHomePageCarType_ZGZ_WYC: return [RQ_YDT_ZGZ_WYC_Question_Module getChapterQuestionWithChapterName:chapterName]; default: return [RQ_YDT_XC_Question_Module getChapterQuestionWithChapterName:chapterName]; } } - (NSArray *)getChapterQuestionWithChapterName:(NSString *)chapterName exerciseType:(RQExerciseType)exerciseType { return [RQ_YDT_XC_Question_Module getChapterQuestionWithChapterName:chapterName exerciseType:exerciseType]; } - (NSArray *)getPoint { switch (self.carType) { case RQHomePageCarType_Car: return [RQ_YDT_XC_Question_Module getPoint]; case RQHomePageCarType_Truck: return [RQ_YDT_HC_Question_Module getPoint]; case RQHomePageCarType_Bus: return [RQ_YDT_KC_Question_Module getPoint]; case RQHomePageCarType_Motorcycle: return [RQ_YDT_MTC_Question_Module getPoint]; case RQHomePageCarType_ZGZ_JLY: return [RQ_YDT_ZGZ_JLY_Question_Module getPoint]; case RQHomePageCarType_ZGZ_KY: return [RQ_YDT_ZGZ_KY_Question_Module getPoint]; case RQHomePageCarType_ZGZ_HY: return [RQ_YDT_ZGZ_HY_Question_Module getPoint]; case RQHomePageCarType_ZGZ_WXP: return [RQ_YDT_ZGZ_WXP_Question_Module getPoint]; case RQHomePageCarType_ZGZ_CZC: return [RQ_YDT_ZGZ_CZC_Question_Module getPoint]; case RQHomePageCarType_ZGZ_WYC: return [RQ_YDT_ZGZ_WYC_Question_Module getPoint]; default: return [RQ_YDT_XC_Question_Module getPoint]; } } - (NSArray *)getPointQuestionWithPointID:(NSInteger)pointId { switch (self.carType) { case RQHomePageCarType_Car: return [RQ_YDT_XC_Question_Module getPointQuestionWithPointId:pointId]; case RQHomePageCarType_Truck: return [RQ_YDT_HC_Question_Module getPointQuestionWithPointId:pointId]; case RQHomePageCarType_Bus: return [RQ_YDT_KC_Question_Module getPointQuestionWithPointId:pointId]; case RQHomePageCarType_Motorcycle: return [RQ_YDT_MTC_Question_Module getPointQuestionWithPointId:pointId]; case RQHomePageCarType_ZGZ_JLY: return [RQ_YDT_ZGZ_JLY_Question_Module getPointQuestionWithPointId:pointId]; case RQHomePageCarType_ZGZ_KY: return [RQ_YDT_ZGZ_KY_Question_Module getPointQuestionWithPointId:pointId]; case RQHomePageCarType_ZGZ_HY: return [RQ_YDT_ZGZ_HY_Question_Module getPointQuestionWithPointId:pointId]; case RQHomePageCarType_ZGZ_WXP: return [RQ_YDT_ZGZ_WXP_Question_Module getPointQuestionWithPointId:pointId]; case RQHomePageCarType_ZGZ_CZC: return [RQ_YDT_ZGZ_CZC_Question_Module getPointQuestionWithPointId:pointId]; case RQHomePageCarType_ZGZ_WYC: return [RQ_YDT_ZGZ_WYC_Question_Module getPointQuestionWithPointId:pointId]; default: return [RQ_YDT_XC_Question_Module getPointQuestionWithPointId:pointId]; } } - (NSArray *)getPointQuestionWithPointID:(NSInteger)pointId exerciseType:(RQExerciseType)exerciseType { return [RQ_YDT_XC_Question_Module getPointQuestionWithPointId:pointId exerciseType:exerciseType]; } - (BOOL)isNewRuleQuestionWithQuestionId:(NSInteger)questionId { switch (self.carType) { case RQHomePageCarType_Car: return [RQ_YDT_XC_Question_Module isNewRuleQuestionWithQuestionId:questionId]; case RQHomePageCarType_Truck: return [RQ_YDT_HC_Question_Module isNewRuleQuestionWithQuestionId:questionId]; case RQHomePageCarType_Bus: return [RQ_YDT_KC_Question_Module isNewRuleQuestionWithQuestionId:questionId]; case RQHomePageCarType_Motorcycle: return [RQ_YDT_MTC_Question_Module isNewRuleQuestionWithQuestionId:questionId]; case RQHomePageCarType_ZGZ_JLY: return [RQ_YDT_ZGZ_JLY_Question_Module isNewRuleQuestionWithQuestionId:questionId]; case RQHomePageCarType_ZGZ_KY: return [RQ_YDT_ZGZ_KY_Question_Module isNewRuleQuestionWithQuestionId:questionId]; case RQHomePageCarType_ZGZ_HY: return [RQ_YDT_ZGZ_HY_Question_Module isNewRuleQuestionWithQuestionId:questionId]; case RQHomePageCarType_ZGZ_WXP: return [RQ_YDT_ZGZ_WXP_Question_Module isNewRuleQuestionWithQuestionId:questionId]; case RQHomePageCarType_ZGZ_CZC: return [RQ_YDT_ZGZ_CZC_Question_Module isNewRuleQuestionWithQuestionId:questionId]; case RQHomePageCarType_ZGZ_WYC: return [RQ_YDT_ZGZ_WYC_Question_Module isNewRuleQuestionWithQuestionId:questionId]; default: return [RQ_YDT_XC_Question_Module isNewRuleQuestionWithQuestionId:questionId]; } } - (NSData *)getMediaDataWithMediaName:(NSString *)mediaName { switch (self.carType) { case RQHomePageCarType_Car: return [RQ_YDT_XC_Question_Module getMediaDataWithMediaName:mediaName]; case RQHomePageCarType_Truck: return [RQ_YDT_HC_Question_Module getMediaDataWithMediaName:mediaName]; case RQHomePageCarType_Bus: return [RQ_YDT_KC_Question_Module getMediaDataWithMediaName:mediaName]; case RQHomePageCarType_Motorcycle: return [RQ_YDT_MTC_Question_Module getMediaDataWithMediaName:mediaName]; case RQHomePageCarType_ZGZ_JLY: return [RQ_YDT_ZGZ_JLY_Question_Module getMediaDataWithMediaName:mediaName]; case RQHomePageCarType_ZGZ_KY: return [RQ_YDT_ZGZ_KY_Question_Module getMediaDataWithMediaName:mediaName]; case RQHomePageCarType_ZGZ_HY: return [RQ_YDT_ZGZ_HY_Question_Module getMediaDataWithMediaName:mediaName]; case RQHomePageCarType_ZGZ_WXP: return [RQ_YDT_ZGZ_WXP_Question_Module getMediaDataWithMediaName:mediaName]; case RQHomePageCarType_ZGZ_CZC: return [RQ_YDT_ZGZ_CZC_Question_Module getMediaDataWithMediaName:mediaName]; case RQHomePageCarType_ZGZ_WYC: return [RQ_YDT_ZGZ_WYC_Question_Module getMediaDataWithMediaName:mediaName]; default: return [RQ_YDT_XC_Question_Module getMediaDataWithMediaName:mediaName]; } } /// 做到哪一题 - (NSInteger)getHistoryQuestionNum { NSString *key = [NSString stringWithFormat:@"HistoryQuestionNum%ld-%ld-%ld-%@",self.subject,self.carType,RQ_Exercise_Module.currentExerciseType,RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.loginCode)? RQ_USER_MANAGER.currentUser.loginCode : @"0"]; if ((RQ_Exercise_Module.currentExerciseType == RQExerciseType_Point || RQ_Exercise_Module.currentExerciseType == RQExerciseType_Chapter) && RQStringIsNotEmpty(RQ_Exercise_Module.otherStr)) { key = [NSString stringWithFormat:@"HistoryQuestionNum%ld-%ld-%ld-%@-%@",self.subject,self.carType,RQ_Exercise_Module.currentExerciseType,RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.loginCode)? RQ_USER_MANAGER.currentUser.loginCode : @"0", RQ_Exercise_Module.otherStr]; }else if(RQ_Exercise_Module.currentExerciseType == RQExerciseType_Block_List) { key = [NSString stringWithFormat:@"HistoryQuestionNum%ld-%ld-%ld-%@-%@-%@",self.subject,self.carType,RQ_Exercise_Module.currentExerciseType,RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.loginCode)? RQ_USER_MANAGER.currentUser.loginCode : @"0", RQ_Exercise_Module.otherStr,RQ_Exercise_Module.codeStr]; } id object = [RQ_COMMON_MANAGER getObjectWithKey:key]; if (RQObjectIsNil(object)) { return 0; } else { NSInteger historyQuestionNum = [object integerValue]; return historyQuestionNum; } } - (void)saveHistoryQuestionNumWithQuestionId:(NSInteger)questionId { NSString *key = [NSString stringWithFormat:@"HistoryQuestionNum%ld-%ld-%ld-%@",self.subject,self.carType,RQ_Exercise_Module.currentExerciseType,RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.loginCode)? RQ_USER_MANAGER.currentUser.loginCode : @"0"]; if ((RQ_Exercise_Module.currentExerciseType == RQExerciseType_Point || RQ_Exercise_Module.currentExerciseType == RQExerciseType_Chapter) && RQStringIsNotEmpty(RQ_Exercise_Module.otherStr)) { key = [NSString stringWithFormat:@"HistoryQuestionNum%ld-%ld-%ld-%@-%@",self.subject,self.carType,RQ_Exercise_Module.currentExerciseType,RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.loginCode)? RQ_USER_MANAGER.currentUser.loginCode : @"0", RQ_Exercise_Module.otherStr]; }else if(RQ_Exercise_Module.currentExerciseType == RQExerciseType_Block_List) { key = [NSString stringWithFormat:@"HistoryQuestionNum%ld-%ld-%ld-%@-%@-%@",self.subject,self.carType,RQ_Exercise_Module.currentExerciseType,RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.loginCode)? RQ_USER_MANAGER.currentUser.loginCode : @"0", RQ_Exercise_Module.otherStr,RQ_Exercise_Module.codeStr]; } [RQ_SHARE_FUNCTION saveObjectWithObject:@(questionId) ForKey:key]; } - (NSString *)isWelcomed { id object = [RQ_SHARE_FUNCTION getObjectWithKey:@"isWelcomed"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *isWelcomed = (NSString *)object; return isWelcomed; } } - (void)setIsWelcomed:(NSString *)isWelcomed { [RQ_SHARE_FUNCTION saveObjectWithObject:isWelcomed ForKey:@"isWelcomed"]; } - (NSString *)car_type { return [self getCar_TypeNameWithCarType:self.carType]; } - (NSString *)userSubj1Index { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"userSubj1Index"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *userSubj1Index = (NSString *)object; return userSubj1Index; } } - (void)setUserSubj1Index:(NSString *)userSubj1Index { [RQ_COMMON_MANAGER saveObjectWithObject:userSubj1Index ForKey:@"userSubj1Index"]; } - (NSString *)userSubj4Index { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"userSubj4Index"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *userSubj4Index = (NSString *)object; return userSubj4Index; } } - (void)setUserSubj4Index:(NSString *)userSubj4Index { [RQ_COMMON_MANAGER saveObjectWithObject:userSubj4Index ForKey:@"userSubj4Index"]; } - (NSString *)user1Index { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"user1Index"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *user1Index = (NSString *)object; return user1Index; } } - (void)setUser1Index:(NSString *)user1Index { [RQ_COMMON_MANAGER saveObjectWithObject:user1Index ForKey:@"user1Index"]; } - (NSString *)user4Index { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"user4Index"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *user4Index = (NSString *)object; return user4Index; } } - (void)setUser4Index:(NSString *)user4Index { [RQ_COMMON_MANAGER saveObjectWithObject:user4Index ForKey:@"user4Index"]; } - (NSString *)A2Subj1Index { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"A2Subj1Index"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *A2Subj1Index = (NSString *)object; return A2Subj1Index; } } - (void)setA2Subj1Index:(NSString *)A2Subj1Index{ [RQ_COMMON_MANAGER saveObjectWithObject:A2Subj1Index ForKey:@"A2Subj1Index"]; } - (NSString *)A2Subj4Index { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"A2Subj4Index"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *A2Subj4Index = (NSString *)object; return A2Subj4Index; } } - (void)setA2Subj4Index:(NSString *)A2Subj4Index { [RQ_COMMON_MANAGER saveObjectWithObject:A2Subj4Index ForKey:@"A2Subj4Index"]; } - (NSString *)A1Subj1Index { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"A1Subj1Index"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *A1Subj1Index = (NSString *)object; return A1Subj1Index; } } - (void)setA1Subj1Index:(NSString *)A1Subj1Index { [RQ_COMMON_MANAGER saveObjectWithObject:A1Subj1Index ForKey:@"A1Subj1Index"]; } - (NSString *)A1Subj4Index { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"A1Subj4Index"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *A1Subj4Index = (NSString *)object; return A1Subj4Index; } } - (void)setA1Subj4Index:(NSString *)A1Subj4Index { [RQ_COMMON_MANAGER saveObjectWithObject:A1Subj4Index ForKey:@"A1Subj4Index"]; } - (NSString *)DSubj1Index { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"DSubj1Index"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *DSubj1Index = (NSString *)object; return DSubj1Index; } } - (void)setDSubj1Index:(NSString *)DSubj1Index { [RQ_COMMON_MANAGER saveObjectWithObject:DSubj1Index ForKey:@"DSubj1Index"]; } - (NSString *)DSubj4Index { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"DSubj4Index"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *DSubj4Index = (NSString *)object; return DSubj4Index; } } - (void)setDSubj4Index:(NSString *)DSubj4Index { [RQ_COMMON_MANAGER saveObjectWithObject:DSubj4Index ForKey:@"DSubj4Index"]; } - (NSString *)coachIndex { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"coachIndex"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *coachIndex = (NSString *)object; return coachIndex; } } - (void)setCoachIndex:(NSString *)coachIndex { [RQ_COMMON_MANAGER saveObjectWithObject:coachIndex ForKey:@"coachIndex"]; } - (NSString *)A1Index { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"A1Index"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *A1Index = (NSString *)object; return A1Index; } } - (void)setA1Index:(NSString *)A1Index { [RQ_COMMON_MANAGER saveObjectWithObject:A1Index ForKey:@"A1Index"]; } - (NSString *)A2Index { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"A2Index"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *A2Index = (NSString *)object; return A2Index; } } - (void)setA2Index:(NSString *)A2Index { [RQ_COMMON_MANAGER saveObjectWithObject:A2Index ForKey:@"A2Index"]; } - (NSString *)dangerIndex { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"dangerIndex"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *dangerIndex = (NSString *)object; return dangerIndex; } } - (void)setDangerIndex:(NSString *)dangerIndex { [RQ_COMMON_MANAGER saveObjectWithObject:dangerIndex ForKey:@"dangerIndex"]; } - (NSString *)texiIndex { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"texiIndex"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *texiIndex = (NSString *)object; return texiIndex; } } - (void)setTexiIndex:(NSString *)texiIndex { [RQ_COMMON_MANAGER saveObjectWithObject:texiIndex ForKey:@"texiIndex"]; } - (NSString *)wycIndex { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"wycIndex"]; if (RQObjectIsNil(object)) { return @""; } else { NSString *wycIndex = (NSString *)object; return wycIndex; } } - (void)setWycIndex:(NSString *)wycIndex { [RQ_COMMON_MANAGER saveObjectWithObject:wycIndex ForKey:@"wycIndex"]; } - (NSString *)isZhiGeZheng { id object = [RQ_COMMON_MANAGER getObjectWithKey:@"isZhiGeZheng"]; if (RQObjectIsNil(object)) { return @"NO"; } else { NSString *isZhiGeZheng = (NSString *)object; return isZhiGeZheng; } } - (void)setIsZhiGeZheng:(NSString *)isZhiGeZheng { [RQ_COMMON_MANAGER saveObjectWithObject:isZhiGeZheng ForKey:@"isZhiGeZheng"]; } #pragma mark - PrivateMethods - (NSString *)getCarTypeNameWithCarType:(RQHomePageCarType)carType { switch (carType) { case RQHomePageCarType_Car: return @"xc"; case RQHomePageCarType_Bus: return @"kc"; case RQHomePageCarType_Truck: return @"hc"; case RQHomePageCarType_Motorcycle: return @"mtc"; case RQHomePageCarType_ZGZ_JLY: return @"zgzjl"; case RQHomePageCarType_ZGZ_KY: return @"zgzky"; case RQHomePageCarType_ZGZ_HY: return @"zgzhy"; case RQHomePageCarType_ZGZ_WXP: return @"zgzwxp"; case RQHomePageCarType_ZGZ_CZC: return @"zgzcz"; case RQHomePageCarType_ZGZ_WYC: return @"zgzwyc"; default: return @"xc"; } } - (void)rq_showDBUpdateView { @weakify(self) dispatch_async(dispatch_get_main_queue(), ^{ @strongify(self) RQUpdateView *dbUpdateView = [RQUpdateView updateView]; dbUpdateView.questionUpdateViewType = RQQuestionUpdateViewType_LibDownload; dbUpdateView.downloadUrl = self.downloadUrl; QMUIModalPresentationViewController *dbModalViewController = [[QMUIModalPresentationViewController alloc] init]; dbModalViewController.contentView = dbUpdateView; dbModalViewController.contentViewMargins = UIEdgeInsetsMake(0, 0, 0, 0); dbModalViewController.modal = YES; dbUpdateView.modalViewController = dbModalViewController; [dbModalViewController showWithAnimated:YES completion:nil]; }); } - (void)rq_showJSUpdateView { @weakify(self) dispatch_async(dispatch_get_main_queue(), ^{ @strongify(self) RQUpdateView *dbUpdateView = [RQUpdateView updateView]; dbUpdateView.questionUpdateViewType = RQQuestionUpdateViewType_ExplainDownload; dbUpdateView.jsDownloadUrl = self.jsDownloadUrl; QMUIModalPresentationViewController *dbModalViewController = [[QMUIModalPresentationViewController alloc] init]; dbModalViewController.contentView = dbUpdateView; dbModalViewController.contentViewMargins = UIEdgeInsetsMake(0, 0, 0, 0); dbModalViewController.modal = YES; dbUpdateView.modalViewController = dbModalViewController; [dbModalViewController showWithAnimated:YES completion:nil]; }); } - (void)rq_showJQUpdateView { @weakify(self) dispatch_async(dispatch_get_main_queue(), ^{ @strongify(self) RQUpdateView *dbUpdateView = [RQUpdateView updateView]; dbUpdateView.questionUpdateViewType = RQQuestionUpdateViewType_ExplainDownload; dbUpdateView.jsDownloadUrl = self.jqDownloadUrl; QMUIModalPresentationViewController *dbModalViewController = [[QMUIModalPresentationViewController alloc] init]; dbModalViewController.contentView = dbUpdateView; dbModalViewController.contentViewMargins = UIEdgeInsetsMake(0, 0, 0, 0); dbModalViewController.modal = YES; dbUpdateView.modalViewController = dbModalViewController; [dbModalViewController showWithAnimated:YES completion:nil]; }); } @end