rubric
คือเทมเพลตที่ครูสามารถใช้เมื่อให้คะแนนงานที่นักเรียนส่ง Classroom API ช่วยให้คุณจัดการเกณฑ์การให้คะแนนเหล่านี้ในนามของครูได้
รูปที่ 1 ดูเกณฑ์การให้คะแนนตัวอย่างในงานของ Classroom
คู่มือนี้จะอธิบายแนวคิดและฟังก์ชันเบื้องต้นของ Rubrics API โปรดดูบทความเหล่านี้ในศูนย์ช่วยเหลือเพื่อดูข้อมูลเกี่ยวกับโครงสร้างทั่วไปของเกณฑ์การให้คะแนนและวิธีการให้คะแนนด้วยเกณฑ์การให้คะแนนใน UI ของ Classroom
ข้อกำหนดเบื้องต้น
คู่มือนี้จะถือว่าคุณมีสิ่งต่อไปนี้
- Python 3.8.6 ขึ้นไป
- เครื่องมือจัดการแพ็กเกจ pip
- โปรเจ็กต์ Google Cloud
- บัญชี Google Workspace for Education ที่เปิดใช้ Google Classroom
- ชั้นเรียนทดสอบที่มีบัญชีนักเรียนทดสอบอย่างน้อย 1 บัญชี หากคุณไม่มีชั้นเรียนใน Classroom ที่ใช้ทดสอบได้ ให้สร้างชั้นเรียนใน UI และเพิ่มนักเรียนทดสอบ
ให้สิทธิ์ข้อมูลเข้าสู่ระบบสำหรับแอปพลิเคชันเดสก์ท็อป
หากต้องการตรวจสอบสิทธิ์เป็นผู้ใช้ปลายทางและเข้าถึงข้อมูลผู้ใช้ในแอป คุณต้องสร้างรหัสไคลเอ็นต์ OAuth 2.0 อย่างน้อย 1 รายการ รหัสไคลเอ็นต์ใช้เพื่อระบุแอปเดียวไปยังเซิร์ฟเวอร์ OAuth ของ Google หากแอปทำงานบนหลายแพลตฟอร์ม คุณต้องสร้างรหัสไคลเอ็นต์แยกกันสำหรับแต่ละแพลตฟอร์ม
- ไปที่หน้าข้อมูลเข้าสู่ระบบ GCP ใน Google Cloud Console
- คลิกสร้างข้อมูลเข้าสู่ระบบ > รหัสไคลเอ็นต์ OAuth
- คลิกประเภทแอปพลิเคชัน > แอปบนเดสก์ท็อป
- ในช่องชื่อ ให้พิมพ์ชื่อของข้อมูลเข้าสู่ระบบ ชื่อนี้จะแสดง ในคอนโซล Google Cloud เท่านั้น เช่น "ไคลเอ็นต์ตัวอย่างเกณฑ์การให้คะแนน"
- คลิกสร้าง หน้าจอที่ไคลเอ็นต์ OAuth สร้างขึ้นจะปรากฏขึ้น โดยแสดงรหัสไคลเอ็นต์และรหัสลับไคลเอ็นต์ใหม่ของคุณ
- คลิกดาวน์โหลด JSON ตามด้วยตกลง ข้อมูลรับรองที่สร้างขึ้นใหม่ จะปรากฏในรหัสไคลเอ็นต์ OAuth 2.0
- บันทึกไฟล์ JSON ที่ดาวน์โหลดเป็น
credentials.json
และย้ายไฟล์ไปยังไดเรกทอรีการทำงาน - คลิกสร้างข้อมูลเข้าสู่ระบบ > คีย์ API และจดบันทึกคีย์ API
โปรดดูสร้างข้อมูลรับรองการเข้าถึงเพื่อเรียนรู้เพิ่มเติม
กำหนดค่าขอบเขต OAuth
คุณอาจต้องกำหนดค่าขอบเขตเพิ่มเติม ทั้งนี้ขึ้นอยู่กับขอบเขต OAuth ที่มีอยู่ของโปรเจ็กต์
- ไปที่หน้าจอขอความยินยอม OAuth
- คลิกแก้ไขแอป > บันทึกและดำเนินการต่อเพื่อไปยังหน้าจอขอบเขต
- คลิกเพิ่มหรือนำขอบเขตออก
- เพิ่มขอบเขตต่อไปนี้หากยังไม่มี
https://www.googleapis.com/auth/classroom.coursework.students
https://www.googleapis.com/auth/classroom.courses
- จากนั้นคลิกอัปเดต > บันทึกและดำเนินการต่อ > บันทึกและดำเนินการต่อ > กลับไปที่หน้าแดชบอร์ด
โปรดดูที่กำหนดค่าหน้าจอคำยินยอม OAuth เพื่อเรียนรู้เพิ่มเติม
ขอบเขต classroom.coursework.students
ให้สิทธิ์อ่านและเขียนเกณฑ์การให้คะแนน (รวมถึงสิทธิ์เข้าถึง CourseWork
) และขอบเขต classroom.courses
อนุญาตหลักสูตรอ่านและเขียน
ขอบเขตที่จำเป็นสำหรับวิธีการที่ระบุจะแสดงอยู่ในเอกสารอ้างอิงสำหรับวิธีการนั้นๆ ดูขอบเขตการให้สิทธิ์ courses.courseWork.rubrics.create
รายการเป็นตัวอย่าง คุณจะดูขอบเขตทั้งหมดของ Classroom ได้ในขอบเขต OAuth 2.0 สำหรับ Google API ไม่มีการกล่าวถึงเกณฑ์การให้คะแนนที่นี่เนื่องจาก API ยังอยู่ในช่วงแสดงตัวอย่าง
กำหนดค่าตัวอย่าง
ติดตั้งไลบรารีของไคลเอ็นต์ Google สำหรับ Python ในไดเรกทอรีการทำงาน
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
สร้างไฟล์ชื่อ main.py
ซึ่งจะสร้างไลบรารีของไคลเอ็นต์และให้สิทธิ์ผู้ใช้ โดยใช้คีย์ API แทน YOUR_API_KEY
ดังนี้
import json
import os.path
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
# If modifying these scopes, delete the file token.json.
SCOPES = ['https://www.googleapis.com/auth/classroom.courses',
'https://www.googleapis.com/auth/classroom.coursework.students']
def build_authenticated_service(api_key):
"""Builds the Classroom service."""
creds = None
# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists('token.json'):
creds = Credentials.from_authorized_user_file('token.json', SCOPES)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
'credentials.json', SCOPES)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run.
with open('token.json', 'w') as token:
token.write(creds.to_json())
try:
# Build the Classroom service.
service = build(
serviceName="classroom",
version="v1",
credentials=creds,
discoveryServiceUrl=f"https://classroom.googleapis.com/$discovery/rest?labels=DEVELOPER_PREVIEW&key={api_key}")
return service
except HttpError as error:
print('An error occurred: %s' % error)
if __name__ == '__main__':
service = build_authenticated_service(YOUR_API_KEY)
เรียกใช้สคริปต์โดยใช้ python main.py
คุณควรได้รับแจ้งให้ลงชื่อเข้าใช้และ
ยินยอมใช้ขอบเขต OAuth
สร้างงาน
เกณฑ์การให้คะแนนจะเชื่อมโยงกับงานหรือ CourseWork
และมีความหมายในบริบทของ CourseWork
เท่านั้น มีเพียงโปรเจ็กต์ Google Cloud ที่สร้างรายการ CourseWork
ระดับบนสุดเท่านั้นที่สร้างเกณฑ์การให้คะแนนได้ สำหรับจุดประสงค์ของคู่มือนี้ โปรดสร้างงาน CourseWork
ใหม่ด้วยสคริปต์
เพิ่มรายการต่อไปนี้ลงใน main.py
def get_latest_course(service):
"""Retrieves the last created course."""
try:
response = service.courses().list(pageSize=1).execute()
courses = response.get("courses", [])
if not courses:
print("No courses found. Did you remember to create one in the UI?")
return
course = courses[0]
return course
except HttpError as error:
print(f"An error occurred: {error}")
return error
def create_coursework(service, course_id):
"""Creates and returns a sample coursework."""
try:
coursework = {
"title": "Romeo and Juliet analysis.",
"description": """Write a paper arguing that Romeo and Juliet were
time travelers from the future.""",
"workType": "ASSIGNMENT",
"state": "PUBLISHED",
}
coursework = service.courses().courseWork().create(
courseId=course_id, body=coursework).execute()
return coursework
except HttpError as error:
print(f"An error occurred: {error}")
return error
อัปเดต main.py
เพื่อเรียกข้อมูล course_id
ของคลาสการทดสอบที่คุณเพิ่งสร้าง สร้างงานตัวอย่างใหม่ และเรียกข้อมูล coursework_id
ของงาน:
if __name__ == '__main__':
service = build_authenticated_service(YOUR_API_KEY)
course = get_latest_course(service)
course_id = course.get("id")
course_name = course.get("name")
print(f"'{course_name}' course ID: {course_id}")
coursework = create_coursework(service, course_id)
coursework_id = coursework.get("id")
print(f"Assignment created with ID {coursework_id}")
#TODO(developer): Save the printed course and coursework IDs.
บันทึกcourse_id
และcoursework_id
ซึ่งจำเป็นสำหรับการดำเนินการ
CRUD เกณฑ์การให้คะแนนทั้งหมด
ตอนนี้คุณควรมีตัวอย่าง CourseWork
ใน Classroom แล้ว
รูปที่ 2 ดูงานตัวอย่างใน Classroom
สร้างเกณฑ์การให้คะแนน
ตอนนี้คุณก็พร้อมเริ่มจัดการเกณฑ์การให้คะแนนแล้ว
คุณสามารถสร้างเกณฑ์การให้คะแนนใน CourseWork
ที่มีการเรียก Create
ที่มีออบเจ็กต์เกณฑ์การให้คะแนนแบบเต็มได้ โดยจะไม่แสดงพร็อพเพอร์ตี้ของรหัสสำหรับเกณฑ์และระดับต่างๆ (ซึ่งจะสร้างขึ้นเมื่อมีการสร้าง)
เพิ่มฟังก์ชันต่อไปนี้ใน main.py
:
def create_rubric(service, course_id, coursework_id):
"""Creates an example rubric on a coursework."""
try:
body = {
"criteria": [
{
"title": "Argument",
"description": "How well structured your argument is.",
"levels": [
{"title": "Convincing",
"description": "A compelling case is made.", "points": 30},
{"title": "Passable",
"description": "Missing some evidence.", "points": 20},
{"title": "Needs Work",
"description": "Not enough strong evidence..", "points": 0},
]
},
{
"title": "Spelling",
"description": "How well you spelled all the words.",
"levels": [
{"title": "Perfect",
"description": "No mistakes.", "points": 20},
{"title": "Great",
"description": "A mistake or two.", "points": 15},
{"title": "Needs Work",
"description": "Many mistakes.", "points": 5},
]
},
{
"title": "Grammar",
"description": "How grammatically correct your sentences are.",
"levels": [
{"title": "Perfect",
"description": "No mistakes.", "points": 20},
{"title": "Great",
"description": "A mistake or two.", "points": 15},
{"title": "Needs Work",
"description": "Many mistakes.", "points": 5},
]
},
]
}
rubric = service.courses().courseWork().rubrics().create(
courseId=course_id, courseWorkId=coursework_id, body=body,
# Specify the preview version. Rubrics CRUD capabilities are
# supported in V1_20231110_PREVIEW and later.
previewVersion="V1_20231110_PREVIEW"
).execute()
print(f"Rubric created with ID {rubric.get('id')}")
return rubric
except HttpError as error:
print(f"An error occurred: {error}")
return error
จากนั้นอัปเดตและเรียกใช้ main.py
เพื่อสร้างเกณฑ์การให้คะแนนตัวอย่าง โดยใช้รหัส Course
และ CourseWork
ของคุณจากก่อนหน้านี้ ดังนี้
if __name__ == '__main__':
service = build_authenticated_service(YOUR_API_KEY)
rubric = create_rubric(service, YOUR_COURSE_ID, YOUR_COURSEWORK_ID)
print(json.dumps(rubric, indent=4))
บางประเด็นเกี่ยวกับการแสดงเกณฑ์การให้คะแนนมีดังนี้
- เกณฑ์และลำดับระดับจะแสดงใน UI ของ Classroom
- ระดับที่มีคะแนน (ที่มีพร็อพเพอร์ตี้
points
) ต้องจัดเรียงตามคะแนนจากน้อยไปมากหรือมากไปน้อย (ไม่สามารถเรียงลำดับแบบสุ่มได้) - ครูสามารถจัดเรียงเกณฑ์และระดับคะแนนใหม่ได้ (แต่ไม่ใช่ระดับที่ไม่มีคะแนน) ใน UI และเปลี่ยนลำดับของข้อมูล
ดูข้อจำกัดสำหรับคำเตือนเพิ่มเติมเกี่ยวกับโครงสร้างเกณฑ์การให้คะแนน
กลับไปที่ UI แล้วคุณจะเห็นเกณฑ์การให้คะแนนในงาน
รูปที่ 3 ดูเกณฑ์การให้คะแนนตัวอย่างในงานของ Classroom
อ่านเกณฑ์การให้คะแนน
อ่านเกณฑ์การให้คะแนนได้ผ่านทางเมธอด List
และ Get
มาตรฐาน
งานมีเกณฑ์การให้คะแนนได้ไม่เกิน 1 รายการ ดังนั้น List
อาจดูใช้การไม่ได้ แต่จะมีประโยชน์หากคุณยังไม่มีรหัสเกณฑ์การให้คะแนน หากไม่มีเกณฑ์การให้คะแนนที่เชื่อมโยงกับ CourseWork
คำตอบ List
จะว่างเปล่า
เพิ่มฟังก์ชันต่อไปนี้ใน main.py
:
def get_rubric(service, course_id, coursework_id):
"""
Get the rubric on a coursework. There can only be at most one.
Returns null if there is no rubric.
"""
try:
response = service.courses().courseWork().rubrics().list(
courseId=course_id, courseWorkId=coursework_id,
# Specify the preview version. Rubrics CRUD capabilities are
# supported in V1_20231110_PREVIEW and later.
previewVersion="V1_20231110_PREVIEW"
).execute()
rubrics = response.get("rubrics", [])
if not rubrics:
print("No rubric found for this assignment.")
return
rubric = rubrics[0]
return rubric
except HttpError as error:
print(f"An error occurred: {error}")
return error
อัปเดตและเรียกใช้ main.py
เพื่อดึงข้อมูลเกณฑ์การให้คะแนนที่คุณเพิ่มไว้
if __name__ == '__main__':
service = build_authenticated_service(YOUR_API_KEY)
rubric = get_rubric(service, YOUR_COURSE_ID, YOUR_COURSEWORK_ID)
print(json.dumps(rubric, indent=4))
#TODO(developer): Save the printed rubric ID.
จดพร็อพเพอร์ตี้ id
ไว้ในเกณฑ์การให้คะแนนสำหรับขั้นตอนถัดไป
Get
จะทำงานได้ดีเมื่อคุณมีรหัสเกณฑ์การให้คะแนน การใช้ Get
ในฟังก์ชันแทนอาจมีลักษณะดังนี้
def get_rubric(service, course_id, coursework_id, rubric_id):
"""
Get the rubric on a coursework. There can only be at most one.
Returns a 404 if there is no rubric.
"""
try:
rubric = service.courses().courseWork().rubrics().get(
courseId=course_id,
courseWorkId=coursework_id,
id=rubric_id,
# Specify the preview version. Rubrics CRUD capabilities are
# supported in V1_20231110_PREVIEW and later.
previewVersion="V1_20231110_PREVIEW"
).execute()
return rubric
except HttpError as error:
print(f"An error occurred: {error}")
return error
การติดตั้งใช้งานนี้จะแสดงผล 404 หากไม่มีเกณฑ์การให้คะแนน
อัปเดตเกณฑ์การให้คะแนน
อัปเดตเกณฑ์การให้คะแนนด้วยการโทร Patch
รายการ เนื่องจากโครงสร้างที่ซับซ้อนของเกณฑ์การให้คะแนน แอปจึงต้องอัปเดตโดยใช้รูปแบบ Read-modify-write ซึ่งจะมีการแทนที่พร็อพเพอร์ตี้ criteria
ทั้งหมด
กฎการอัปเดตมีดังนี้
- เกณฑ์หรือระดับที่เพิ่มโดยไม่มีรหัสจะถือว่าเป็นการเพิ่ม
- เกณฑ์หรือระดับที่ไม่มีจากก่อนหน้าจะถือว่าเป็นการลบ
- เกณฑ์หรือระดับที่มีรหัสที่มีอยู่แต่ข้อมูลที่แก้ไขถือว่าเป็นการแก้ไข พร็อพเพอร์ตี้ที่ไม่มีการแก้ไขจะปล่อยไว้ตามเดิม
- เกณฑ์หรือระดับที่ได้รับมาพร้อมกับรหัสใหม่หรือรหัสที่ไม่รู้จักจะถือว่าเป็นข้อผิดพลาด
- ลำดับของเกณฑ์และระดับใหม่จะถือว่าเป็นลำดับ UI ใหม่ (ตามข้อจำกัดที่ได้กล่าวไปแล้ว)
เพิ่มฟังก์ชันสำหรับอัปเดตเกณฑ์การให้คะแนน
def update_rubric(service, course_id, coursework_id, rubric_id, body):
"""
Updates the rubric on a coursework.
"""
try:
rubric = service.courses().courseWork().rubrics().patch(
courseId=course_id,
courseWorkId=coursework_id,
id=rubric_id,
body=body,
updateMask='criteria',
# Specify the preview version. Rubrics CRUD capabilities are
# supported in V1_20231110_PREVIEW and later.
previewVersion="V1_20231110_PREVIEW"
).execute()
return rubric
except HttpError as error:
print(f"An error occurred: {error}")
return error
ในตัวอย่างนี้มีการระบุช่อง criteria
สำหรับการแก้ไขด้วย updateMask
จากนั้นแก้ไข main.py
เพื่อเปลี่ยนแปลงกฎการอัปเดตแต่ละข้อที่กล่าวถึงก่อนหน้านี้
if __name__ == '__main__':
service = build_authenticated_service(YOUR_API_KEY)
# Get the latest rubric.
rubric = get_rubric(service, YOUR_COURSE_ID, YOUR_COURSEWORK_ID)
criteria = rubric.get("criteria")
"""
The "criteria" property should look like this:
[
{
"id": "NkEyMdMyMzM2Nxkw",
"title": "Argument",
"description": "How well structured your argument is.",
"levels": [
{
"id": "NkEyMdMyMzM2Nxkx",
"title": "Convincing",
"description": "A compelling case is made.",
"points": 30
},
{
"id": "NkEyMdMyMzM2Nxky",
"title": "Passable",
"description": "Missing some evidence.",
"points": 20
},
{
"id": "NkEyMdMyMzM2Nxkz",
"title": "Needs Work",
"description": "Not enough strong evidence..",
"points": 0
}
]
},
{
"id": "NkEyMdMyMzM2Nxk0",
"title": "Spelling",
"description": "How well you spelled all the words.",
"levels": [...]
},
{
"id": "NkEyMdMyMzM2Nxk4",
"title": "Grammar",
"description": "How grammatically correct your sentences are.",
"levels": [...]
}
]
"""
# Make edits. This example will make one of each type of change.
# Add a new level to the first criteria. Levels must remain sorted by
# points.
new_level = {
"title": "Profound",
"description": "Truly unique insight.",
"points": 50
}
criteria[0]["levels"].insert(0, new_level)
# Remove the last criteria.
del criteria[-1]
# Update the criteria titles with numeric prefixes.
for index, criterion in enumerate(criteria):
criterion["title"] = f"{index}: {criterion['title']}"
# Resort the levels from descending to ascending points.
for criterion in criteria:
criterion["levels"].sort(key=lambda level: level["points"])
# Update the rubric with a patch call.
new_rubric = update_rubric(
service, YOUR_COURSE_ID, YOUR_COURSEWORK_ID, YOUR_RUBRIC_ID, rubric)
print(json.dumps(new_rubric, indent=4))
การเปลี่ยนแปลงควรปรากฏต่อครูใน Classroom
รูปที่ 4 มุมมองเกณฑ์การให้คะแนนที่อัปเดตแล้ว
ดูงานที่ให้คะแนนตามเกณฑ์การให้คะแนน
ขณะนี้ API จะให้คะแนนงานที่นักเรียนส่งด้วยเกณฑ์การให้คะแนนไม่ได้ แต่คุณสามารถอ่านคะแนนคร่าวๆ ของงานที่ส่งที่มีการให้คะแนนด้วยเกณฑ์การให้คะแนนใน UI ของ Classroom ได้
ในฐานะนักเรียนใน UI ของ Classroom ให้ดำเนินการให้เสร็จและส่งงานตัวอย่าง จากนั้นในฐานะครู ให้ให้คะแนนงานโดยใช้เกณฑ์การให้คะแนนด้วยตนเอง
รูปที่ 5 มุมมองของครูระหว่างการให้คะแนน
งานที่ส่งโดยนักเรียนที่ได้รับการให้คะแนนด้วยเกณฑ์การให้คะแนนจะมีพร็อพเพอร์ตี้ใหม่ 2 รายการ ได้แก่ draftRubricGrades
และ assignedRubricGrades
ซึ่งแสดงถึงคะแนนและระดับที่ครูเลือกระหว่างสถานะการตัดเกรดฉบับร่างและที่มอบหมายแล้วตามลำดับ
นอกจากนี้ งานที่นักเรียนส่งซึ่งมีเกณฑ์การให้คะแนนที่เกี่ยวข้องจะมีช่อง rubricId
ด้วย แม้กระทั่งก่อนการให้คะแนน ค่านี้แสดงเกณฑ์การให้คะแนนล่าสุดที่เชื่อมโยงกับ CourseWork
และค่านี้อาจเปลี่ยนแปลงหากครูลบและสร้างเกณฑ์การให้คะแนนขึ้นใหม่
คุณจะใช้เมธอด studentSubmissions.Get
และ studentSubmissions.List
ที่มีอยู่เพื่อดูงานที่ให้คะแนนแล้วได้
เพิ่มฟังก์ชันต่อไปนี้ใน main.py
เพื่อแสดงงานที่นักเรียนส่ง
def get_latest_submission(service, course_id, coursework_id):
"""Retrieves the last submission for an assignment."""
try:
response = service.courses().courseWork().studentSubmissions().list(
courseId = course_id,
courseWorkId = coursework_id,
pageSize=1,
# Specify the preview version. Rubrics CRUD capabilities are
# supported in V1_20231110_PREVIEW and later.
previewVersion="V1_20231110_PREVIEW"
).execute()
submissions = response.get("studentSubmissions", [])
if not submissions:
print(
"""No submissions found. Did you remember to turn in and grade
the assignment in the UI?""")
return
submission = submissions[0]
return submission
except HttpError as error:
print(f"An error occurred: {error}")
return error
จากนั้นอัปเดตและเรียกใช้ main.py
เพื่อดูคะแนนที่ส่ง
if __name__ == '__main__':
service = build_authenticated_service(YOUR_API_KEY)
submission = get_latest_submission(
service, YOUR_COURSE_ID, YOUR_COURSEWORK_ID)
print(json.dumps(submission, indent=4))
draftRubricGrades
และ assignedRubricGrades
ประกอบด้วย
criterionId
ของเกณฑ์เกณฑ์การให้คะแนนที่เกี่ยวข้องpoints
ที่ครูมอบหมายให้สำหรับเกณฑ์แต่ละรายการ ซึ่งอาจมาจากระดับที่เลือก แต่ครูสามารถเขียนทับได้levelId
ของระดับที่เลือกสำหรับเกณฑ์แต่ละรายการ หากครูไม่ได้เลือกระดับ แต่ยังคงให้คะแนนสำหรับเกณฑ์ดังกล่าว ช่องนี้จะไม่แสดง
รายการเหล่านี้มีเฉพาะรายการสำหรับเกณฑ์ที่ครูเลือกระดับหรือกำหนดคะแนน เช่น หากครูเลือกที่จะโต้ตอบกับเกณฑ์เพียง 1 เกณฑ์ในระหว่างการให้คะแนน ระหว่างการให้คะแนน draftRubricGrades
และ assignedRubricGrades
จะมีเพียง 1 รายการเท่านั้น แม้ว่าเกณฑ์การให้คะแนนดังกล่าวจะมีหลายเกณฑ์ก็ตาม
ลบเกณฑ์การให้คะแนน
คุณลบเกณฑ์การให้คะแนนได้ด้วยคำขอ Delete
มาตรฐาน โค้ดต่อไปนี้แสดงตัวอย่างฟังก์ชันความสมบูรณ์ แต่เนื่องจากการให้คะแนนเริ่มขึ้นแล้ว คุณจึงไม่สามารถลบเกณฑ์การให้คะแนนปัจจุบันได้
def delete_rubric(service, course_id, coursework_id, rubric_id):
"""Deletes the rubric on a coursework."""
try:
service.courses().courseWork().rubrics().delete(
courseId=course_id,
courseWorkId=coursework_id,
id=rubric_id,
# Specify the preview version. Rubrics CRUD capabilities are
# supported in V1_20231110_PREVIEW and later.
previewVersion="V1_20231110_PREVIEW"
).execute()
except HttpError as error:
print(f"An error occurred: {error}")
return error
ส่งออกและนําเข้าเกณฑ์การให้คะแนน
คุณสามารถส่งออกเกณฑ์การให้คะแนนไปยังสเปรดชีตของ Google ด้วยตนเองเพื่อให้ครูนำไปใช้ซ้ำได้
นอกจากการระบุเกณฑ์เกณฑ์การให้คะแนนในโค้ดแล้ว คุณยังสร้างและอัปเดตเกณฑ์การให้คะแนนจากชีตที่ส่งออกเหล่านี้ได้โดยระบุ sourceSpreadsheetId
ในเนื้อหาเกณฑ์การให้คะแนนแทน criteria
ดังนี้
def create_rubric_from_sheet(service, course_id, coursework_id, sheet_id):
"""Creates an example rubric on a coursework."""
try:
body = {
"sourceSpreadsheetId": sheet_id
}
rubric = service.courses().courseWork().rubrics().create(
courseId=course_id, courseWorkId=coursework_id, body=body,
# Specify the preview version. Rubrics CRUD capabilities are
# supported in V1_20231110_PREVIEW and later.
previewVersion="V1_20231110_PREVIEW"
).execute()
print(f"Rubric created with ID {rubric.get('id')}")
return rubric
except HttpError as error:
print(f"An error occurred: {error}")
return error
ความคิดเห็น
หากคุณพบปัญหาหรือมีความคิดเห็น โปรดแชร์ความคิดเห็นของคุณ