ويمثّل المورد حسب الموضوع مجموعة من عناصر ساحة المشاركات المصنّفة حسب التشابه، مثل الأسبوع المحدّد أو موضوع الدورة التدريبية.
ويتم تحديد كل موضوع عن طريق رقم تعريف فريد يعيّنه الخادم. ويرتبط رقم التعريف هذا برقم تعريف الدورة التدريبية الذي ينتمي إليه الموضوع، واسم الموضوع الفعلي المعروض في واجهة مستخدم Classroom، وتاريخ آخر تحديث ووقته.
إنشاء موضوع
يمكنك إنشاء موضوع جديد في الدورة التدريبية باستخدام طريقة topics.create()
، كما هو موضّح في النموذج التالي:
Java
Python
topic = {
"name": 'Example Topic'
}
response = service.courses().topics().create(
courseId=<course ID or alias>,
body=topic).execute()
print('Topic created: ', response['name'])
استرداد تفاصيل الموضوع
يمكنك استرداد مواضيع الدورة التدريبية المناسبة باستخدام طريقة topics.get()
، كما هو موضّح في النموذج التالي:
Java
Python
response = service.courses().topics().get(
courseId=<course ID or alias>,
id=<topic ID>).execute()
print('{0} ({1})'.format(response['name'], response['topicId']))
للحصول على قائمة بالدورات التدريبية، استخدِم طريقة topics.list()
كما هو موضّح في النموذج التالي:
Java
Python
topics = []
page_token = None
while True:
response = service.courses().topics().list(
pageToken=page_token,
pageSize=30,
courseId=<course ID or alias>).execute()
topics.extend(response.get('topic', []))
page_token = response.get('nextPageToken', None)
if not page_token:
break
if not topics:
print('No topics found.')
else:
print('Topics:')
for topic in topics:
print('{0} ({1})'.format(topic['name'], topic['topicId']))
تعديل المواضيع
يمكنك تعديل اسم موضوع حالي باستخدام الطريقة topics.patch()
،
كما هو موضّح في النموذج التالي:
Java
Python
topic = {
"name": "New Topic Name"
}
response = service.courses().topics().patch(
courseId=<course ID or alias>,
id=<topic ID>,
updateMask="name",
body=topic).execute()
print('{0} ({1})'.format(response['name'], response['topicId']))
حذف المواضيع
يمكنك حذف موضوع حالي باستخدام طريقة topics.delete()
، كما هو موضّح
في النموذج التالي: