|
@@ -14,13 +14,36 @@
|
|
|
#import "AccompanyArrangeCell.h"
|
|
|
#import "AccompanyHomeworkCell.h"
|
|
|
#import "AccompanyRemarkCell.h"
|
|
|
+#import "HomeworkDetailModel.h"
|
|
|
+#import "EvaluateDetailModel.h"
|
|
|
+#import "AccompanyDetailBottomView.h"
|
|
|
+#import "KSChatConversationViewController.h"
|
|
|
+#import "WMPlayer.h"
|
|
|
|
|
|
-@interface AccompanyDetailViewController ()<UITableViewDelegate,UITableViewDataSource>
|
|
|
+@interface AccompanyDetailViewController ()<UITableViewDelegate,UITableViewDataSource,WMPlayerDelegate>
|
|
|
+{
|
|
|
+ WMPlayer *_wmPlayer;
|
|
|
+ CGRect _playerFrame;
|
|
|
+}
|
|
|
+@property (nonatomic, strong) UIView *bgView;
|
|
|
+
|
|
|
+@property (nonatomic, assign) BOOL isRatation;
|
|
|
|
|
|
@property (nonatomic, strong) AccompanyNavView *navView;
|
|
|
|
|
|
@property (nonatomic, strong) UITableView *tableView;
|
|
|
|
|
|
+@property (nonatomic, strong) HomeworkDetailModel *homeworkModel;
|
|
|
+
|
|
|
+@property (nonatomic, strong) EvaluateDetailModel *evaluateModel;
|
|
|
+
|
|
|
+@property (nonatomic, strong) AccompanyDetailBottomView *bottomView;
|
|
|
+
|
|
|
+@property (nonatomic, strong) AccompanyAlertView *alertView;
|
|
|
+
|
|
|
+@property (nonatomic, strong) NSMutableArray *fileArray;
|
|
|
+
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation AccompanyDetailViewController
|
|
@@ -30,25 +53,59 @@
|
|
|
// Do any additional setup after loading the view.
|
|
|
self.ks_prefersNavigationBarHidden = YES;
|
|
|
[self configUI];
|
|
|
- [self requestMessage];
|
|
|
+ [self requestCourseInfoMessage];
|
|
|
}
|
|
|
|
|
|
-- (void)requestMessage {
|
|
|
-
|
|
|
+- (void)requestCourseInfoMessage {
|
|
|
+ [self requestHomeworkMessage];
|
|
|
+ [self requestEvaluateMessage];
|
|
|
}
|
|
|
|
|
|
- (void)requestHomeworkMessage {
|
|
|
-
|
|
|
+ [KSNetworkingManager homeworkDetailRequest:KS_GET courseId:self.courseId success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ self.homeworkModel = [[HomeworkDetailModel alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
|
|
|
+ if (self.homeworkModel.submitHomework == 1) {
|
|
|
+ if (![NSString isEmptyString:self.homeworkModel.studentAttachments]) {
|
|
|
+ self.fileArray = [NSMutableArray arrayWithArray:[self.homeworkModel.studentAttachments componentsSeparatedByString:@","]];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ self.fileArray = [NSMutableArray array];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ self.fileArray = [NSMutableArray array];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ [self.tableView reloadData];
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
-//- (void)request
|
|
|
+- (void)requestEvaluateMessage {
|
|
|
+ [KSNetworkingManager selectRepliedRequest:KS_POST courseGroupId:self.courseId courseScheduleId:self.courseGroupId studentId:self.studentId success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ self.evaluateModel = [[EvaluateDetailModel alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ [self.tableView reloadData];
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+
|
|
|
+ }];
|
|
|
+}
|
|
|
|
|
|
- (void)configUI {
|
|
|
[self.scrollView removeFromSuperview];
|
|
|
[self.view addSubview:self.navView];
|
|
|
CGFloat height = [self.navView getViewHeight];
|
|
|
[self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.right.top.mas_equalTo(self);
|
|
|
+ make.left.right.top.mas_equalTo(self.view);
|
|
|
make.height.mas_equalTo(height);
|
|
|
}];
|
|
|
[self.view addSubview:self.tableView];
|
|
@@ -68,34 +125,222 @@
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
if (indexPath.row == 0) {
|
|
|
AccompanyCourseInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyCourseInfoCell"];
|
|
|
+ [cell configWithStartTime:self.homeworkModel.startTime endTime:self.homeworkModel.endTime studentAvatar:self.homeworkModel.studentAvatar studentName:self.homeworkModel.studentName studentId:self.homeworkModel.studentId studentSubject:self.homeworkModel.subjectName];
|
|
|
+ cell.hideChatButton = NO;
|
|
|
+ MJWeakSelf;
|
|
|
+ [cell chatCalkback:^{
|
|
|
+ [weakSelf chatAction];
|
|
|
+ }];
|
|
|
+
|
|
|
return cell;
|
|
|
}
|
|
|
else if (indexPath.row == 1) {
|
|
|
AccompanyEvaluateCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyEvaluateCell"];
|
|
|
+ NSString *message = self.evaluateModel.teacherReplied;
|
|
|
+ BOOL hasEvaluate = [NSString isEmptyString:self.evaluateModel.teacherReplied] ? NO : YES;
|
|
|
+ MJWeakSelf;
|
|
|
+ [cell configWithEvaluateMessage:message hasEvaluate:hasEvaluate callback:^{
|
|
|
+ [weakSelf evaluateCourse];
|
|
|
+ }];
|
|
|
return cell;
|
|
|
}
|
|
|
else if (indexPath.row == 2) {
|
|
|
AccompanyStudentEvaCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyStudentEvaCell"];
|
|
|
+ NSString *message = self.evaluateModel.studentReplied;
|
|
|
+ BOOL hasEvaluate = [NSString isEmptyString:self.evaluateModel.studentReplied] ? NO : YES;
|
|
|
+ [cell configWithEvaluateMessage:message starNum:self.evaluateModel.score hasEvaluate:hasEvaluate];
|
|
|
return cell;
|
|
|
}
|
|
|
else if (indexPath.row == 3) {
|
|
|
AccompanyArrangeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyArrangeCell"];
|
|
|
-
|
|
|
+ BOOL hasArrange = self.homeworkModel.decorateHomework == 1 ? YES : NO;
|
|
|
+ MJWeakSelf;
|
|
|
+ [cell configWithHomeworkContent:self.homeworkModel.content hasArrangeHomework:hasArrange callback:^{
|
|
|
+ [weakSelf arrangeHomework];
|
|
|
+ }];
|
|
|
return cell;
|
|
|
}
|
|
|
else if (indexPath.row == 4) {
|
|
|
+ BOOL hasSubmitHomework = self.homeworkModel.submitHomework == 1 ? YES : NO;
|
|
|
AccompanyHomeworkCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyHomeworkCell"];
|
|
|
+ MJWeakSelf;
|
|
|
+ [cell configWithAttachmentArray:self.fileArray hasSubmit:hasSubmitHomework callback:^(NSInteger viewIndex) {
|
|
|
+ [weakSelf playVideoIndex:viewIndex];
|
|
|
+ }];
|
|
|
return cell;
|
|
|
}
|
|
|
else {
|
|
|
AccompanyRemarkCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyRemarkCell"];
|
|
|
+ BOOL hasEvaluate = self.homeworkModel.reviewHomework == 1? YES : NO;
|
|
|
+ MJWeakSelf;
|
|
|
+ [cell configWithRemarkMessage:self.homeworkModel.teacherReplied hasEvaluate:hasEvaluate callback:^{
|
|
|
+ [weakSelf evaluateHomework];
|
|
|
+ }];
|
|
|
return cell;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#pragma mark --- lazying
|
|
|
+- (void)chatAction {
|
|
|
+ if (self.homeworkModel && ![NSString isEmptyString:self.homeworkModel.studentId]) {
|
|
|
+ KSChatConversationViewController *conversationVC = [[KSChatConversationViewController alloc] init];
|
|
|
+ conversationVC.targetId = self.homeworkModel.studentId;
|
|
|
+ conversationVC.title = self.homeworkModel.studentName;
|
|
|
+ conversationVC.conversationType = ConversationType_PRIVATE;
|
|
|
+ [self.navigationController pushViewController:conversationVC animated:YES];
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+- (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 requestCourseInfoMessage];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ [self removehub];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)arrangeHomework {
|
|
|
+ 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 arrangeAction:content];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)arrangeAction:(NSString *)homeworkContent {
|
|
|
+ [self showhud];
|
|
|
+ [KSNetworkingManager homeworkDecorateRequest:KS_POST content:homeworkContent courseScheduleId:self.courseId success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ [self removehub];
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ [self MBPShow:@"布置成功"];
|
|
|
+ [self requestCourseInfoMessage];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ [self removehub];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+// 评价作业
|
|
|
+- (void)evaluateHomework {
|
|
|
+ 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 commentAction:content];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)commentAction:(NSString *)commentMessage {
|
|
|
+ [self showhud];
|
|
|
+ [KSNetworkingManager homeworkReviewRequest:KS_POST courseScheduleId:self.courseId review:commentMessage success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ [self removehub];
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ [self MBPShow:@"点评成功"];
|
|
|
+ [self requestCourseInfoMessage];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ [self removehub];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+- (void)playVideoIndex:(NSInteger)index {
|
|
|
+ if (self.fileArray.count > index) {
|
|
|
+ NSString *fileUrl = self.fileArray[index];
|
|
|
+ [self playVideoWithUrl:fileUrl];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark ------ WMPlayer
|
|
|
+- (void)playVideoWithUrl:(NSString *)fileUrl {
|
|
|
+ fileUrl = [fileUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
|
+ _playerFrame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
|
|
|
+ _wmPlayer = [[WMPlayer alloc] initWithFrame:_playerFrame];
|
|
|
+ WMPlayerModel *playModel = [[WMPlayerModel alloc] init];
|
|
|
+ playModel.videoURL = [NSURL URLWithString:fileUrl];
|
|
|
+ _wmPlayer.playerModel = playModel;
|
|
|
+ _wmPlayer.delegate = self;
|
|
|
+ _bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
|
|
|
+ _bgView.backgroundColor = [UIColor blackColor];
|
|
|
+ [[UIApplication sharedApplication].keyWindow addSubview:_bgView];
|
|
|
+ [[UIApplication sharedApplication].keyWindow addSubview:_wmPlayer];
|
|
|
+ [[UIApplication sharedApplication].keyWindow bringSubviewToFront:_wmPlayer];
|
|
|
+
|
|
|
+ [_wmPlayer play];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)wmplayer:(WMPlayer *)wmplayer clickedCloseButton:(UIButton *)backBtn {
|
|
|
+ [wmplayer removePlayer];
|
|
|
+ [_bgView removeFromSuperview];
|
|
|
+ [self setNeedsStatusBarAppearanceUpdate];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)wmplayer:(WMPlayer *)wmplayer clickedFullScreenButton:(UIButton *)fullScreenBtn {
|
|
|
+ self.isRatation = !self.isRatation;
|
|
|
+
|
|
|
+ if (self.isRatation) {
|
|
|
+ [wmplayer removeFromSuperview];
|
|
|
+ [UIView animateWithDuration:1.0f animations:^{
|
|
|
+ wmplayer.transform = CGAffineTransformMakeRotation(M_PI_2);
|
|
|
+
|
|
|
+ } completion:^(BOOL finished) {
|
|
|
+ wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
|
|
|
+ [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
|
|
|
+ [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [wmplayer removeFromSuperview];
|
|
|
+
|
|
|
+ [UIView animateWithDuration:1.0f animations:^{
|
|
|
+ // 复原
|
|
|
+ wmplayer.transform = CGAffineTransformIdentity;
|
|
|
+
|
|
|
+ } completion:^(BOOL finished) {
|
|
|
+ wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
|
|
|
+ [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
|
|
|
+ [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark --- lazying
|
|
|
- (UITableView *)tableView {
|
|
|
if (!_tableView) {
|
|
|
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
|
@@ -106,6 +351,12 @@
|
|
|
_tableView.showsHorizontalScrollIndicator = NO;
|
|
|
_tableView.backgroundColor = [UIColor clearColor];
|
|
|
_tableView.rowHeight = UITableViewAutomaticDimension;
|
|
|
+ [_tableView registerNib:[UINib nibWithNibName:@"AccompanyCourseInfoCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyCourseInfoCell"];
|
|
|
+ [_tableView registerNib:[UINib nibWithNibName:@"AccompanyEvaluateCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyEvaluateCell"];
|
|
|
+ [_tableView registerNib:[UINib nibWithNibName:@"AccompanyStudentEvaCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyStudentEvaCell"];
|
|
|
+ [_tableView registerNib:[UINib nibWithNibName:@"AccompanyArrangeCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyArrangeCell"];
|
|
|
+ [_tableView registerNib:[UINib nibWithNibName:@"AccompanyHomeworkCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyHomeworkCell"];
|
|
|
+ [_tableView registerNib:[UINib nibWithNibName:@"AccompanyRemarkCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyRemarkCell"];
|
|
|
_tableView.estimatedRowHeight = 136.0f;
|
|
|
UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
|
|
|
bottomView.backgroundColor = [UIColor clearColor];
|
|
@@ -113,6 +364,7 @@
|
|
|
}
|
|
|
return _tableView;
|
|
|
}
|
|
|
+
|
|
|
- (AccompanyNavView *)navView {
|
|
|
if (!_navView) {
|
|
|
_navView = [AccompanyNavView shareInstance];
|
|
@@ -124,6 +376,20 @@
|
|
|
return _navView;
|
|
|
}
|
|
|
|
|
|
+- (AccompanyDetailBottomView *)bottomView {
|
|
|
+ if (!_bottomView) {
|
|
|
+ _bottomView = [AccompanyDetailBottomView shareInstance];
|
|
|
+ MJWeakSelf;
|
|
|
+ [_bottomView joinroomCallback:^{
|
|
|
+ [weakSelf joinRoomAction];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ return _bottomView;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)joinRoomAction {
|
|
|
+
|
|
|
+}
|
|
|
/*
|
|
|
#pragma mark - Navigation
|
|
|
|