RQTestResultsViewController.m 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. //
  2. // RQTestResultsViewController.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2021/8/25.
  6. //
  7. #import "RQTestResultsViewController.h"
  8. @interface RQTestResultsViewController ()
  9. /// viewModel
  10. @property (nonatomic, readonly, strong) RQTestResultsViewModel *viewModel;
  11. @property (weak, nonatomic) IBOutlet UIView *containerView;
  12. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageViewTopToSuperView;
  13. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *repeatBtnTopToNoteLabel;
  14. @property (weak, nonatomic) IBOutlet UIImageView *headerImageView;
  15. @property (weak, nonatomic) IBOutlet UILabel *greetingsLabel;
  16. @property (weak, nonatomic) IBOutlet UILabel *scoreLabel;
  17. @property (weak, nonatomic) IBOutlet UILabel *ruleLabel;
  18. @property (weak, nonatomic) IBOutlet UILabel *useTimeLabel;
  19. @property (weak, nonatomic) IBOutlet UILabel *commentLabel;
  20. @end
  21. @implementation RQTestResultsViewController
  22. @dynamic viewModel;
  23. #pragma mark - SystemMethod
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. /// 初始化
  27. [self rq_setup];
  28. }
  29. #pragma mark - PrivateMethods
  30. /// 初始化
  31. - (void)rq_setup {
  32. /// set up ...
  33. /// 设置contentSize
  34. [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.width.mas_equalTo(RQ_SCREEN_WIDTH);
  36. make.height.mas_equalTo(RQ_SCREEN_HEIGHT);
  37. }];
  38. UIScrollView *scrollView = (UIScrollView *)self.view;
  39. scrollView.alwaysBounceVertical = YES;
  40. scrollView.showsHorizontalScrollIndicator = NO;
  41. scrollView.showsVerticalScrollIndicator = NO;
  42. /// 适配 iOS 11
  43. RQAdjustsScrollViewInsets_Never(scrollView);
  44. if (RQ_IS_IPHONE_4_OR_LESS) {
  45. _imageViewTopToSuperView.constant = RQ_APPLICATION_TOP_BAR_HEIGHT + 0.f;
  46. _repeatBtnTopToNoteLabel.constant = 0.f;
  47. } else if (RQ_IS_IPHONE_6) {
  48. _imageViewTopToSuperView.constant = RQ_APPLICATION_TOP_BAR_HEIGHT + 20.5f;
  49. _repeatBtnTopToNoteLabel.constant = 55.f;
  50. } else {
  51. _imageViewTopToSuperView.constant = RQ_APPLICATION_TOP_BAR_HEIGHT + 29.5f;
  52. _repeatBtnTopToNoteLabel.constant = 75.f;
  53. }
  54. NSInteger allCount = (self.viewModel.homePageCarType == RQHomePageCarType_Motorcycle)? 30 * 60 : 45 * 60;
  55. NSInteger count = allCount - self.viewModel.count;
  56. NSUInteger sec = count%60;
  57. NSUInteger min = count/60;
  58. NSString* sec0,*min0;
  59. sec0 = sec<10 ? @"0" : @"";
  60. min0 = min<10 ? @"0" : @"";
  61. if (self.viewModel.score >=90 ) {
  62. _headerImageView.image = RQImageNamed(@"passTheExam");
  63. _greetingsLabel.text = @"恭喜你,测试通过~";
  64. _scoreLabel.text = [NSString stringWithFormat:@"%ld",self.viewModel.score];
  65. _useTimeLabel.text = [NSString stringWithFormat:@"用时:%@%lu分%@%lu秒",min0,(unsigned long)min,sec0,(unsigned long)sec];
  66. _commentLabel.text = @"天赋异禀、骨骼惊奇,想来是百年难得一见的考试奇才。";
  67. } else {
  68. _headerImageView.image = RQImageNamed(@"failedTheExam");
  69. _greetingsLabel.text = @"抱歉,测试未通过~";
  70. _scoreLabel.text = [NSString stringWithFormat:@"%ld",self.viewModel.score];
  71. _useTimeLabel.text = [NSString stringWithFormat:@"用时:%@%lu分%@%lu秒",min0,(unsigned long)min,sec0,(unsigned long)sec];
  72. _commentLabel.text = @"学车之路,任重而道远!路漫漫其修远兮,吾将上下而求索。";
  73. }
  74. [[RQ_HTTP_Service queryAddScoreRecordWithScore:_scoreLabel.text subject:self.viewModel.homePageSubjectType carType:self.viewModel.homePageCarType] subscribeNext:^(id _Nullable x) {
  75. }];
  76. [self.navigationItem setLeftBarButtonItems:@[[UIBarButtonItem rq_backItemWithTitle:@"" imageName:@"back_black" target:self action:@selector(rq_back)]]];
  77. }
  78. - (void)rq_back {
  79. [self.navigationController popToRootViewControllerAnimated:YES];
  80. }
  81. - (IBAction)redoWrongQuestionBtnAction:(id)sender {
  82. [RQ_SDJK_DB_MANAGER queryWrongModelQuestionIdArrWithCarType:self.viewModel.homePageCarType subjectType:self.viewModel.homePageSubjectType complete:^(NSArray *questionIdArr) {
  83. [RQ_QUESTION_DB_MANAGER getQuestionsWithQuestionIdArr:questionIdArr complete:^(NSArray *modelArray) {
  84. RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:self.viewModel.services params:@{
  85. RQHomePageCarTypeKey : @(self.viewModel.homePageCarType),
  86. RQHomePageSubjectTypeKey : @(self.viewModel.homePageSubjectType),
  87. RQHomeSubPageTypeKey : @(self.viewModel.homeSubPageType),
  88. RQExerciseTypeKey : @(RQExerciseType_Exam),
  89. RQViewModelIDKey : @"错题重做",
  90. RQViewModelUtilKey : modelArray,
  91. }];
  92. dispatch_async_on_main_queue(^{
  93. [self.viewModel.services pushViewModel:exerciseViewModel animated:YES];
  94. });
  95. }];
  96. }];
  97. // RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  98. // RQHomePageCarTypeKey : @(self.viewModel.homePageCarType),
  99. // RQHomePageSubjectTypeKey : @(self.viewModel.homePageSubjectType),
  100. // RQHomeSubPageTypeKey : @(self.viewModel.homeSubPageType),
  101. // RQExerciseTypeKey : @(RQExerciseType_Exam),
  102. // RQViewModelUtilKey : self.viewModel.questionArray,
  103. // }];
  104. // [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  105. }
  106. - (IBAction)retestBtnAction:(id)sender {
  107. RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  108. RQHomePageCarTypeKey : @(self.viewModel.homePageCarType),
  109. RQHomePageSubjectTypeKey : @(self.viewModel.homePageSubjectType),
  110. RQHomeSubPageTypeKey : @(self.viewModel.homeSubPageType),
  111. RQExerciseTypeKey : @(RQExerciseType_Exam),
  112. RQViewModelUtilKey : self.viewModel.questionArray,
  113. }];
  114. [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  115. }
  116. @end