0

boca: Surface detailed student status to UI.

Bug: b:405471524
Test: Manully tested
Change-Id: I862fd0b092273a7827cf382174c4d35f6e4e4aea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6382280
Reviewed-by: Benjamin Zielinski <bzielinski@google.com>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: April Zhou <aprilzhou@google.com>
Cr-Commit-Position: refs/heads/main@{#1439613}
This commit is contained in:
April Zhou 2025-03-28 12:20:49 -07:00 committed by Chromium LUCI CQ
parent 5436b1a40c
commit 4d415ae013
7 changed files with 92 additions and 36 deletions
ash/webui/boca_ui
chrome/test/data/webui/chromeos/boca_ui
chromeos/ash/components/boca/session_api

@ -174,6 +174,7 @@ std::vector<mojom::IdentifiedActivityPtr> SessionActivityProtoToMojom(
auto identity_ptr = mojom::IdentifiedActivity::New(
item.first,
mojom::StudentActivity::New(
mojom::StudentStatusDetail(item.second.state()),
device->second.state() == ::boca::StudentDevice::ACTIVE,
device->second.activity().active_tab().title(),
/*is_caption_enabled=*/false,

@ -1608,6 +1608,8 @@ TEST_F(BocaAppPageHandlerTest, UpdateNonEmptyStudentActivitySucceed) {
EXPECT_EQ(2u, result.size());
// Verify only first device added.
EXPECT_EQ("1", result[0]->id);
EXPECT_EQ(mojom::StudentStatusDetail::kActive,
result[0]->activity->student_status_detail);
EXPECT_FALSE(result[0]->activity->is_active);
EXPECT_EQ("google", result[0]->activity->active_tab);
// Connection code should be set

@ -192,8 +192,30 @@ struct Session {
array<IdentifiedActivity> activities;
};
enum StudentStatusDetail {
kUnknown = 0,
// Student not found.
kNotFound = 1,
// Student added, hasn't joined yet.
kAdded = 2,
// Student has joined.
kActive = 3,
// Student removed due to other session take over.
kRemovedByOtherSession = 4,
// Student removed due to being a teacher.
kRemovedByBeingTeacher = 5,
// Student removed by a teacher.
kRemovedByTeacher = 6,
// Student not added due to configured as teacher in policy.
kNotAddedConfiguredAsTeacher = 7,
// Student not added due to feature not enabled in policy.
kNotAddedNotConfigured = 8,
};
struct StudentActivity {
// If the current student status is active.
// The student's status detail.
StudentStatusDetail student_status_detail;
// If the current device status is active.
bool is_active;
// Current active tab title.
string? active_tab;

@ -88,6 +88,26 @@ export enum SubmitAccessCodeResult {
INVALID_CODE = 2,
}
export enum StudentStatusDetail {
STUDENT_STATE_UNKNOWN = 0,
NOT_FOUND = 1,
ADDED = 2,
ACTIVE = 3,
REMOVED_BY_OTHER_SESSION = 4,
REMOVED_BY_BEING_TEACHER = 5,
REMOVED_BY_TEACHER = 6,
NOT_ADDED_CONFIGURED_AS_TEACHER = 7,
NOT_ADDED_NOT_CONFIGURED = 8,
}
/**
* Declare network state enum type
*/
@ -208,6 +228,7 @@ export declare interface Session {
* Declare StudentActivity
*/
export declare interface StudentActivity {
studentStatusDetail?: StudentStatusDetail;
// Whether the student status have flipped from added to active in the
// session.
isActive: boolean;

@ -21,6 +21,7 @@ export function getStudentActivityMojomToUI(activities: Activity[]):
return {
id: item.id,
studentActivity: {
studentStatusDetail: item.activity.studentStatusDetail.valueOf(),
isActive: item.activity.isActive,
activeTab: item.activity.activeTab ? item.activity.activeTab :
undefined,

@ -658,12 +658,40 @@ suite('ClientDelegateTest', function() {
assertTrue(result);
});
test(
'client delegate should translate data for student activity', () => {
const activities = [
test('client delegate should translate data for student activity', () => {
const activities = [
{
id: '1',
activity: {
studentStatusDetail: 3,
isActive: true,
activeTab: 'google',
isCaptionEnabled: false,
isHandRaised: false,
joinMethod: 0,
viewScreenSessionCode: 'abcd',
},
},
{
id: '2',
activity: {
studentStatusDetail: 2,
isActive: false,
activeTab: 'youtube',
isCaptionEnabled: false,
isHandRaised: false,
joinMethod: 1,
viewScreenSessionCode: null,
},
},
];
const result = getStudentActivityMojomToUI(activities);
assertDeepEquals(
[
{
id: '1',
activity: {
studentActivity: {
studentStatusDetail: 3,
isActive: true,
activeTab: 'google',
isCaptionEnabled: false,
@ -674,44 +702,19 @@ suite('ClientDelegateTest', function() {
},
{
id: '2',
activity: {
studentActivity: {
studentStatusDetail: 2,
isActive: false,
activeTab: 'youtube',
isCaptionEnabled: false,
isHandRaised: false,
joinMethod: 1,
viewScreenSessionCode: null,
viewScreenSessionCode: undefined,
},
},
];
const result = getStudentActivityMojomToUI(activities);
assertDeepEquals(
[
{
id: '1',
studentActivity: {
isActive: true,
activeTab: 'google',
isCaptionEnabled: false,
isHandRaised: false,
joinMethod: 0,
viewScreenSessionCode: 'abcd',
},
},
{
id: '2',
studentActivity: {
isActive: false,
activeTab: 'youtube',
isCaptionEnabled: false,
isHandRaised: false,
joinMethod: 1,
viewScreenSessionCode: undefined,
},
},
],
result);
});
],
result);
});
test('client delegate should translate data for set float', async () => {
const result = await clientDelegateImpl.getInstance().setFloatMode(true);

@ -30,6 +30,12 @@ namespace ash::boca {
if (status == "REMOVED_BY_TEACHER") {
return ::boca::StudentStatus::REMOVED_BY_TEACHER;
}
if (status == "NOT_ADDED_CONFIGURED_AS_TEACHER") {
return ::boca::StudentStatus::NOT_ADDED_CONFIGURED_AS_TEACHER;
}
if (status == "NOT_ADDED_NOT_CONFIGURED") {
return ::boca::StudentStatus::NOT_ADDED_NOT_CONFIGURED;
}
return ::boca::StudentStatus::STUDENT_STATE_UNKNOWN;
}