|
@@ -19,6 +19,8 @@
|
|
|
#import "AccompanyDetailBottomView.h"
|
|
|
#import "KSChatConversationViewController.h"
|
|
|
#import "WMPlayer.h"
|
|
|
+#import "RecordCheckManager.h"
|
|
|
+#import "KSPremissionAlert.h"
|
|
|
|
|
|
@interface AccompanyDetailViewController ()<UITableViewDelegate,UITableViewDataSource,WMPlayerDelegate>
|
|
|
{
|
|
@@ -116,6 +118,24 @@
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+- (void)evaluateWithStatusLabel:(UILabel *)statusLabel {
|
|
|
+ if ([self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
|
|
|
+ statusLabel.text = @"已结束";
|
|
|
+ statusLabel.textColor = HexRGB(0x999999);
|
|
|
+ [self.bottomView.sureButton setBackgroundColor:HexRGB(0xd5d5d5)];
|
|
|
+ }
|
|
|
+ else if ([self.homeworkModel.courseStatus isEqualToString:@"ING"]) {
|
|
|
+ statusLabel.text = @"进行中";
|
|
|
+ statusLabel.textColor = THEMECOLOR;
|
|
|
+ [self.bottomView.sureButton setBackgroundColor:THEMECOLOR];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ statusLabel.text = @"未开始";
|
|
|
+ statusLabel.textColor = HexRGB(0xff802c);
|
|
|
+ [self.bottomView.sureButton setBackgroundColor:THEMECOLOR];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
#pragma mark --- table data source
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
@@ -125,6 +145,7 @@
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
if (indexPath.row == 0) {
|
|
|
AccompanyCourseInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyCourseInfoCell"];
|
|
|
+ [self evaluateWithStatusLabel:cell.statusLabel];
|
|
|
[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;
|
|
@@ -252,6 +273,14 @@
|
|
|
|
|
|
// 评价作业
|
|
|
- (void)evaluateHomework {
|
|
|
+ if (self.homeworkModel.decorateHomework == 0) {
|
|
|
+ [self MBPShow:@"您还未布置作业"];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if (self.homeworkModel.submitHomework == 0) {
|
|
|
+ [self MBPShow:@"学生还未提交作业"];
|
|
|
+ return;
|
|
|
+ }
|
|
|
self.alertView = [AccompanyAlertView shareInstance];
|
|
|
self.alertView.alertTitle.text = @"作业点评";
|
|
|
self.alertView.tipsLabel.text = @"请输入您对本次作业的点评";
|
|
@@ -358,9 +387,8 @@
|
|
|
[_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];
|
|
|
- _tableView.tableFooterView = bottomView;
|
|
|
+ self.bottomView.frame = CGRectMake(0, 0, kScreenWidth, 70);
|
|
|
+ self.tableView.tableFooterView = self.bottomView;
|
|
|
}
|
|
|
return _tableView;
|
|
|
}
|
|
@@ -381,15 +409,74 @@
|
|
|
_bottomView = [AccompanyDetailBottomView shareInstance];
|
|
|
MJWeakSelf;
|
|
|
[_bottomView joinroomCallback:^{
|
|
|
- [weakSelf joinRoomAction];
|
|
|
+ [weakSelf tryJoinRoom];
|
|
|
}];
|
|
|
}
|
|
|
return _bottomView;
|
|
|
}
|
|
|
|
|
|
-- (void)joinRoomAction {
|
|
|
+- (void)tryJoinRoom {
|
|
|
+ [self joinClassRoom];
|
|
|
+ return;
|
|
|
+ NSDateFormatter *dateFormatter = [NSObject getDateformatter];
|
|
|
+ [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
|
|
|
+ NSDate *beginDate = [dateFormatter dateFromString:self.homeworkModel.startTime];
|
|
|
+ NSDate *endDate = [dateFormatter dateFromString:self.homeworkModel.endTime];
|
|
|
+ NSDate *currentDate = [NSDate date];
|
|
|
+ NSTimeInterval beginTimeInterval = [beginDate timeIntervalSinceDate:currentDate];
|
|
|
+ NSTimeInterval endTimeInterval = [currentDate timeIntervalSinceDate:endDate];
|
|
|
+ if (beginTimeInterval <= self.joinRoomBeforeTime * 60 && endTimeInterval < 0) {
|
|
|
+ [self joinClassRoom];
|
|
|
+ }
|
|
|
+ else if (endTimeInterval > 0) {
|
|
|
+ [self MBPShow:@"该课程已结束"];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ NSString *tipsString = [NSString stringWithFormat:@"课程还未开始,请在上课前%zd分钟进入", self.joinRoomBeforeTime];
|
|
|
+ [self MBPShow:tipsString];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 加入房间
|
|
|
+- (void)joinClassRoom {
|
|
|
+ // 加入房间前判断摄像头和麦克风逻辑
|
|
|
+ PREMISSIONTYPE micEnable = [RecordCheckManager checkPermissionShowAlert:NO showInView:nil];
|
|
|
+ PREMISSIONTYPE cameraEnable = [RecordCheckManager checkCameraPremissionAvaiable:NO showInView:nil];
|
|
|
+ if (micEnable == PREMISSIONTYPE_YES && cameraEnable == PREMISSIONTYPE_YES) {
|
|
|
+ // 进入教室
|
|
|
+ // 判断是否进行课前检测
|
|
|
+
|
|
|
+// [self.classManager joinRoomWithId:[NSString stringWithFormat:@"%zd", self.courseMessage.internalBaseClassIdentifier] subjectName:self.courseMessage.subjectName subjectId:self.courseMessage.subjectId classEndTime:self.courseMessage.endClassTime quitEndTime:self.quitRomeEndTime inViewController:self];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (micEnable == PREMISSIONTYPE_NO && cameraEnable == PREMISSIONTYPE_NO) { // 如果麦克风权限和摄像头权限都没有
|
|
|
+ [self showAlertWithMessage:@"请开启相机和麦克风访问权限" type:CHECKDEVICETYPE_BOTH];
|
|
|
+ }
|
|
|
+ else if (micEnable == PREMISSIONTYPE_NO) { // 如果没有麦克风权限
|
|
|
+ [self showAlertWithMessage:@"请开启麦克风访问权限" type:CHECKDEVICETYPE_MIC];
|
|
|
+ }
|
|
|
+ else if (cameraEnable == PREMISSIONTYPE_NO) { // 如果没有摄像头权限
|
|
|
+ [self showAlertWithMessage:@"请开启相机访问权限" type:CHECKDEVICETYPE_CAMREA];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)showAlertWithMessage:(NSString *)message type:(CHECKDEVICETYPE)deviceType {
|
|
|
+ [KSPremissionAlert shareInstanceDisplayImage:deviceType message:message showInView:self.view cancel:^{
|
|
|
+
|
|
|
+ } confirm:^{
|
|
|
+ [self openSettingView];
|
|
|
+ }];
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+- (void)openSettingView {
|
|
|
+ if (@available(iOS 10, *)) {
|
|
|
+ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
|
|
|
+ } else {
|
|
|
+ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
|
|
|
+ }
|
|
|
+}
|
|
|
/*
|
|
|
#pragma mark - Navigation
|
|
|
|