Öğrenci grupları oluşturma ve yönetme

Öğrencileri belirli gruplara ayırarak hedeflenmiş ödevler ve ortak çalışmalar gibi gelişmiş öğretim deneyimleri sunmak için öğrenci gruplarını kullanabilirsiniz. Classroom API'yi kullanarak yöneticiler ve öğretmenler adına bir kurstaki öğrenci gruplarını oluşturabilir, değiştirebilir ve okuyabilirsiniz.

Aşağıdaki yöntemleri kullanarak öğrenci grupları oluşturabilir, güncelleyebilir, silebilir ve okuyabilirsiniz:

Ayrıca, aşağıdaki yöntemleri kullanarak öğrenci grubuna üye ekleyebilir, üyeleri kaldırabilir ve üyeleri okuyabilirsiniz:

Lisanslama ve uygunluk koşulları

Bir kursta öğrenci grupları oluşturmak, değiştirmek veya silmek ve öğrenci gruplarına üye eklemek ya da üye kaldırmak için aşağıdaki koşulların karşılanması gerekir:

Öğrenci gruplarını ve üyelerini okuma

Bir kursun yöneticileri ve öğretmenleri, hangi lisansın atandığına bakılmaksızın öğrenci grubu verilerini okuyabilir. Bu, ListStudentGroups ve ListStudentGroupMembers uç noktalarına yapılan isteklerin, kurstaki herhangi bir yönetici veya öğretmen adına izin verildiği anlamına gelir.

Kod örneği ön koşulları

Bu kılavuzda Python dilinde kod örnekleri verilmektedir ve aşağıdaki şartları karşıladığınız varsayılmaktadır:

  • Google Cloud projesi. Python hızlı başlangıç bölümündeki talimatları uygulayarak bir tane oluşturabilirsiniz.
  • Projenizin OAuth kullanıcı rızası ekranına aşağıdaki kapsamları eklediyseniz:
    • https://www.googleapis.com/auth/classroom.rosters
    • Salt okunur uç noktalar için https://www.googleapis.com/auth/classroom.rosters.readonly.
  • Öğrenci gruplarının yönetilmesi gereken bir kursun kimliği. Kurs sahibinin Google Workspace for Education Plus lisansı olmalıdır.
  • Google Workspace for Education Plus lisansına sahip bir öğretmenin veya yöneticinin kimlik bilgilerine erişim

Kullanıcı uygunluğunu kontrol etme

Classroom API, kullanıcının öğrenci grupları oluşturup değiştirebileceğini ve bu grupların üyelerini proaktif olarak belirlemenize yardımcı olmak için userProfiles.checkUserCapability uç noktasını sağlar. Bu yöntem, Geliştirici Önizleme Programı üzerinden kullanılabilir. Başlangıç noktası olarak Python hızlı başlangıç kılavuzunu kullandıysanız önizleme yöntemlerine erişebilen yeni bir Classroom hizmeti oluşturun:

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 uç noktası yalnızca kullanıcının belirli bir özelliği (ör. öğrenci gruplarını değiştirme) kullanmaya uygun olup olmadığını değerlendirir. Kurs rolü hakkında bilgi vermez. Örneğin, bir kullanıcının CREATE_STUDENT_GROUP özelliği olsa bile kursta öğrenciyse CreateStudentGroup uç noktasına yapılan istek başarılı olmaz.

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.")

Öğrenci gruplarını yönetme

Öğrenci grupları, CreateStudentGroup uç noktası kullanılarak oluşturulabilir.

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)

Yanıt, yeni oluşturulan öğrenci grubunun id, courseId ve öğrenci grubu title bilgilerini içerir.

Öğrenci grubu id, tek tek öğrenci gruplarını güncellemek veya silmek için kullanılabilir.

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)

Bir kurstaki öğrenci gruplarını ListStudentGroups uç noktasını kullanarak alabilirsiniz:

Python

def list_student_groups(classroom_service, course_id):
    results = classroom_service.courses().studentGroups().list(
        courseId=course_id
    ).execute()

    studentGroups = results.get("studentGroups")

Öğrenci grubu üyelerini yönetme

Öğrenci grubu başarıyla oluşturulduktan sonra gruba üye ekleyebilirsiniz.

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)

Bir öğrenci grubundan üye kaldırmak istiyorsanız aşağıdaki gibi bir istekte bulunun:

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)

Aşağıdaki isteği göndererek bir gruptaki üyeleri okuyabilirsiniz:

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"))

Her StudentGroupMember kaynağı, grup üyesinin courseId, studentGroupId ve userId bilgilerini içerir.