EvaluateDetailViewController.m 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // EvaluateDetailViewController.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by 王智 on 2022/4/18.
  6. //
  7. #import "EvaluateDetailViewController.h"
  8. #import "AccompanyEvaluateCell.h"
  9. #import "AccompanyCourseInfoCell.h"
  10. #import "AccompanyAlertView.h"
  11. #import "EvaluateDetailModel.h"
  12. @interface EvaluateDetailViewController ()<UITableViewDelegate,UITableViewDataSource>
  13. @property (nonatomic, strong) UITableView *tableView;
  14. @property (nonatomic, strong) AccompanyAlertView *alertView;
  15. @property (nonatomic, strong) EvaluateDetailModel *detailModel;
  16. @end
  17. @implementation EvaluateDetailViewController
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. // Do any additional setup after loading the view.
  21. [self allocTitle:@"课后评价"];
  22. [self configUI];
  23. [self requestData];
  24. }
  25. - (void)configUI {
  26. [self.scrollView removeFromSuperview];
  27. self.view.backgroundColor = HexRGB(0xf6f8f9);
  28. [self.view addSubview:self.tableView];
  29. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.left.right.top.mas_equalTo(self.view);
  31. make.bottom.mas_equalTo(self.view.mas_bottom).offset(-iPhoneXSafeBottomMargin);
  32. }];
  33. }
  34. - (void)requestData {
  35. [self showhud];
  36. [KSNetworkingManager selectRepliedRequest:KS_POST courseGroupId:self.courseGroupId courseScheduleId:self.courseId studentId:self.studentId success:^(NSDictionary * _Nonnull dic) {
  37. [self removehub];
  38. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  39. self.detailModel = [[EvaluateDetailModel alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
  40. }
  41. else {
  42. [self MBPShow:MESSAGEKEY];
  43. }
  44. [self.tableView reloadData];
  45. } faliure:^(NSError * _Nonnull error) {
  46. [self removehub];
  47. }];
  48. }
  49. #pragma mark ----- table data source
  50. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  51. return 2;
  52. }
  53. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  54. if (indexPath.row == 0) { // 课程信息
  55. AccompanyCourseInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyCourseInfoCell"];
  56. cell.statusLabel.text = @"已结束";
  57. cell.statusLabel.textColor = HexRGB(0x999999);
  58. // [cell configWithStartTime:self.detailModel.startTime endTime:self.detailModel.endTime studentAvatar:self.detailModel.studentAvatar studentName:self.detailModel.studentName studentId:self.detailModel.studentId studentSubject:self.detailModel.subjectName];
  59. cell.hideChatButton = YES;
  60. return cell;
  61. }
  62. else {
  63. AccompanyEvaluateCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyEvaluateCell"];
  64. NSString *message = self.detailModel.teacherReplied;
  65. BOOL hasEvaluate = [NSString isEmptyString:self.detailModel.teacherReplied] ? NO : YES;
  66. MJWeakSelf;
  67. [cell configWithEvaluateMessage:message hasEvaluate:hasEvaluate callback:^{
  68. [weakSelf evaluateCourse];
  69. }];
  70. return cell;
  71. }
  72. }
  73. - (void)evaluateCourse {
  74. self.alertView = [AccompanyAlertView shareInstance];
  75. self.alertView.alertTitle.text = @"评价学员";
  76. self.alertView.tipsLabel.text = @"请输入您对本次课程学员表现的评价";
  77. self.alertView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
  78. [self.alertView showInView:[UIApplication sharedApplication].keyWindow showStarView:NO];
  79. MJWeakSelf;
  80. [self.alertView sureCallback:^(NSString * _Nonnull content, NSInteger starNum) {
  81. [weakSelf evaluateAction:content];
  82. }];
  83. }
  84. - (void)evaluateAction:(NSString *)content {
  85. if ([NSString isEmptyString:content]) {
  86. [self MBPShow:@"请输入评价内容"];
  87. return;
  88. }
  89. [self showhud];
  90. [KSNetworkingManager teacherCourseRepliedRequest:KS_POST courseScheduleId:self.courseId courseGroupId:self.courseGroupId studentId:self.studentId teacherReplied:content success:^(NSDictionary * _Nonnull dic) {
  91. [self removehub];
  92. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  93. [self MBPShow:@"评价成功"];
  94. [self requestData];
  95. }
  96. else {
  97. [self MBPShow:MESSAGEKEY];
  98. }
  99. } faliure:^(NSError * _Nonnull error) {
  100. [self removehub];
  101. }];
  102. }
  103. #pragma mark --- lazying
  104. - (UITableView *)tableView {
  105. if (!_tableView) {
  106. _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  107. _tableView.backgroundColor = [UIColor clearColor];
  108. _tableView.delegate = self;
  109. _tableView.dataSource = self;
  110. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  111. _tableView.showsHorizontalScrollIndicator = NO;
  112. _tableView.showsVerticalScrollIndicator = NO;
  113. _tableView.rowHeight = UITableViewAutomaticDimension;
  114. _tableView.estimatedRowHeight = 136.0f;
  115. [_tableView registerNib:[UINib nibWithNibName:@"AccompanyCourseInfoCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyCourseInfoCell"];
  116. [_tableView registerNib:[UINib nibWithNibName:@"AccompanyEvaluateCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyEvaluateCell"];
  117. }
  118. return _tableView;
  119. }
  120. /*
  121. #pragma mark - Navigation
  122. // In a storyboard-based application, you will often want to do a little preparation before navigation
  123. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  124. // Get the new view controller using [segue destinationViewController].
  125. // Pass the selected object to the new view controller.
  126. }
  127. */
  128. @end