How to realize the teaching whiteboard in the development of online education platform

Teaching whiteboard is an indispensable function of online education platform. Its function is just like the blackboard of offline classroom, through which lecturers can operate blackboard writing, courseware display and so on. Let's take the online education platform development of iOS version as an example to understand how the board functions are implemented and invoked.

1. Get the room roomToken required by the corresponding room uuid from the server. In practice, this step can be placed on the server.

{
    [WhiteUtils getRoomTokenWithUuid:self.roomUuid completionHandler:^(NSString * _Nullable roomToken, NSError * _Nullable error) {
        if (roomToken) {
            self.roomToken = roomToken;
//Get token and join the room
             [self joinRoomWithToken:roomToken];
         } else {
            UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"obtain RoomToken fail", nil) message:[NSString stringWithFormat:@"error message:%@", [error description]] preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"determine", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                [self.navigationController popViewControllerAnimated:YES];
            }];
            [alertVC addAction:action];
            [self presentViewController:alertVC animated:YES completion:nil];
        }
    }];
}

2. Join whiteboard room

{
    //Configure the avatar to display when operating the whiteboard
    NSDictionary *payload = @{@"avatar": [Config getavatarThumb]};
    WhiteRoomConfig *roomConfig = [[WhiteRoomConfig alloc] initWithUuid:self.roomUuid roomToken:roomToken userPayload:payload];
    // *isWritable is yes by default, which is used for unit testing
    roomConfig.isWritable = YES;
    // Configuration, whether the eraser can delete the picture. The default is false, which can delete pictures.
    // roomConfig.disableEraseImage = YES;

    [self.sdk joinRoomWithConfig:roomConfig callbacks:nil completionHandler:^(BOOL success, WhiteRoom * _Nonnull room, NSError * _Nonnull error) {
        if (success) {

            self.roomToken = roomToken;
            self.room = room;
            isDisableTeachingAids = YES;
//No user's teaching aid operation is prohibited
            [_room disableDeviceInputs:YES];

        } else {
            self.title = NSLocalizedString(@"Join failed", nil);
            UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Failed to join room", nil) message:[NSString stringWithFormat:@"error message:%@", [error localizedDescription]] preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"determine", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                [self.navigationController popViewControllerAnimated:YES];
            }];
            [alertVC addAction:action];
            [self presentViewController:alertVC animated:YES completion:nil];
        }
    }];
}

3. Use and operation of teaching aids

/*
WhiteApplianceNameKey const AppliancePencil = @"pencil";
WhiteApplianceNameKey const ApplianceSelector = @"selector";
WhiteApplianceNameKey const ApplianceText = @"text";
WhiteApplianceNameKey const ApplianceEllipse = @"ellipse";
WhiteApplianceNameKey const ApplianceRectangle = @"rectangle";
WhiteApplianceNameKey const ApplianceEraser = @"eraser";
*/
        currentmState.currentApplianceName = AppliancePencil;
//Colors can be customized
        currentmState.strokeColor = [UIColor redColor];
//Line width can be customized
        currentmState.strokeWidth = 10;
        [self.room setMemberState:currentmState];

4. Exit room

The above is the implementation and calling process of teaching whiteboard in the development process of iOS version online education platform.

Statement: the above content is the author's original, without the author's consent, it is forbidden to reprint, otherwise the relevant legal liability will be investigated.

Tags: iOS SDK

Posted on Thu, 04 Jun 2020 09:08:24 -0700 by baw