Google 课堂插件现已面向开发者正式推出!如需了解详情,请参阅
插件文档。
附件发现 iframe
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
附件发现 iframe 是教师在创建 Google 课堂任务期间打开插件时看到的初始视图。附件是指您希望学生互动的内容或活动。
在 Google 课堂课程中,教师创建新帖子(例如作业、通知或题目),然后从插件下拉列表中选择一个插件(图 1)。
图 1. 作业创建视图,包括教师可以附加的可能插件选项。
教师选择插件后,Classroom 会创建一个附件发现 iframe 并加载插件的启动网址。所有相关的 iframe 查询参数都会传递给启动网址(图 2)。

图 2. iframe 中的附件发现界面示例。
您可以将附件发现视图视为插件中教师的着陆页。通常,教师会在 iframe 中使用合作伙伴的 Web 应用来选择要附加到其动态项目的内容。插件应用可能会根据信息流项是通知、作业还是课程资料来限制显示的内容。然后,插件应用会进行 Classroom API 调用,以创建附件并将其附加到作业。
当教师完成附件的选择和创建后,插件会发送 postMessage
载荷,请求关闭 iframe。iframe 关闭,然后教师会看到附件,之后他们可以选择预览或从作业中移除附件(图 3)。教师通过向学生布置信息流项目来完成创建流程。

图 3. 包含三个活动类型插件附件的作业创建视图。
用户体验注意事项
- 在首次打开时,该插件必须提示教师登录。
- 所有 Classroom API 调用都需要使用 Google 单点登录。如果您的产品有单独的登录系统,您必须关联账号。
- 教师必须能够在 iframe 中预览附件,然后才能做出最终选择。
- 教师应能够搜索或浏览可附加的内容。
- 该插件可能会提供各种视图,例如“近期内容”“我的内容”以及按学习技能过滤。
- 该插件必须能够从 iframe 内创建新的可附加项。
如需详细了解用户体验要求,请参阅 Google 课堂插件要求清单。
许可状态
如果您的插件需要产品许可,则应显示明确的消息,说明没有许可的教师如何解决此问题。此外,还应考虑隐藏或停用因许可限制而无法供教师使用的内容。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# Attachment Discovery iframe\n\nThe **Attachment Discovery iframe** is the initial view shown to a teacher when\nopening an add-on during the creation of a\nClassroom task. An\n**attachment** is the content or activity that you intend for students to\ninteract with.\n\nFrom within a Classroom course, a teacher creates a new post (for\nexample, an assignment, announcement, or question) and selects an\nadd-on from the add-on\ndrop-down list (Figure 1).\n\n**Figure 1.** View of an assignment\ncreation including the possible add-on options a\nteacher can attach.\n\nOnce a teacher selects an add-on,\nClassroom creates an Attachment Discovery iframe and loads the\nadd-on's launch URL. Any relevant [iframe query\nparameters](/workspace/classroom/add-ons/developer-guides/iframes) are passed to the launch URL (Figure 2).\n\n**Figure 2.** An example of an **attachment discovery** UI in an iframe.\n\nThink of the Attachment Discovery view as the landing page for teachers in your\nadd-on. Typically, the teacher uses the partner's web\napplication within the iframe to select content to attach to their stream item.\nThe add-on application might restrict which content is\nshown depending on whether the stream item is an announcement, assignment, or\ncourse material. The add-on application then makes\nClassroom API calls to create and attach the attachment to the\nassignment.\n\nWhen the teacher is finished selecting and creating attachments, the\nadd-on sends a `postMessage` payload requesting the\niframe to be closed. The iframe closes and the teacher then sees the\nattachments, which they might then choose to preview or remove from the\nassignment (Figure 3). The teacher completes the creation flow by assigning the\nstream item to their students.\n\n**Figure 3.** View of an assignment creation with three activity-type\nadd-on attachments.\n\nUser experience considerations\n------------------------------\n\n- On initial opening, the add-on must prompt the teacher to sign in.\n- Google single sign-on is required for all Classroom API calls. If your product has a separate login system, you must link accounts.\n- A teacher must be able to preview an attachment within the iframe before making their final selection.\n- A teacher should be able to search for, or browse through, attachable content.\n- The add-on may provide a variety of views such as recent content, my content, and filter by learning skills.\n- The add-on must provide an ability to create a new attachable item from within the iframe.\n\nSee the Classroom add-on [requirements checklist](/workspace/classroom/add-ons/requirements) for more details\non user experience requirements.\n\nLicensing status\n----------------\n\nIf your add-on requires a license to your product, a\nclear message should be shown to explain how a teacher without a license can\nremedy the situation. Consider also hiding or disabling content that's not\navailable to a teacher due to licensing restrictions."]]