浏览代码

新增 做题记录,并优化做题界面。

openlockPPP 1 年之前
父节点
当前提交
39d40c25b7

+ 6 - 0
jiaPei.xcodeproj/project.pbxproj

@@ -110,6 +110,7 @@
 		90798B122A53E87800E68461 /* NYComplaintListViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 90798B112A53E87800E68461 /* NYComplaintListViewModel.m */; };
 		908E6E642A89CCFC0090F00A /* DrCityInfoThree.json in Resources */ = {isa = PBXBuildFile; fileRef = 908E6E632A89CCFC0090F00A /* DrCityInfoThree.json */; };
 		908E6E662A8A08E40090F00A /* cities.json in Resources */ = {isa = PBXBuildFile; fileRef = 908E6E652A8A08E40090F00A /* cities.json */; };
+		90958FA02BAD65BA009BAA71 /* NYTools.m in Sources */ = {isa = PBXBuildFile; fileRef = 90958F9F2BAD65BA009BAA71 /* NYTools.m */; };
 		90A2ACEB2AE7C57000FA6E20 /* RQHTTPService+NYAppleUserInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 90A2ACEA2AE7C57000FA6E20 /* RQHTTPService+NYAppleUserInfo.m */; };
 		90AC53AB2A935EF90073D90F /* NYTestingCentreCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 90AC53A92A935EF90073D90F /* NYTestingCentreCell.m */; };
 		90AC53AC2A935EF90073D90F /* NYTestingCentreCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 90AC53AA2A935EF90073D90F /* NYTestingCentreCell.xib */; };
@@ -1856,6 +1857,8 @@
 		90798B112A53E87800E68461 /* NYComplaintListViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NYComplaintListViewModel.m; sourceTree = "<group>"; };
 		908E6E632A89CCFC0090F00A /* DrCityInfoThree.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = DrCityInfoThree.json; sourceTree = "<group>"; };
 		908E6E652A8A08E40090F00A /* cities.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = cities.json; sourceTree = "<group>"; };
+		90958F9E2BAD65BA009BAA71 /* NYTools.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NYTools.h; sourceTree = "<group>"; };
+		90958F9F2BAD65BA009BAA71 /* NYTools.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NYTools.m; sourceTree = "<group>"; };
 		90A2ACE92AE7C57000FA6E20 /* RQHTTPService+NYAppleUserInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RQHTTPService+NYAppleUserInfo.h"; sourceTree = "<group>"; };
 		90A2ACEA2AE7C57000FA6E20 /* RQHTTPService+NYAppleUserInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RQHTTPService+NYAppleUserInfo.m"; sourceTree = "<group>"; };
 		90AC53A82A935EF90073D90F /* NYTestingCentreCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NYTestingCentreCell.h; sourceTree = "<group>"; };
@@ -6132,6 +6135,8 @@
 			children = (
 				D0295E9C243F1B2300B46AB1 /* Tools.h */,
 				D0295E9D243F1B2300B46AB1 /* Tools.mm */,
+				90958F9E2BAD65BA009BAA71 /* NYTools.h */,
+				90958F9F2BAD65BA009BAA71 /* NYTools.m */,
 			);
 			path = Tools;
 			sourceTree = "<group>";
@@ -11304,6 +11309,7 @@
 				D04DF7AE27006F72006E3633 /* SAMKeychain+RQUtil.m in Sources */,
 				D0870D722701A6B9004EC94E /* UIImagePickerController+BlocksKit.m in Sources */,
 				D04DF6C627006C57006E3633 /* RQCommonCollectionItemViewModel.m in Sources */,
+				90958FA02BAD65BA009BAA71 /* NYTools.m in Sources */,
 				D056D3BC28B749A90003F024 /* RQHTTPService+RQSaveBetchFavQuestion.m in Sources */,
 				D001AF1525A842DD00921EF2 /* FMDBMigrationManager.m in Sources */,
 				D0295ECB243F1EC800B46AB1 /* WXUtil.mm in Sources */,

二进制
jiaPei.xcworkspace/xcuserdata/mimasigeling.xcuserdatad/UserInterfaceState.xcuserstate


+ 31 - 23
jiaPei/Modules/OtherModules/ExerciseModule/Controller/RQExerciseSubViewController.m

