छात्र-छात्राओं के ग्रुप बनाकर, उन्हें अलग-अलग टीमों में व्यवस्थित तरीके से बांटा जा सकता है. इससे ग्रुप की क्षमता के हिसाब से असाइनमेंट देने और साथ मिलकर की जाने वाली गतिविधियों में उनकी भागेदारी तय करने जैसे मकसद पूरे किए जा सकते हैं. Classroom API का इस्तेमाल करके, एडमिन और शिक्षकों की ओर से किसी कोर्स में छात्र-छात्राओं के ग्रुप बनाए जा सकते हैं, उनमें बदलाव किया जा सकता है, और उन्हें पढ़ा जा सकता है.
छात्र-छात्राओं के ग्रुप बनाए जा सकते हैं, अपडेट किए जा सकते हैं, मिटाए जा सकते हैं, और पढ़े जा सकते हैं. इसके लिए, इन तरीकों का इस्तेमाल करें:
छात्र-छात्राओं के ग्रुप में सदस्यों को जोड़ने, हटाने, और उन्हें पढ़ने के लिए, यहां दिए गए तरीकों का इस्तेमाल किया जा सकता है:
लाइसेंस और ज़रूरी शर्तें
किसी कोर्स में छात्र-छात्राओं के ग्रुप बनाने, उनमें बदलाव करने या उन्हें मिटाने के लिए, ये शर्तें पूरी होनी चाहिए:
- अनुरोध करने वाला व्यक्ति, कोर्स का शिक्षक या डोमेन का एडमिन होना चाहिए.
- अनुरोध करने वाले उपयोगकर्ता के पास, Google Workspace for Education Plus का लाइसेंस होना चाहिए.
- कोर्स के मालिक को Google Workspace for Education Plus का लाइसेंस असाइन किया गया हो.
छात्र-छात्राओं के ग्रुप और उनके सदस्यों की जानकारी फ़ेच की जा रही है
किसी कोर्स के एडमिन और शिक्षक, छात्र-छात्राओं के ग्रुप का डेटा पढ़ सकते हैं. इससे कोई फ़र्क़ नहीं पड़ता कि उन्हें कौनसा लाइसेंस असाइन किया गया है. इसका मतलब है कि किसी कोर्स में एडमिन या शिक्षक की ओर से, ListStudentGroups और ListStudentGroupMembers एंडपॉइंट के लिए अनुरोध किए जा सकते हैं.
कोड के उदाहरण के लिए ज़रूरी शर्तें
इस गाइड में Python में कोड के उदाहरण दिए गए हैं. साथ ही, यह माना गया है कि आपके पास ये चीज़ें हैं:
- Google Cloud प्रोजेक्ट. Python क्विकस्टार्ट में दिए गए निर्देशों का पालन करके, इसे सेट अप किया जा सकता है.
- आपके प्रोजेक्ट की OAuth सहमति स्क्रीन में ये स्कोप जोड़े गए हैं:
https://www.googleapis.com/auth/classroom.rostershttps://www.googleapis.com/auth/classroom.rosters.readonlyसिर्फ़ पढ़ने वाले एंडपॉइंट के लिए.
- उस कोर्स का आईडी जिसमें छात्र-छात्राओं के ग्रुप मैनेज किए जाने चाहिए. कोर्स के मालिक के पास Google Workspace for Education Plus का लाइसेंस होना चाहिए.
- शिक्षक या एडमिन के क्रेडेंशियल का ऐक्सेस हो. साथ ही, उनके पास Google Workspace for Education Plus का लाइसेंस हो.
देखें कि उपयोगकर्ता के लिए अपग्रेड उपलब्ध है या नहीं
Classroom API, userProfiles.checkUserCapability
एंडपॉइंट उपलब्ध कराता है. इससे आपको यह तय करने में मदद मिलती है कि कोई उपयोगकर्ता, छात्र-छात्राओं के ग्रुप बना सकता है या नहीं. साथ ही, वह ग्रुप और उसके सदस्यों में बदलाव कर सकता है या नहीं. यह तरीका, Developer Preview Program के ज़रिए उपलब्ध है. अगर आपने शुरुआत में Python क्विकस्टार्ट का इस्तेमाल किया है, तो Classroom की एक नई सेवा सेट अप करें. इससे आपको पूर्वावलोकन के तरीके ऐक्सेस करने में मदद मिलेगी:
Python
classroom_service_with_capability_endpoint = googleapiclient.discovery.build(
serviceName='classroom',
version='v1',
credentials=creds,
static_discovery=False,
discoveryServiceUrl='https://classroom.googleapis.com/$discovery/rest?labels=DEVELOPER_PREVIEW&key=API_KEY')
userProfiles.checkUserCapability एंडपॉइंट सिर्फ़ यह आकलन करता है कि कोई उपयोगकर्ता किसी सुविधा का इस्तेमाल करने की ज़रूरी शर्तें पूरी करता है या नहीं. जैसे, छात्र-छात्राओं के ग्रुप में बदलाव करना. इससे कोर्स में भूमिका के बारे में कोई जानकारी नहीं मिलती. उदाहरण के लिए,
अगर किसी उपयोगकर्ता के पास CREATE_STUDENT_GROUP की सुविधा है, लेकिन वह कोर्स में छात्र है, तो CreateStudentGroup एंडपॉइंट के लिए किया गया अनुरोध पूरा नहीं होगा.
Python
def check_student_groups_update_capability():
"""Checks whether a user is eligible to create and modify student groups."""
capability = classroom_service_with_capability_endpoint.userProfiles().checkUserCapability(
userId="me", # Can also be set to a different user's email address or ID
capability="CREATE_STUDENT_GROUP",
previewVersion="V1_20240930_PREVIEW" # Required while the method is in the DPP.
).execute()
if capability.get("allowed"): # Retrieve the `allowed` boolean from the response.
print("User is eligible to create and modify student groups.")
else:
print("User is not eligible to create and modify student groups.")
छात्र-छात्राओं के ग्रुप मैनेज करना
छात्र-छात्राओं के ग्रुप बनाने के लिए, CreateStudentGroup एंडपॉइंट का इस्तेमाल किया जा सकता है.
Python
def create_student_group(classroom_service, course_id):
body = {
"title": "Team Blue"
}
response = classroom_service.courses().studentGroups().create(
courseId=course_id,
body=body
).execute()
print(response)
जवाब में, छात्र-छात्राओं के नए ग्रुप का id, courseId, और title शामिल होता है.
छात्र-छात्राओं के ग्रुप id का इस्तेमाल, छात्र-छात्राओं के अलग-अलग ग्रुप को अपडेट करने या मिटाने के लिए किया जा सकता है.
Python
def update_student_group(classroom_service, course_id, student_group_id):
body = {
"title": "Team Green"
}
response = classroom_service.courses().studentGroups().patch(
courseId=course_id,
id=student_group_id,
body=body,
updateMask="title"
).execute()
print(response)
def delete_student_group(classroom_service, course_id, student_group_id):
response = classroom_service.courses().studentGroups().delete(
courseId=course_id,
id=student_group_id
).execute()
print(response)
ListStudentGroups एंडपॉइंट का इस्तेमाल करके, किसी कोर्स में मौजूद छात्र-छात्राओं के ग्रुप को वापस पाया जा सकता है:
Python
def list_student_groups(classroom_service, course_id):
results = classroom_service.courses().studentGroups().list(
courseId=course_id
).execute()
studentGroups = results.get("studentGroups")
छात्र-छात्राओं के ग्रुप के सदस्यों को मैनेज करना
छात्र-छात्राओं का ग्रुप बन जाने के बाद, उसमें सदस्यों को जोड़ा जा सकता है.
Python
def add_student_group_member(classroom_service, course_id, student_group_id):
body = {
"userId": "student@schooldomain.com"
}
response = classroom_service.courses().studentGroups().studentGroupMembers().create(
courseId=course_id,
studentGroupId=student_group_id,
body=body
).execute()
print(response)
अगर आपको छात्र-छात्राओं के ग्रुप से किसी सदस्य को हटाना है, तो इस तरह का अनुरोध करें:
Python
def delete_student_group_member(classroom_service, course_id, student_group_id):
response = classroom_service.courses().studentGroups().studentGroupMembers().delete(
courseId=course_id,
studentGroupId=student_group_id,
userId="student@schooldomain.com"
).execute()
print(response)
यहां दिए गए अनुरोध को करके, किसी ग्रुप में शामिल सदस्यों के बारे में जानकारी पाई जा सकती है:
Python
def list_student_group_members(classroom_service, course_id, student_group_id):
results = classroom_service.courses().studentGroups().studentGroupMembers().list(
courseId=course_id,
studentGroupId=student_group_id
).execute()
print(results.get("studentGroupMembers"))
हर StudentGroupMember संसाधन में, ग्रुप के सदस्य की courseId, studentGroupId, और userId शामिल होती है.