123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- //
- // EvaluateDetailViewController.m
- // KulexiuForTeacher
- //
- // Created by 王智 on 2022/4/18.
- //
- #import "EvaluateDetailViewController.h"
- #import "AccompanyEvaluateCell.h"
- #import "AccompanyCourseInfoCell.h"
- #import "AccompanyAlertView.h"
- #import "EvaluateDetailModel.h"
- @interface EvaluateDetailViewController ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) AccompanyAlertView *alertView;
- @property (nonatomic, strong) EvaluateDetailModel *detailModel;
- @end
- @implementation EvaluateDetailViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- [self allocTitle:@"课后评价"];
- [self configUI];
- [self requestData];
- }
- - (void)configUI {
- [self.scrollView removeFromSuperview];
- self.view.backgroundColor = HexRGB(0xf6f8f9);
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.mas_equalTo(self.view);
- make.bottom.mas_equalTo(self.view.mas_bottom).offset(-iPhoneXSafeBottomMargin);
- }];
- }
- - (void)requestData {
- [self showhud];
- [KSNetworkingManager selectRepliedRequest:KS_POST courseGroupId:self.courseGroupId courseScheduleId:self.courseId studentId:self.studentId success:^(NSDictionary * _Nonnull dic) {
- [self removehub];
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- self.detailModel = [[EvaluateDetailModel alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
- }
- else {
-
- [self MBPShow:MESSAGEKEY];
- }
- [self.tableView reloadData];
- } faliure:^(NSError * _Nonnull error) {
- [self removehub];
- }];
- }
- #pragma mark ----- table data source
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 2;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.row == 0) { // 课程信息
- AccompanyCourseInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyCourseInfoCell"];
- cell.statusLabel.text = @"已结束";
- cell.statusLabel.textColor = HexRGB(0x999999);
- // [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];
- cell.hideChatButton = YES;
- return cell;
- }
- else {
- AccompanyEvaluateCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyEvaluateCell"];
- NSString *message = self.detailModel.teacherReplied;
- BOOL hasEvaluate = [NSString isEmptyString:self.detailModel.teacherReplied] ? NO : YES;
- MJWeakSelf;
- [cell configWithEvaluateMessage:message hasEvaluate:hasEvaluate callback:^{
- [weakSelf evaluateCourse];
- }];
- return cell;
- }
- }
- - (void)evaluateCourse {
- self.alertView = [AccompanyAlertView shareInstance];
- self.alertView.alertTitle.text = @"评价学员";
- self.alertView.tipsLabel.text = @"请输入您对本次课程学员表现的评价";
- self.alertView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
- [self.alertView showInView:[UIApplication sharedApplication].keyWindow showStarView:NO];
- MJWeakSelf;
- [self.alertView sureCallback:^(NSString * _Nonnull content, NSInteger starNum) {
- [weakSelf evaluateAction:content];
- }];
- }
- - (void)evaluateAction:(NSString *)content {
- if ([NSString isEmptyString:content]) {
- [self MBPShow:@"请输入评价内容"];
- return;
- }
- [self showhud];
- [KSNetworkingManager teacherCourseRepliedRequest:KS_POST courseScheduleId:self.courseId courseGroupId:self.courseGroupId studentId:self.studentId teacherReplied:content success:^(NSDictionary * _Nonnull dic) {
- [self removehub];
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- [self MBPShow:@"评价成功"];
- [self requestData];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [self removehub];
- }];
- }
- #pragma mark --- lazying
- - (UITableView *)tableView {
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _tableView.backgroundColor = [UIColor clearColor];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.showsHorizontalScrollIndicator = NO;
- _tableView.showsVerticalScrollIndicator = NO;
- _tableView.rowHeight = UITableViewAutomaticDimension;
- _tableView.estimatedRowHeight = 136.0f;
- [_tableView registerNib:[UINib nibWithNibName:@"AccompanyCourseInfoCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyCourseInfoCell"];
- [_tableView registerNib:[UINib nibWithNibName:@"AccompanyEvaluateCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyEvaluateCell"];
- }
- return _tableView;
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|