@@ -40,7 +40,17 @@
     [super viewDidLoad];
     /// 初始化
     [self rq_setup];
-    
+    @weakify(self)
+    dispatch_async(dispatch_get_main_queue(), ^{
+        CGFloat height = RQ_SCREEN_HEIGHT - (RQ_APPLICATION_NAV_BAR_HEIGHT + RQ_APPLICATION_STATUS_BAR_HEIGHT) - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT - RQ_FIT_HORIZONTAL(50.f);
+        self.pagerView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, height);
+        [self.exerciseToolBarView mas_makeConstraints:^(MASConstraintMaker *make) {
+            @strongify(self)
+            make.centerX.mas_equalTo(self.view);
+            make.bottom.mas_equalTo(self.view.mas_bottom).mas_offset(0);
+            make.size.mas_equalTo(CGSizeMake(RQ_SCREEN_WIDTH, RQ_FIT_HORIZONTAL(50.f)));
+        }];
+    });
 }
 
 - (void)viewWillDisappear:(BOOL)animated {
@@ -52,15 +62,7 @@
 
 - (void)viewWillLayoutSubviews {
     [super viewWillLayoutSubviews];
-    @weakify(self)
-    CGFloat height = RQ_SCREEN_HEIGHT - (RQ_APPLICATION_NAV_BAR_HEIGHT + RQ_APPLICATION_STATUS_BAR_HEIGHT) - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT - RQ_FIT_HORIZONTAL(50.f);
-    self.pagerView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, height);
-    [_exerciseToolBarView mas_makeConstraints:^(MASConstraintMaker *make) {
-        @strongify(self)
-        make.centerX.mas_equalTo(self.view);
-        make.bottom.mas_equalTo(self.view.mas_bottom).mas_offset(0);
-        make.size.mas_equalTo(CGSizeMake(RQ_SCREEN_WIDTH, RQ_FIT_HORIZONTAL(50.f)));
-    }];    
+    
 }
 
 - (void)dealloc {
@@ -112,15 +114,19 @@
                 self.exerciseToolBarView.collectBtn.selected = [RQ_YDT_USER_Question_Module getCollectRecordWithQuestionId:exerciseModel.ydtQuestionModel.ID carType:RQ_YDTQuestion_Module.carType subject:RQ_YDTQuestion_Module.subject];
             }
         }
+        if(RQ_Exercise_Module.errorArr.count)
+            self.exerciseToolBarView.errorOptionNumLabel.text = (RQ_Exercise_Module.currentExerciseType == RQExerciseType_Recitation)? @"0" : [NSString qmui_stringWithNSInteger:RQ_Exercise_Module.errorArr.count];//错题
+        if(RQ_Exercise_Module.correctArr.count)
+            self.exerciseToolBarView.correctOptionNumLabel.text = (RQ_Exercise_Module.currentExerciseType == RQExerciseType_Recitation)? @"0" : [NSString qmui_stringWithNSInteger:RQ_Exercise_Module.correctArr.count];//对题
     }];
     
-    RAC(self.exerciseToolBarView.errorOptionNumLabel, text) = [RACObserve(RQ_Exercise_Module, errorArr) map:^id _Nullable(id  _Nullable value) {
-        return (RQ_Exercise_Module.currentExerciseType == RQExerciseType_Recitation)? @"0" : [NSString qmui_stringWithNSInteger:RQ_Exercise_Module.errorArr.count];
-    }];
-    
-    RAC(self.exerciseToolBarView.correctOptionNumLabel, text) = [RACObserve(RQ_Exercise_Module, correctArr) map:^id _Nullable(id  _Nullable value) {
-        return (RQ_Exercise_Module.currentExerciseType == RQExerciseType_Recitation)? @"0" : [NSString qmui_stringWithNSInteger:RQ_Exercise_Module.correctArr.count];
-    }];
+//    RAC(self.exerciseToolBarView.errorOptionNumLabel, text) = [RACObserve(RQ_Exercise_Module, errorArr) map:^id _Nullable(id  _Nullable value) {
+//        return (RQ_Exercise_Module.currentExerciseType == RQExerciseType_Recitation)? @"0" : [NSString qmui_stringWithNSInteger:RQ_Exercise_Module.errorArr.count];
+//    }];
+//    
+//    RAC(self.exerciseToolBarView.correctOptionNumLabel, text) = [RACObserve(RQ_Exercise_Module, correctArr) map:^id _Nullable(id  _Nullable value) {
+//        return (RQ_Exercise_Module.currentExerciseType == RQExerciseType_Recitation)? @"0" : [NSString qmui_stringWithNSInteger:RQ_Exercise_Module.correctArr.count];
+//    }];
     
 //    [[[[RQNotificationCenter rac_addObserverForName:RQExerciseAlertNotification object:nil] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNotification * note) {
 //        @strongify(self)
