Enable and disable the whiteboard
The whiteboard module in Flexible Classroom is implemented based on AgoraWidget. You can turn the whiteboard module on or off in the classroom by setting the widget state as active or inactive.
After disabling the whiteboard module, the drawing tools, including pencils, text boxes, shapes, and erasers will no longer be available. Users can neither display class files on the whiteboard. Other features, such as uploading or deleting class files, pop-up quiz, count-down timer, and screen sharing will not be affected.
Disable the whiteboard
You need to monitor the whiteboard widget state change caused by the teacher's client and adjust the UI accordingly. Below takes an iOS project as an example. Generally speaking, you need to edit the /SDKs/AgoraEduUI/AgoraEduUI/Classes/Components/FlatComponents/AgoraBoardUIController.swift
file.
-
Create a new branch based on the latest release branch in the CloudClass-iOS repository.
-
Add a function in the
AgoraBoardUIController.swift
file for destroying the board widget inAgoraBoardUIController
, as follows: -
Add
contextPool.widget.add(self)
in theinit
function inAgoraBoardUIController.swift
to register an observer for observing the whiteboard state change. -
When the state of the whiteboard widget changes, the SDK triggers the
onWidgetActive
oronWidgetInactive
callback. Add logic in theonWidgetActive
andonWidgetInactive
callbacks. When the whiteboard state changes to active, render the whiteboard are; when the whiteboard state changes to inactive, calldeinitBoardWidget
to destroy the board widget.
Reference
AgoraWidgetContext
create
Creates a widget object.
Parameter:
- config: The initialization configurations of the widget object.
Return: An AgoraBaseWidget object.
setWidgetActive
Sets the widget state as active.
Parameter:
- widgetId: The widget ID.
- ownerUuid: (Nullable) The ID of the user to whom the widget belongs. When the user goes offline, the
onWidgetInactive
callback will be triggered for the widgets owned by this user. - roomProperties: (Nullable) The room properties related to the widget.
- syncFrame: (Nullable) The size and position of the widget.
- success: The method call succeeds.
- failure: The method call fails, the SDK returns an error.
setWidgetInactive
Sets the widget state as inactive.
Parameter:
- widgetId: The widget ID.
- roomProperties: (Nullable) The room properties related to the widget.
- success: The method call succeeds.
- failure: The method call fails, the SDK returns an error.
getWidgetActivity
Gets the state of a specified widget.
Parameter:
- widgetId: The widget ID.
Return: Whether the widget is active or not.
getWidgetConfigs
Gets the configurations of all widgets.
Return: An array of the AgoraWidgetConfig objects.
getWidgetConfig
Gets the configurations of a specified widget.
Parameter:
- widgetId: The widget ID.
Return: An AgoraWidgetConfig object.
addWidgetActiveObserver
Registers an observer to observe the state of a specified widget. When the state of the widget changes, the SDK triggers a callback.
Parameter:
- observer: See AgoraWidgetActiveObserver.
- widgetId: The widget ID.
Return: When the widget ID is not valid, the SDK returns an error.
removeWidgetActiveObserver
Registers the observer of a specified widget.
Parameter:
- observer: See AgoraWidgetActiveObserver.
- widgetId: The widget ID.
Return: When the widget ID is not valid, the SDK returns an error.
AgoraWidgetActiveObserver
onWidgetActive
Occurs when the widget state changes to active.
Parameter:
- widgetId: The widget ID.
onWidgetInactive
Occurs when the widget state changes to inactive.
Parameter:
- widgetId: The widget ID.