Skip to main content

You are viewing Agora Docs forBetaproducts and features. Switch to Docs

How to set custom user and class attributes?

Flexible Classroom supports custom user attributes, classroom attributes, and widget attributes. You can set any classroom attribute according to your business needs, and Flexible Classroom will synchronize it to all terminals.

Attributes include names and values, and each attribute name has only one corresponding attribute value. You can modify the value of custom user attributes or classroom attributes in two ways, by full modification or path modification.

Suppose you currently define the following attributes:


_9
{"key1":
_9
{"subkey1":"a",
_9
"subkey2":"b"
_9
},
_9
"key2":
_9
{"subkey3":"c",
_9
"subkey4":"d"
_9
}
_9
}

If you want to modify all attributes, you can use the full modification method. For example, to change the value of all subkey to uppercase, pass the following JSON array when calling the API:


_9
{"key1":
_9
{"subkey1":"A",
_9
"subkey2":"B"
_9
},
_9
"key2":
_9
{"subkey3":"C",
_9
"subkey4":"D"
_9
}
_9
}

If you only want to modify some properties, you can use the path modification method. For example, pass in {"key1.subkey1":"A"} when calling the API to modify the A value to a for subkey1. The modified attributes are as follows:


_9
{"key1":
_9
{"subkey1":"a",
_9
"subkey2":"B"
_9
},
_9
"key2":
_9
{"subkey3":"C",
_9
"subkey4":"D"
_9
}
_9
}

If you pass in {"key1.subkey5":"E"}, the modified attributes are as follows:


_10
{"key1":
_10
{"subkey1":"a",
_10
"subkey2":"B",
_10
"subkey5":"E"
_10
},
_10
"key2":
_10
{"subkey3":"C",
_10
"subkey4":"D"
_10
}
_10
}

If you pass in {"key1":{ "subkey5":"E"}} with all key1 original, the modified attributes are as follows:


_9
{"key1":
_9
{
_9
"subkey5":"E"
_9
},
_9
"key2":
_9
{"subkey3":"C",
_9
"subkey4":"D"
_9
}
_9
}

If you pass in {"key1.subkey5":"E", "key2.subkey6":"F"}, the modified attributes are as follows:


_11
{"key1":
_11
{"subkey1":"A",
_11
"subkey2":"B",
_11
"subkey5":"E"
_11
},
_11
"key2":
_11
{"subkey3":"C",
_11
"subkey4":"D",
_11
"subkey6":"F"
_11
}
_11
}

vundefined