@@ -183,12 +189,14 @@
 
 
 - (void)jumpQuestionWithIndex:(NSUInteger)index {
-    self.number = (int)index;
-    self.pagerView.defaultSelectedIndex = index;
-    self.categoryView.defaultSelectedIndex = index;
-    [self.pagerView reloadData];
-    [self.categoryView reloadData];
-    [self saveNumWithIndex:index];
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        self.number = (int)index;
+        self.pagerView.defaultSelectedIndex = index;
+        self.categoryView.defaultSelectedIndex = index;
+        [self.pagerView reloadData];
+        [self.categoryView reloadData];
+        [self saveNumWithIndex:index];
+    });
 }
 
 

+ 16 - 16
jiaPei/Modules/OtherModules/ExerciseModule/View/ExercisePage/RQExerciseToolBarView.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -34,6 +34,9 @@
                         </button>
                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3Kt-BT-JZi" customClass="QMUIButton">
                             <rect key="frame" x="71" y="1.5" width="22" height="20"/>
+                            <constraints>
+                                <constraint firstAttribute="width" secondItem="3Kt-BT-JZi" secondAttribute="height" multiplier="22/20.29" id="x1f-0W-bwV"/>
+                            </constraints>
                             <fontDescription key="fontDescription" type="system" pointSize="13"/>
                             <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
                             <state key="normal" backgroundImage="收藏灰"/>
@@ -46,6 +49,9 @@
                         </button>
                         <button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ogr-7e-wu6" customClass="QMUIButton">
                             <rect key="frame" x="93" y="3.5" width="16" height="16"/>
+                            <constraints>
+                                <constraint firstAttribute="width" secondItem="ogr-7e-wu6" secondAttribute="height" id="pDm-u2-SPp"/>
+                            </constraints>
                             <fontDescription key="fontDescription" type="system" pointSize="13"/>
                             <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
                             <state key="normal" backgroundImage="清空"/>
@@ -57,16 +63,12 @@
                             </userDefinedRuntimeAttributes>
                         </button>
                     </subviews>
-                    <constraints>
-                        <constraint firstItem="ogr-7e-wu6" firstAttribute="width" secondItem="ogr-7e-wu6" secondAttribute="height" id="pDm-u2-SPp"/>
-                        <constraint firstItem="3Kt-BT-JZi" firstAttribute="width" secondItem="3Kt-BT-JZi" secondAttribute="height" multiplier="22/20.29" id="x1f-0W-bwV"/>
-                    </constraints>
                 </stackView>
                 <stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="pTx-ya-61C">
-                    <rect key="frame" x="124" y="14" width="127" height="22"/>
+                    <rect key="frame" x="148" y="14" width="79" height="22"/>
                     <subviews>
                         <stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" alignment="center" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="Zr6-fq-EF8">
-                            <rect key="frame" x="0.0" y="0.0" width="59.5" height="22"/>
+                            <rect key="frame" x="0.0" y="0.0" width="35.5" height="22"/>
                             <subviews>
                                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="对" translatesAutoresizingMaskIntoConstraints="NO" id="hMo-O6-NJO">
                                     <rect key="frame" x="0.0" y="0.0" width="22" height="22"/>
@@ -74,8 +76,8 @@
                                         <constraint firstAttribute="width" secondItem="hMo-O6-NJO" secondAttribute="height" multiplier="1:1" id="mfs-jE-qPC"/>
                                     </constraints>
                                 </imageView>
-                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2000" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="b7t-Nc-KbU">
-                                    <rect key="frame" x="27" y="4" width="32.5" height="14"/>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="b7t-Nc-KbU">
+                                    <rect key="frame" x="27" y="4" width="8.5" height="14"/>
                                     <constraints>
                                         <constraint firstAttribute="height" constant="14" id="1Bj-ae-KQG"/>
                                     </constraints>
