-
Notifications
You must be signed in to change notification settings - Fork 921
added four first classroom course snippets #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
I signed it! |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Off to a good start! I've added a bunch of comments, please take a look.
FYI, it looks like you're committing this to the wrong repo. Apps Script Samples should go here:
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
// [START classroom_quickstart] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These START and END comments must use unique names. This should be something like "classroom_update_course" in this case. Fix here and for the other samples.
course['room'] = '302'; | ||
var course = Classroom.Courses.update(body=course, id=course_id); | ||
Logger.log('Course "%s" updated.', course.name); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are missing the END comment.
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
// [START classroom_quickstart] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For our other snippets we've been excluding the method signature and only including the body of the method.
*/ | ||
function courseUpdate() { | ||
var course_id = '123456'; | ||
var course = Classroom.Courses.get(id=course_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The id=course_id
format doesn't work as intended in Apps Script / JavaScript. Just pass course_id
directly. Ditto for other samples.
var course = Classroom.Courses.get(id=course_id); | ||
Logger.log('Course %s found. ', course.name); | ||
} | ||
catch (err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be on the same line as the closing brace (}
).
var course_id = '123456'; | ||
try { | ||
var course = Classroom.Courses.get(id=course_id); | ||
Logger.log('Course %s found. ', course.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surround the name with quotes.
Logger.log('Course %s found. ', course.name); | ||
} | ||
catch (err) { | ||
Logger.log("Course with id %s not found", course_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surround the ID with quotes.
while (true) { | ||
var response = Classroom.Courses.list(optionalArgs); | ||
var courses = response['courses']; | ||
if (! page_token) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No space between the bang (!
) and the variable.
} | ||
else { | ||
Logger.log("Courses:"); | ||
for (course in courses) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We avoid using for-in loops. Use a traditional for loop or courses.forEach()
@@ -0,0 +1,32 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can put all of these snippets into one file, perhaps called courseSnippets.gs
.
Hi @lesley2958, |
@grant submitted a new PR to the proper repo here! googleworkspace/apps-script-samples#82 |
No description provided.