本文介绍了是否有Classroom.Courses.Topics.get的示例,所以我可以使用现有的topicId调用Classroom.Courses.CourseWork.create?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们学校正在尝试将所有课程作业在线转移.我们有八名老师将内容添加到一个班级,主要是手动而不是使用脚本.我有一个JavaScript脚本,可基于电子表格的行创建课程作业.如果可能,我希望在Coursework数据电子表格的每一行中以字符串形式显示主题,例如在数学周1"中,使用Classroom.Courses.Topics.get获取主题,然后将主题中的topicId写入CourseWork.

Our school is trying to move all coursework online. We have eight teachers adding content to one class, mostly manually rather than with a script. I have a javascript script that creates Coursework based on rows of a spreadsheet. If possible, I would like to have the topic as a string in each row of the spreadsheet of Coursework data, e.g. "Math Week 1", use Classroom.Courses.Topics.get to get the topic, then write the topicId from the topic into CourseWork.

我在StackOverflow上找到了创建主题的代码.我尝试了Classroom.Courses.Topics.get的许多变体,但始终会收到未找到请求的实体"的错误. (第14行,文件"createTopics")这是我尝试过的一些方法:我之前创建了"fakeTopic3:使用Classroom.Courses.Topics.create

I found code on StackOverflow to create a topic. I've tried many variations of Classroom.Courses.Topics.get but always get the error Requested entity was not found. (line 14, file "createTopics")Here are some of the methods I've tried:I previously created "fakeTopic3: using Classroom.Courses.Topics.create

   var topicName = "fakeTopic3";
   var getTopic2= Classroom.Courses.Topics.get(courseId,{name:topicName} )
   var getTopic= Classroom.Courses.Topics.get(courseId,topicName )
   var getTopic = Classroom.Courses.Topics.get({name:topicName},courseId );
   var getTopic = Classroom.Courses.Topics.get(topicName,courseId );

推荐答案

答案:

您需要使用courses.topics.list 与课程ID一起获取主题ID的列表,然后使用主题ID代替courses.topics.get 调用.

courses.topics.get方法的文档中所述:

因此,您只需提供 course IDtopic ID.

So you need to supply only the course ID and the topic ID.

var coursesList = Classroom.Courses.list();
var topicName = "your topic's name";
var courseId = "your course's ID";
  
for (var i = 0; i < coursesList.courses.length; i++) {
  if (coursesList.courses[i].name == topicName) {
    var topicId = coursesList.courses[i].id;
    break;
  }    
}

var getTopic = Classroom.Courses.Topics.get(courseId. topicId);    

希望对您有帮助!

  1. 方法:courses.topics.list
  2. 方法:courses.topics.get

这篇关于是否有Classroom.Courses.Topics.get的示例,所以我可以使用现有的topicId调用Classroom.Courses.CourseWork.create?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 17:19