@@ -86,16 +88,17 @@
                             </subviews>
                         </stackView>
                         <stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" alignment="center" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="pYy-Jv-8E0">
-                            <rect key="frame" x="67.5" y="0.0" width="59.5" height="22"/>
+                            <rect key="frame" x="43.5" y="0.0" width="35.5" height="22"/>
                             <subviews>
                                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="错" translatesAutoresizingMaskIntoConstraints="NO" id="fgW-nP-yMe">
                                     <rect key="frame" x="0.0" y="0.0" width="22" height="22"/>
                                     <constraints>
                                         <constraint firstAttribute="width" secondItem="fgW-nP-yMe" secondAttribute="height" multiplier="1:1" id="4HG-Y2-4md"/>
+                                        <constraint firstAttribute="width" secondItem="fgW-nP-yMe" secondAttribute="height" multiplier="1:1" id="Lso-k9-ZqJ"/>
                                     </constraints>
                                 </imageView>
-                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2000" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="t04-gv-4wI">
-                                    <rect key="frame" x="27" y="4" width="32.5" height="14"/>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="t04-gv-4wI">
+                                    <rect key="frame" x="27" y="4" width="8.5" height="14"/>
                                     <constraints>
                                         <constraint firstAttribute="height" constant="14" id="b4R-S3-m24"/>
                                     </constraints>
@@ -104,9 +107,6 @@
                                     <nil key="highlightedColor"/>
                                 </label>
                             </subviews>
-                            <constraints>
-                                <constraint firstItem="fgW-nP-yMe" firstAttribute="width" secondItem="fgW-nP-yMe" secondAttribute="height" multiplier="1:1" id="Lso-k9-ZqJ"/>
-                            </constraints>
                         </stackView>
                     </subviews>
                 </stackView>

+ 32 - 2
jiaPei/Modules/OtherModules/ExerciseModule/ViewModel/ExercisePage/RQExerciseSubViewModel.m

@@ -36,8 +36,38 @@
         self.titleStr = params[RQViewModelIDKey];
         self.number = [params[RQViewCommonValueKey] integerValue];
         self.questionArr = params[RQViewModelUtilKey];
-
-
+        //读取用户记录-赋值
+        NSArray *readList = [NYTools readExerciseListUserKey:RQ_USER_MANAGER.currentUser.outId carType:RQ_YDTQuestion_Module.carType subject:RQ_YDTQuestion_Module.subject exerciseType:RQ_Exercise_Module.currentExerciseType];
+        NSLog(@"readList=%@",readList);
+        if(readList.count>0){ //遍历用户做的题目
+            for (NSDictionary *item in readList) {
+                NSInteger ID = [item[@"ID"] unsignedIntValue];//题目id
+                NSInteger type = [item[@"type"] unsignedIntValue];//题目类型
+                NSInteger answerResultsType = [item[@"answerResultsType"] unsignedIntValue];//是否做对
+                NSArray *userAnswer = item[@"userAnswer"];//用户选项
+                //查找对应题目
+                NSArray *filteredArray = [self.questionArr filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"ydtQuestionModel.ID == %d", ID]];
+                if (filteredArray.count > 0) {
+                    RQExerciseModel *exerciseModel = filteredArray.firstObject;
+                    exerciseModel.answerResultsType = answerResultsType;
+                    exerciseModel.userAnswer = userAnswer;
+                    if (exerciseModel.answerResultsType == RQAnswerResultsType_Correct) {
+                        if (![RQ_Exercise_Module.correctArr containsObject:exerciseModel]) {
+                            NSMutableArray *corArr = RQ_Exercise_Module.correctArr.mutableCopy;
+                            [corArr addObject:exerciseModel];
+                            RQ_Exercise_Module.correctArr = corArr.copy;
+                        }
+                    } else if (exerciseModel.answerResultsType == RQAnswerResultsType_Error) {
+                        if (![RQ_Exercise_Module.errorArr containsObject:exerciseModel]) {
+                            NSMutableArray *errArr = RQ_Exercise_Module.errorArr.mutableCopy;
+                            [errArr addObject:exerciseModel];
+                            RQ_Exercise_Module.errorArr = errArr.copy;
+                        }
+                    }
+                }
+            }
+        }
+        
     }
     return self;
 }

