123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666 |
- //
- // JXQuestionnnnVc.m
- // shiku_im
- //
- // Created by os on 2020/7/2.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JXQuestionnnnVc.h"
- #import "JXQuestionCell.h"
- #import "JXApplyViewController.h"
- @interface JXQuestionnnnVc ()<UIAlertViewDelegate,UITableViewDelegate,UITableViewDataSource>
- @property(strong,nonatomic)UIView * navigationView;
- @property(strong,nonatomic)UIView * alertViews;
- @property(strong,nonatomic)UILabel * alertLabel;
- @property(strong,nonatomic)UILabel * countLabel;
- @property(strong,nonatomic)UIButton * backButton;
- @property(strong,nonatomic)UILabel * questionLabel;
- @property(strong,nonatomic)UILabel * questionTitle;
- @property(strong,nonatomic)UITableView * questionTable;
- @property(strong,nonatomic)UIScrollView * scrollView;
- @property(strong,nonatomic)NSArray * questionArray;
- @property(assign,nonatomic)NSUInteger currentSort;
- @property(strong,nonatomic)NSDictionary * currentQuestion;
- @property(strong,nonatomic)NSTimer * timer;
- @property(assign,nonatomic)int count;
- @property(strong,nonatomic)UIButton * nextButton;
- @property (nonatomic,copy) NSString *Id_str;
- @property (nonatomic,assign) NSInteger indexRightRow;
- @property (nonatomic,strong) NSMutableArray *dataArr;
- @property (nonatomic,strong) NSMutableArray *firstArr;
- @property (nonatomic,strong) NSMutableArray *questionArr;
- @property (nonatomic,strong) NSMutableArray *ruleArr;
- @property (nonatomic,assign) NSInteger indexRecordIndex;
- @property (nonatomic,assign) NSInteger indexRow;
- @property (nonatomic,strong) NSMutableArray *saveSelectIndexArr;
- @property (nonatomic,strong) NSMutableDictionary *saveSelectIndexDict;
- @property (nonatomic,weak) UIAlertView * aler;
- @property (nonatomic,strong) NSMutableArray *dataArr222;
- @property (nonatomic,strong) NSMutableArray *dataArr333;
- @end
- @implementation JXQuestionnnnVc
-
- - (void)viewDidLoad {
- [super viewDidLoad];
- _currentQuestion=[NSDictionary dictionary];
- _indexRightRow=100;
- _indexRow=200;
-
- _isAnsware=YES;
- //保存选中的数据
- _saveSelectIndexArr=[NSMutableArray array];
- _saveSelectIndexDict=[NSMutableDictionary dictionary];
- _firstArr=[NSMutableArray array];
- _dataArr222=[NSMutableArray array];
-
- _dataArr333=[NSMutableArray array];
-
- //_errorArray=[NSMutableArray arrayWithCapacity:0];
-
- _dataArr=[NSMutableArray array];
- _questionArr=[NSMutableArray array];
- _ruleArr=[NSMutableArray array];
- self.view.backgroundColor = [UIColor colorWithRed:126/255.0f green:23/255.0f blue:21/255.0f alpha:1.0f];
- self.tableView.alpha = 0.0f;
- self.currentSort = 0;
- [self initNavigationView];
- [self initComponents];
- [SVProgressHUD show];
- self.count = 5;
- long time = (long)[[NSDate date] timeIntervalSince1970];
- time = (time *1000 + g_server.timeDifference);
- NSString *salt = [NSString stringWithFormat:@"%ld", time];
-
- [g_server getAllQuestions:salt andToView:self];
-
- self.questionTitle.text = [NSString stringWithFormat:@"%d",1];
-
- }
- #pragma mark --- 提交
- -(void)postButtonClicked:(UIButton *)sender
- {
-
- if (_dataArr333.count==10) {
-
- [SVProgressHUD setMaximumDismissTimeInterval:2];
- [SVProgressHUD showErrorWithStatus:@"已经完成所有答题"];
-
- NSMutableArray * mutableArray = [[NSMutableArray alloc]initWithCapacity:0];
- [_dataArr333 enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-
- QustionJX *optionModel=obj[@"option"];
- NSString *Id_str=obj[@"Id_str"];
-
- NSDictionary * dictionary = @{@"questionId":[NSString stringWithFormat:@"%@",optionModel.id],@"optionId":Id_str};
- [mutableArray addObject:dictionary];
-
- }];
-
- long time = (long)[[NSDate date] timeIntervalSince1970];
- time = (time *1000 + g_server.timeDifference);
- NSString *salt = [NSString stringWithFormat:@"%ld", time];
-
- NSArray * postArray = mutableArray.copy;
-
- NSError *parseError = nil;
-
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postArray options:NSJSONWritingPrettyPrinted error:&parseError];
-
- NSString *jsonstr =[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
-
-
-
- [SVProgressHUD show];
- [g_server postQuestionAnswers:salt andOptions:jsonstr andToView:self];
-
- }else{
-
- UIAlertView * aler = [[UIAlertView alloc]initWithTitle:@"提示" message:[NSString stringWithFormat:@"您有题目没有答完,请返回检查"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
- [aler show];
- self.aler=aler;
-
- }
-
- if([self.ifAnswer isEqualToString:@"NO"])
- {
- [SVProgressHUD setMaximumDismissTimeInterval:2];
- [SVProgressHUD showErrorWithStatus:@"已经完成所有答题"];
- }
- else
- {
- NSMutableArray * mutableArray = [[NSMutableArray alloc]initWithCapacity:0];
- for(NSDictionary * dict in _questionArray)
- {
- NSString * lastAnswer = [NSString stringWithFormat:@"%@",[dict objectForKey:@"answerid"]];
- if(lastAnswer != nil && lastAnswer.length != 0 && ![lastAnswer isEqualToString:@"(null)"] && ![lastAnswer isEqualToString:@"<null>"])
- {
-
-
- NSDictionary * dictionary = [[NSDictionary alloc]initWithObjectsAndKeys:[NSString stringWithFormat:@"%@",[dict objectForKey:@"id"]],@"questionId",lastAnswer,@"optionId", nil];
- [mutableArray addObject:dictionary];
-
- long time = (long)[[NSDate date] timeIntervalSince1970];
- time = (time *1000 + g_server.timeDifference);
- NSString *salt = [NSString stringWithFormat:@"%ld", time];
-
- NSArray * postArray = mutableArray.copy;
-
- NSError *parseError = nil;
-
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postArray options:NSJSONWritingPrettyPrinted error:&parseError];
-
- NSString *jsonstr =[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
-
-
-
- [SVProgressHUD show];
- [g_server postQuestionAnswers:salt andOptions:jsonstr andToView:self];
-
- }
- else
- {
- UIAlertView * aler = [[UIAlertView alloc]initWithTitle:@"提示" message:[NSString stringWithFormat:@"您有题目没有答完,请返回检查"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
- [aler show];
- self.aler=aler;
- break;
- }
- }
-
-
- }
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return _dataArr.count;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
-
- if (_firstArr.count==0) {
-
-
- return 0;
- }else{
-
- QustionJX *optionArr = _firstArr[section];
-
-
- return optionArr.options.count;
- }
- }
- #pragma mark --- 代理 tableView
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- { //NSArray * options = [_currentQuestion objectForKey:@"options"];
- JXQuestionCell * cell = [JXQuestionCell cellWithTableView:tableView];
-
- QustionJX *optionArr = [_firstArr firstObject];
-
- OptionsJX *model=optionArr.options[indexPath.row];
-
-
- [cell createUI:model andDui:_indexRightRow andSelect:_indexRow andCell:indexPath.row];
-
-
- return cell;
- }
-
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return 54.0f;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- _isAnsware=NO;
- QustionJX *optionArr = [_firstArr firstObject];
- __block OptionsJX *model=nil;
- _indexRow=indexPath.row;
- [optionArr.options enumerateObjectsUsingBlock:^(OptionsJX *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- if ( [obj.right isEqualToString:@"1"]) {
- _indexRightRow=idx;
- _Id_str=obj.sort;
- model=obj;
- }if ( [obj.right isEqualToString:@"1"] && indexPath.row==idx) {
-
- [_dataArr222 addObject:model];
- }
- }];
- __block QustionJX *modelS=nil;
- [_questionArr enumerateObjectsUsingBlock:^(QustionJX * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- // if ([obj.sort intValue]==_currentSort) {
- if ([obj.title isEqualToString:self.questionLabel.text]) {
- modelS=obj;
- }
- }];
- if (_isclick==YES) {
-
- return;
- }
-
- _currentSort ++;
- _isclick=YES;
- _isCheck=1;
-
- NSDictionary *dict=@{@"option":modelS,@"title":modelS.title,@"selectIndex":[NSString stringWithFormat:@"%zd",indexPath.row] ,@"rightRow":[NSString stringWithFormat:@"%zd",_indexRightRow],@"checkNo":[NSString stringWithFormat:@"%d",_isCheck],@"currentSort":[NSString stringWithFormat:@"%lu",(unsigned long)_currentSort],@"Id_str":[NSString stringWithFormat:@"%zd",indexPath.row+1]};
- [_saveSelectIndexArr addObject:dict];
-
- if (_saveSelectIndexArr.count==10) {
- //提交答卷
- [_nextButton setImage:[UIImage imageNamed:@"提交答卷"] forState:UIControlStateNormal];
- }
- [_dataArr333 addObject:dict];
-
-
- [_questionTable reloadData];
- }
- -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
-
-
- [SVProgressHUD dismiss];
- if([aDownload.action isEqualToString:act_GetQuestionAndRules])
- {
-
- NSDictionary * dict0 = [array1 objectAtIndex:0];
- NSLog(@"aaa %@",dict0);
- _questionArr=[QustionJX mj_objectArrayWithKeyValuesArray:dict0[@"questions"]];
- _ruleArr=[RulesJX mj_objectArrayWithKeyValuesArray:dict0[@"rules"]];
- [_firstArr addObject:[_questionArr firstObject]];
- /* [_questionArr enumerateObjectsUsingBlock:^(QustionJX * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-
- if (idx==0) {
- [_firstArr addObject:obj];
- }
- }];*/
-
- _dataArr=[packageRoolModel mj_objectArrayWithKeyValuesArray:array1];
- QustionJX *modell=[_firstArr firstObject];
- self.questionLabel.text = modell.title;
- [self.questionTable reloadData];
-
-
- [[NSNotificationCenter defaultCenter]postNotificationName:@"refreshes" object:nil];
- }if([aDownload.action isEqualToString:act_PostQuestionAnswers])
- {
- UIAlertView * aler = [[UIAlertView alloc]initWithTitle:@"提示" message:[NSString stringWithFormat:@"本次答题:正确:%zd道题,错误 %zd道题",_dataArr222.count,_dataArr333.count-_dataArr222.count] delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil];
- aler.tag=3000;
- [aler show];
- }
-
-
- }
- -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
-
- NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]];
- if([errorCode isEqualToString:@"权限验证失败"])
- {
- if([aDownload.action isEqualToString:act_GetQuestionAndRules])
- {
- long time = (long)[[NSDate date] timeIntervalSince1970];
- time = (time *1000 + g_server.timeDifference);
- NSString *salt = [NSString stringWithFormat:@"%ld", time];
-
- [g_server getAllQuestions:salt andToView:self];
- }
- if([aDownload.action isEqualToString:act_PostQuestionAnswers])
- {
- if([self.ifAnswer isEqualToString:@"NO"])
- {
- [SVProgressHUD setMaximumDismissTimeInterval:2];
- [SVProgressHUD showErrorWithStatus:@"已经完成所有答题"];
- }
- else
- {
- NSMutableArray * mutableArray = [[NSMutableArray alloc]initWithCapacity:0];
- for(NSDictionary * dict in self.questionArray)
- {
- NSString * lastAnswer = [NSString stringWithFormat:@"%@",[dict objectForKey:@"answerid"]];
- if(lastAnswer != nil && lastAnswer.length != 0 && ![lastAnswer isEqualToString:@"(null)"] && ![lastAnswer isEqualToString:@"<null>"])
- {
- NSDictionary * dictionary = [[NSDictionary alloc]initWithObjectsAndKeys:[NSString stringWithFormat:@"%@",[dict objectForKey:@"id"]],@"questionId",lastAnswer,@"optionId", nil];
- [mutableArray addObject:dictionary];
- }
- else
- {
- UIAlertView * aler = [[UIAlertView alloc]initWithTitle:@"提示" message:[NSString stringWithFormat:@"您有题目没有答完,请返回检查"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
- [aler show];
- break;
- }
- }
-
- long time = (long)[[NSDate date] timeIntervalSince1970];
- time = (time *1000 + g_server.timeDifference);
- NSString *salt = [NSString stringWithFormat:@"%ld", time];
-
- NSArray * postArray = mutableArray.copy;
-
- NSError *parseError = nil;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postArray options:NSJSONWritingPrettyPrinted error:&parseError];
-
- NSString *jsonstr =[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
-
- [g_server postQuestionAnswers:salt andOptions:jsonstr andToView:self];
- }
- }
- }
- else
- {
- [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]]];
- }
- if( [aDownload.action isEqualToString:act_UserLogout] ){
- //[self performSelector:@selector(doSwitch) withObject:nil afterDelay:1];
- }
- return hide_error;
- }
- -(void)backButtonClicked:(UIButton *)sender
- {
- [g_navigation dismissViewController:self animated:YES];
- }
- -(void)initNavigationView
- {
- self.navigationView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT>=812?88:64)];
- self.navigationView.backgroundColor = [UIColor whiteColor];
- [self.view addSubview:self.navigationView];
-
- UILabel * titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, JX_SCREEN_TOP - 40, JX_SCREEN_WIDTH, 40)];
- titleLabel.text = @"每日答题";
- titleLabel.textColor = [UIColor blackColor];
- titleLabel.font = [UIFont systemFontOfSize:18.0f];
- titleLabel.textAlignment = NSTextAlignmentCenter;
- [self.navigationView addSubview:titleLabel];
-
- self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
- self.backButton.frame = CGRectMake(15, 30, 30, 30);
- if(JX_SCREEN_HEIGHT >= 812)
- {
- self.backButton.frame = CGRectMake(15, 45, 30, 30);
- }
- [self.backButton setImage:[UIImage imageNamed:@"title_back_black"] forState:UIControlStateNormal];
- [self.backButton addTarget:self action:@selector(backButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
- [self.navigationView addSubview:self.backButton];
- }
- -(void)initComponents
- {
-
-
- UIImageView * backView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 0.68*JX_SCREEN_WIDTH)];
- backView.image = [UIImage imageNamed:@"每日答题"];
- [self.view addSubview:backView];
- [backView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(JX_SCREEN_TOP+44);
- make.centerX.mas_equalTo(self.view.mas_centerX);
-
- }];
-
- UIImageView * backViewtitle = [[UIImageView alloc]init];
- backViewtitle.image = [UIImage imageNamed:@"每日完成任务豪礼送不断"];
- [self.view addSubview:backViewtitle];
- [backViewtitle mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(backView.mas_bottom).mas_offset(20);
- make.centerX.mas_equalTo(backView.mas_centerX);
-
- }];
-
- //黄框框
- UIImageView * questionView = [[UIImageView alloc]init];
- questionView.image = [UIImage imageNamed:@"questionImage"];
- [self.view addSubview:questionView];
- questionView.userInteractionEnabled = YES;
- [questionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(backViewtitle.mas_bottom).mas_offset(20);
- make.centerX.mas_equalTo(backViewtitle.mas_centerX);
- make.height.mas_equalTo(280);
- make.width.mas_equalTo(JX_SCREEN_WIDTH - 40);
-
- }];
- //数字标题 提交答卷
- UILabel *titleLL = [[UILabel alloc]init];
- titleLL.text = @"1";
- titleLL.textColor = [UIColor colorWithRed:115/255.0f green:20/255.0f blue:5/255.0f alpha:1.0f];
- titleLL.font = [UIFont boldSystemFontOfSize:15.0f];
- titleLL.textAlignment = NSTextAlignmentCenter;
- [questionView addSubview:titleLL];
- self.questionTitle=titleLL;
- [titleLL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(10);
- make.centerX.mas_equalTo(questionView.mas_centerX);
- }];
-
- UIImageView * lefIMG = [[UIImageView alloc]init];
- lefIMG.image = [UIImage imageNamed:@"第dati"];
- [questionView addSubview:lefIMG];
- [lefIMG mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(titleLL.mas_left).mas_offset(-20);
- make.centerY.mas_equalTo(titleLL.mas_centerY);
-
- }];
-
- UIImageView * rightIMG = [[UIImageView alloc]init];
- rightIMG.image = [UIImage imageNamed:@"题"];
- [questionView addSubview:rightIMG];
- [rightIMG mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(titleLL.mas_right).mas_offset(20);
- make.centerY.mas_equalTo(titleLL.mas_centerY);
-
- }];
-
-
- self.questionLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 40, questionView.frame.size.width - 30, 40)];
- self.questionLabel.text = @"吉利公司保持着多少年的百分百出款?";
- self.questionLabel.numberOfLines = 0;
- self.questionLabel.textAlignment=NSTextAlignmentCenter;
- self.questionLabel.textColor = self.questionTitle.textColor;
- self.questionLabel.font = [UIFont systemFontOfSize:14.0f];
- [questionView addSubview:self.questionLabel];
- [self.questionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(titleLL.mas_bottom).mas_offset(20);
- //make.centerX.mas_equalTo(questionView.mas_centerX);
- make.left.mas_equalTo(5);
- make.right.mas_equalTo(-5);
-
- }];
-
-
- UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
- tableView.dataSource = self;
- tableView.delegate = self;
- tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- tableView.backgroundColor = [UIColor clearColor];
- [questionView addSubview:tableView];
- self.questionTable=tableView;
- [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.questionLabel.mas_bottom).mas_offset(20);
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-10);
- make.bottom.mas_equalTo(-10);
- }];
-
-
-
- UIButton * nextButton = [UIButton buttonWithType:UIButtonTypeCustom]; //提交答卷
- [nextButton setImage:[UIImage imageNamed:@"下一题"] forState:UIControlStateNormal];
- [nextButton addTarget:self action:@selector(nextButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
- nextButton.alpha = 1.0f;
- [self.view addSubview:nextButton];
- self.nextButton=nextButton;
- [nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.questionTable.mas_bottom).mas_offset(40);
- make.centerX.mas_equalTo(self.questionTable.mas_centerX).mas_offset(0);
-
- }];
- }
- /**下一题*/
- -(void)nextButtonClicked:(UIButton *)sender
- {
-
- self.questionTitle.text = [NSString stringWithFormat:@"%zd",_saveSelectIndexArr.count+1];
-
-
- if (_saveSelectIndexArr.count>=_currentSort) {
-
-
- _isclick=NO;
-
- if (_currentSort>_questionArr.count-1) {
-
- // _currentSort=(int)_questionArr.count;
- // UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"当前已是最后一题了" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
- // [alert show];
-
- if (_dataArr333.count==10) {
-
- [SVProgressHUD setMaximumDismissTimeInterval:2];
- [SVProgressHUD showErrorWithStatus:@"已经完成所有答题"];
-
- NSMutableArray * mutableArray = [[NSMutableArray alloc]initWithCapacity:0];
- [_dataArr333 enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-
- QustionJX *optionModel=obj[@"option"];
- NSString *Id_str=obj[@"Id_str"];
-
- NSDictionary * dictionary = @{@"questionId":[NSString stringWithFormat:@"%@",optionModel.id],@"optionId":Id_str};
- [mutableArray addObject:dictionary];
-
- }];
-
- long time = (long)[[NSDate date] timeIntervalSince1970];
- time = (time *1000 + g_server.timeDifference);
- NSString *salt = [NSString stringWithFormat:@"%ld", time];
-
- NSArray * postArray = mutableArray.copy;
-
- NSError *parseError = nil;
-
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postArray options:NSJSONWritingPrettyPrinted error:&parseError];
-
- NSString *jsonstr =[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
-
-
-
- [SVProgressHUD show];
- [g_server postQuestionAnswers:salt andOptions:jsonstr andToView:self];
-
- }
-
-
- return;
- }else{
-
- if (_isAnsware==NO) {
- _isAnsware=YES;
- }else{
-
- [SVProgressHUD showWithStatus:@"请先做答当前题目,再进入下一题。"];
- [SVProgressHUD dismissWithDelay:1.1];
-
-
- }
-
- }
- self.questionTable.userInteractionEnabled=YES;
- [_firstArr removeAllObjects];
- _indexRow=100;
- _indexRightRow=100;
- [_questionArr enumerateObjectsUsingBlock:^(QustionJX * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- //if ([obj.sort intValue]==_currentSort) {
-
- if ( _currentSort == idx) {
-
- [_firstArr addObject:obj];
- self.questionLabel.text = obj.title;
-
- }
- }];
- [self.questionTable reloadData];
- }
- return;
- [_saveSelectIndexArr enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- QustionJX *modelJx=obj[@"option"];
- //if (( [modelJx.title isEqualToString:self.questionTitle.text])&& obj[@"option"]!=nil) {
- if (( [modelJx.title isEqualToString:self.questionTitle.text])&& obj[@"option"]!=nil) {
-
- _indexRightRow=[obj[@"rightRow"] intValue];
- _indexRow=[obj[@"selectIndex"] intValue];
- }else{
-
- self.questionTable.userInteractionEnabled=YES;
- }
- // if ( _currentSort == idx) {
- // _indexRightRow=idx;
- // _indexRow=idx;
- // }
-
- }];
-
-
- }
-
- -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
-
- if (alertView.tag==3000) {
- [g_navigation popToViewController:[JXApplyViewController class] animated:YES];
- return;
- }
- if(alertView.tag == 1000)
- {
- if(buttonIndex==0){
- return;
- }
- [g_navigation popToViewController:[JXApplyViewController class] animated:YES];
-
-
- }
- else if(alertView.tag == 10000)
- {
- self.currentSort ++;
- for(NSDictionary * dictionary in self.questionArray)
- {
- NSString * questionSort = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"sort"]];
- if(questionSort.intValue == self.currentSort)
- {
- NSString * questionTitle = [NSString stringWithFormat:@"第%@题:%@",questionSort,[dictionary objectForKey:@"title"]];
- NSString * questionDesc = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"desc"]];
- if(questionTitle != nil && questionTitle.length != 0 && ![questionTitle isEqualToString:@"(null)"] && ![questionTitle isEqualToString:@"<null>"])
- {
- self.questionTitle.text = questionTitle;
- }
- if(questionDesc != nil && questionDesc.length != 0 && ![questionDesc isEqualToString:@"(null)"] && ![questionDesc isEqualToString:@"<null>"])
- {
- self.questionLabel.text = questionDesc;
- }
- self.currentQuestion = dictionary;
- break;
- }
- }
- [self.questionTable reloadData];
- }
- }
- @end
|