/** 这里的数据信息可以保存在plist里面。 plist是个2维数组。 1级索引需要在代码里建立。2级索引是固定的。考试科目,考试题库,考试标准,合格标准 其中题目数可以从另外的地方取数值。 */ #import "ExamVC.h" #import "ExerciseVC.h" #import "STButton.h" @interface ExamVC () { UITableView* myTableView; NSArray* titles; NSMutableArray* details; } @end @implementation ExamVC - (void)viewDidLoad { [super viewDidLoad]; [self myInit]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } -(void)myInit { [self setTitle:RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"模拟考试" : ([defUser.car_type isEqualToString:@"2"]? @"结业考核" : @"模拟考试")]; [self configNavigationBar]; [self.view setBackgroundColor:[UIColor whiteColor]]; CGFloat x, y,hei,wid; wid = 70; hei = wid; x = (kSize.width - wid)/2.0 ; y = 0; UIImageView* iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, wid, hei)]; NSString *str = defUser.userDict[@"photo"]; if (str && ![str hasPrefix:@"http"]){ str = [imgPreFix stringByAppendingString:str]; } if (!str || str.length < 1) { str = @""; } //dansonimg [iv sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"drawer_head.png"]]; [self.view addSubview:iv]; [iv setBoardWid:1 Color:defGreen]; [iv setRound]; // hei = 110; // y=0; // headBtn = [[STButton alloc] initWithFrame:CGRectMake(0, 0, kSize.width, hei)]; // NSString *name = @"工程师"; // if (defUser.userName.length > 0) { // name = defUser.userName; // } // [headBtn setTitle:name textColor:subTitleColor font:14 fotState:UIControlStateNormal]; // [headBtn setSubTitle:@"你可以登录学员中心更新个人资料哦"]; // [self.view addSubview:headBtn]; NSString *name = @"驾考学员"; if (defUser.userName.length > 0) { name = defUser.userName; } UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(0, y+hei, kSize.width, 20)]; [lab setText:name Font:14 TextColor:contentTextColor Alignment:NSTextAlignmentCenter]; [self.view addSubview:lab]; UILabel *subLab = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(lab.frame), kSize.width, 30)]; [subLab setText:@"你可以登录学员中心更新个人资料哦" Font:14 TextColor:contentTextColor Alignment:NSTextAlignmentCenter]; if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) { } else { [self.view addSubview:subLab]; } [self loadModels]; y += hei + 50; hei = 180; wid = kSize.width * .9; x = (kSize.width - wid)/2.0; myTableView = [[UITableView alloc] initWithFrame:CGRectMake(x, y, wid, hei)]; [myTableView addSelfViewWithRect:SGRectMake(17, 0, wid - 17, .7) Color:KlineColor]; [self.view addSubview:myTableView]; [myTableView setUserInteractionEnabled:NO]; [myTableView setDataSource:self]; [myTableView setDelegate:self]; [myTableView setScrollEnabled:NO]; y += hei + 30; wid = kSize.width - x*2; hei = 50; UIButton* btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, wid, hei)]; [btn setTitle:RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"全真模拟考试" : ([defUser.car_type isEqualToString:@"2"]? @"开始考试" : @"全真模拟考试") textColor:[UIColor whiteColor] font:18 fotState:UIControlStateNormal]; [btn addTarget:self action:@selector(beginExam) forControlEvents:UIControlEventTouchUpInside]; btn.layer.cornerRadius = 20; [btn setBackgroundColor:defGreen]; [self.view addSubview:btn]; } -(void)loadModels { titles = [NSMutableArray array]; details = [NSMutableArray array]; NSString * examSubject = @"科目一理论考试"; if (myDelegate.subject.intValue == 4) { examSubject = @"科目四理论考试"; } if ([defUser.car_type isEqualToString:@"1"] || [defUser.car_type isEqualToString:@"2"] || [defUser.car_type isEqualToString:@"3"] || [defUser.car_type isEqualToString:@"4"] || [defUser.car_type isEqualToString:@"5"] || [defUser.car_type isEqualToString:@"6"]) { examSubject = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"资格证考试" : ([defUser.car_type isEqualToString:@"2"]? @"结业考核" : @"资格证考试"); } [details addObject:examSubject]; titles = @[@"考试科目",@"考试题库",@"考试标准",@"合格标准"]; NSArray *carType = @[@"小车 (C1,C2,C3)",@"货车(A2/B2)",@"客车(A1/A3/B1)",@"摩托(D/E/F)",@"教练员",@"客运",@"货运",@"危险品",@"出租车",@"网约车"]; // if([defUser.car_type isEqualToString:@"C1"]) { // [details addObject:carType[0]]; // if (myDelegate.subject.intValue == 1) { // [details addObject:@"100题,45分钟"]; // [details addObject:@"满分100分,90分及格"]; // }else { // [details addObject:@"50题,45分钟"]; // [details addObject:@"满分100分,90分及格"]; // } // }else if ([defUser.car_type isEqualToString:@"A2"]) { // [details addObject:carType[1]]; // if (myDelegate.subject.intValue == 1) { // [details addObject:@"100题,45分钟"]; // [details addObject:@"满分100分,90分及格"]; // }else { // [details addObject:@"50题,30分钟"]; // [details addObject:@"满分100分,90分及格"]; // } // }else if ([defUser.car_type isEqualToString:@"A1"]) { // [details addObject:carType[2]]; // if (myDelegate.subject.intValue == 1) { // [details addObject:@"100题,45分钟"]; // [details addObject:@"满分100分,90分及格"]; // }else { // [details addObject:@"50题,30分钟"]; // [details addObject:@"满分100分,90分及格"]; // } // }else if ([defUser.car_type isEqualToString:@"D"]) { // [details addObject:carType[3]]; // [details addObject:@"50题,30分钟"]; // [details addObject:@"满分100分,90分及格"]; // }else if ([defUser.car_type isEqualToString:@"4"]) { // [details addObject:carType[4]]; // [details addObject:@"100题,60分钟"]; // [details addObject:@"满分100分,80分及格"]; // }else if ([defUser.car_type isEqualToString:@"1"]) { // [details addObject:carType[5]]; // [details addObject:@"90题,60分钟"]; // [details addObject:@"满分100分,80分及格"]; // }else if ([defUser.car_type isEqualToString:@"2"]) { // [details addObject:carType[6]]; //// [details addObject:@"90题,90分钟"]; //// [details addObject:@"满分100分,80分及格"]; // [details addObject:@"50题"]; // [details addObject:@"满分100分,80分及格"]; // }else if ([defUser.car_type isEqualToString:@"3"]) { // [details addObject:carType[7]]; // [details addObject:@"100题,90分钟"]; // [details addObject:@"满分100分,90分及格"]; // }else { // [details addObject:carType[8]]; // [details addObject:@"90题,45分钟"]; // [details addObject:@"满分100分,80分及格"]; // } if ([defUser.car_type isEqualToString:@"C1"]) { [details addObject:carType[0]]; } else if ([defUser.car_type isEqualToString:@"A2"]) { [details addObject:carType[1]]; } else if ([defUser.car_type isEqualToString:@"A1"]) { [details addObject:carType[2]]; } else if ([defUser.car_type isEqualToString:@"D"]) { //如果摩托车库的内容有了 可以在这里将DEF改为数据库中的参数 [details addObject:carType[3]]; } else if ([defUser.car_type isEqualToString:@"4"]) { [details addObject:carType[4]]; } else if ([defUser.car_type isEqualToString:@"1"]) { [details addObject:carType[5]]; } else if ([defUser.car_type isEqualToString:@"2"]) { [details addObject:carType[6]]; } else if ([defUser.car_type isEqualToString:@"3"]) { [details addObject:carType[7]]; } else if ([defUser.car_type isEqualToString:@"6"]) { [details addObject:carType[9]]; } else { [details addObject:carType[8]]; } if ([defUser.car_type isEqualToString:@"D"]) { [details addObject:[NSString stringWithFormat:@"50题,30分钟"]]; } else { if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) { NSInteger count = [RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Exam].count; [details addObject:[NSString stringWithFormat:@"%@题,45分钟",count > 0? [NSNumber numberWithInteger:count] : (myDelegate.subject.intValue == 4?@"50":@"100")]]; } else { if ([defUser.car_type isEqualToString:@"2"]) { [details addObject:@"50题"]; } else { NSInteger count = [RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Exam].count; [details addObject:[NSString stringWithFormat:@"%@题,45分钟",count > 0? [NSNumber numberWithInteger:count] : (myDelegate.subject.intValue == 4?@"50":@"100")]]; } } } if ([defUser.car_type isEqualToString:@"1"] || [defUser.car_type isEqualToString:@"2"] || [defUser.car_type isEqualToString:@"3"] || [defUser.car_type isEqualToString:@"4"] || [defUser.car_type isEqualToString:@"5"] || [defUser.car_type isEqualToString:@"6"]) { [details addObject:[NSString stringWithFormat:@"满分100分,80分及格"]]; }else{ [details addObject:[NSString stringWithFormat:@"满分100分,90分及格"]]; } NSLog(@"details-----><>%@",details); } #pragma mark - -(void)beginExam { NSString* msg; NSString *string = [details lastObject]; int totalMark = [[string substringWithRange:NSMakeRange(2, 3)] intValue]; int passMark = [[string substringWithRange:NSMakeRange(7, 2)] intValue]; if (myDelegate.subject.intValue == 1 || myDelegate.subject.intValue == 4) { msg = [NSString stringWithFormat:@"按最新交规考试要求,科目%@考试答题后不能修改答案,每做一题,系统自动计算错题,当累计错题分数超过%d分时(共100分),系统会自动提交答卷,本次考试不通过。",myDelegate.subject.intValue == 1 ? @"一":@"四",(totalMark - passMark)]; } if ([defUser.car_type isEqualToString:@"1"] || [defUser.car_type isEqualToString:@"3"] || [defUser.car_type isEqualToString:@"4"] || [defUser.car_type isEqualToString:@"5"] || [defUser.car_type isEqualToString:@"6"]) { msg = [NSString stringWithFormat:@"按最新交规考试要求,资格证考试答题后不能修改答案,每做一题,系统自动计算错题,当累计错题分数超过%d分时(共100分),系统会自动提交答卷,本次考试不通过。",(totalMark - passMark)]; } if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) { } else { if ([defUser.car_type isEqualToString:@"2"]) { msg = [NSString stringWithFormat:@"按最新交规考试要求,结业考核答题后不能修改答案,每做一题,系统自动计算错题,当累计错题分数超过%d分时(共100分),本次考试不通过。",(totalMark - passMark)]; } } NSLog(@"subject-------><>%@-------car_type-----><>%@--------msg------><>%@",myDelegate.subject,defUser.car_type,msg); UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:msg delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil]; [alert show]; } -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ // NSString *titleString = alertView.title; // int loseMark = [[[[titleString componentsSeparatedByString:@"如果累计错题分数超过"] lastObject] substringToIndex:2] intValue]; NSString *string = [details lastObject]; int totalMark = [[string substringWithRange:NSMakeRange(2, 3)] intValue]; int passMark = [[string substringWithRange:NSMakeRange(7, 2)] intValue]; string = details[details.count - 2]; int testTime = [[[[string componentsSeparatedByString:@","] lastObject] substringToIndex:2] intValue]; ExerciseVC *vc = [[ExerciseVC alloc] init]; vc.testTime = testTime; vc.loseMark = totalMark - passMark; [self navPushHideTabbarToVC:vc]; } #pragma mark - - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 4; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell* cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"examCell"]; [cell.textLabel setTextColor:contentTextColor]; [cell.detailTextLabel setTextColor:kTitleColor]; [cell.textLabel setText:titles[indexPath.row]]; if (details.count == 4) { [cell.detailTextLabel setText:details[indexPath.row]]; } return cell; } @end