+ 2 - 0
jiaPei/Modules/OtherModules/ExerciseModule/ViewModel/ExercisePage/itemViewModel/RQExerciseOptionItemViewModel.m

@@ -259,7 +259,9 @@
                 }
             } else {
                 self.exerciseModel.userAnswer = @[optString].mutableCopy;
+                
 //                [RQ_YDTQuestion_Module saveHistoryQuestionNumWithQuestionId:exerciseModel.ydtQuestionModel.num];
+                [NYTools saveExerciseModel:exerciseModel userKey:RQ_USER_MANAGER.currentUser.outId carType:RQ_YDTQuestion_Module.carType subject:RQ_YDTQuestion_Module.subject exerciseType:RQ_Exercise_Module.currentExerciseType];//记录用户做的题目
                 if (exerciseModel.ydtQuestionModel.AnswerTrue.integerValue == [allOptionsArr indexOfObject:optString] + 1) {
                     [RQNotificationCenter postNotificationName:RQAutoJumpNextNotification object:nil];
                     if (RQ_Exercise_Module.isRightAutoRemoveError) {

+ 1 - 1
jiaPei/Modules/OtherModules/ExerciseModule/ViewModel/ExercisePage/itemViewModel/RQExerciseOptionSureBtnItemViewModel.m

@@ -28,7 +28,7 @@
 //                    [RQNotificationCenter postNotificationName:RQAutoJumpNextNotification object:nil];
 //                    [RQNotificationCenter postNotificationName:RQCancelWrongNotification object:nil];
 //                }
-                
+                [NYTools saveExerciseModel:exerciseModel userKey:RQ_USER_MANAGER.currentUser.outId carType:RQ_YDTQuestion_Module.carType subject:RQ_YDTQuestion_Module.subject exerciseType:RQ_Exercise_Module.currentExerciseType];//记录用户做的题目
                 if (userAnswerIndexStr.integerValue == exerciseModel.ydtQuestionModel.AnswerTrue.integerValue) {
 //                    [RQ_YDTQuestion_Module saveHistoryQuestionNumWithQuestionId:exerciseModel.ydtQuestionModel.num];
                     [RQNotificationCenter postNotificationName:RQAutoJumpNextNotification object:nil];

+ 4 - 4
jiaPei/Modules/OtherModules/YDTQuestionModule/RQYDTQuestionModule.m

@@ -648,9 +648,9 @@ static id rq_ydtQuestionModule = nil;
 
 /// 做到哪一题
 - (NSInteger)getHistoryQuestionNum {
-    NSString *key = [NSString stringWithFormat:@"HistoryQuestionNum%ld-%ld-%@",self.carType,RQ_Exercise_Module.currentExerciseType,RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.loginCode)? RQ_USER_MANAGER.currentUser.loginCode : @"0"];
+    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-%@-%@",self.carType,RQ_Exercise_Module.currentExerciseType,RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.loginCode)? RQ_USER_MANAGER.currentUser.loginCode : @"0", 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];
     }
     id object = [RQ_COMMON_MANAGER getObjectWithKey:key];
     if (RQObjectIsNil(object)) {
@@ -663,9 +663,9 @@ static id rq_ydtQuestionModule = nil;
 
 - (void)saveHistoryQuestionNumWithQuestionId:(NSInteger)questionId {
     
-    NSString *key = [NSString stringWithFormat:@"HistoryQuestionNum%ld-%ld-%@",self.carType,RQ_Exercise_Module.currentExerciseType,RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.loginCode)? RQ_USER_MANAGER.currentUser.loginCode : @"0"];
+    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-%@-%@",self.carType,RQ_Exercise_Module.currentExerciseType,RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.loginCode)? RQ_USER_MANAGER.currentUser.loginCode : @"0", 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];
     }
     [RQ_SHARE_FUNCTION saveObjectWithObject:@(questionId) ForKey:key];
 }

+ 30 - 0
jiaPei/OLD/Util/Tools/NYTools.h

@@ -0,0 +1,30 @@
+//
+//  NYTools.h
+//  jiaPei
+//
+//  Created by Ning.ge on 2024/3/22.
+//  Copyright © 2024 JCZ. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+@class RQExerciseModel;
+@interface NYTools : NSObject
+
+/**
+ *记录-题目-对错
+ *userKey 用户id
+ *carType 车辆类型
+ *subject 科目几
+ *exerciseType 题目类型
+ */
++(void)saveExerciseModel:(RQExerciseModel*)exercise userKey:(NSString*)userKey carType:(RQHomePageCarType)carType subject:(RQHomePageSubjectType)subject exerciseType:(NSUInteger)exerciseType;
+//读取-题目对错
++(NSArray*)readExerciseListUserKey:(NSString*)userKey carType:(RQHomePageCarType)carType subject:(RQHomePageSubjectType)subject exerciseType:(NSUInteger)exerciseType;
+//删除-题目
++(void)delateUserKey:(NSString*)userKey;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 63 - 0
jiaPei/OLD/Util/Tools/NYTools.m

@@ -0,0 +1,63 @@
+//
+//  NYTools.m
+//  jiaPei
+//
+//  Created by Ning.ge on 2024/3/22.
+//  Copyright © 2024 JCZ. All rights reserved.
+//
+
+#import "NYTools.h"
+
+@implementation NYTools
+
+
+
+/**
+ *记录-题目-对错
+ *userKey 用户id
+ *carType 车辆类型
+ *subject 科目几
+ *exerciseType 题目类型
+ */
++(void)saveExerciseModel:(RQExerciseModel*)exercise userKey:(NSString*)userKey carType:(RQHomePageCarType)carType subject:(RQHomePageSubjectType)subject exerciseType:(NSUInteger)exerciseType{
+    NSString *NYCocheName = [NSString stringWithFormat:@"NYExercise_%@",userKey];
+    YYCache  *yyCache = [YYCache cacheWithName:NYCocheName];
+    NSString *NYCocheNameKey = [NSString stringWithFormat:@"NYExerciseKey_%zd_%zd_%zd",carType,subject,exerciseType];
+    //记录——用户做的题目-答题
+    NSArray *userAnswer = exercise.userAnswer.copy;
+    NSDictionary *exer_dic = @{
+        @"ID":@(exercise.ydtQuestionModel.ID),//题目id
+        @"type":@(exercise.ydtQuestionModel.Type),//题目类型
+        @"answerResultsType":@(exercise.answerResultsType),//是否做对
+        @"userAnswer":userAnswer,//用户选项
+    };
+    NSArray *array = [self readExerciseListUserKey:userKey carType:carType subject:subject exerciseType:exerciseType];
+    NSMutableArray *value = [NSMutableArray arrayWithArray:array];
+    [value addObject:exer_dic];
+    //根据key写入缓存value
+    [yyCache setObject:value forKey:NYCocheNameKey withBlock:^{
+      NSLog(@"setObject sucess");
+    }];
+    
+}
+//读取-题目对错
++(NSArray*)readExerciseListUserKey:(NSString*)userKey carType:(RQHomePageCarType)carType subject:(RQHomePageSubjectType)subject exerciseType:(NSUInteger)exerciseType{
+    NSString *NYCocheName = [NSString stringWithFormat:@"NYExercise_%@",userKey];
+    YYCache  *yyCache = [YYCache cacheWithName:NYCocheName];
+    NSString *NYCocheNameKey = [NSString stringWithFormat:@"NYExerciseKey_%zd_%zd_%zd",carType,subject,exerciseType];
+    id object = [yyCache objectForKey:NYCocheNameKey];
+    if ([object isKindOfClass:[NSMutableArray class]]) {
+        return (NSArray *)object;
+    } else {
+        // 返回一个空数组或者其他默认值,视情况而定
+        return @[];
+    }
+}
+//删除-题目
++(void)delateUserKey:(NSString*)userKey{
+    NSString *NYCocheName = [NSString stringWithFormat:@"NYExercise_%@",userKey];
+    YYCache  *yyCache = [YYCache cacheWithName:NYCocheName];
+    [yyCache removeAllObjects];
+}
+
+@end

+ 1 - 0
jiaPei/PrefixHeader.pch

@@ -105,6 +105,7 @@
 #import "Util.h"
 #import "jiaPeiManager.h"
 #import "Tools.h"
+#import "NYTools.h"
 
 #pragma mark - Modules
 #import "BaseModule.h"