Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
934 views
in Technique[技术] by (71.8m points)

google apps script - How to assign correct answers to checkboxGridItem questions in a quiz?

One issue with using Google Forms to make a multiple choice quiz is that if a question has (for example) 3 points and 3 out of 5 correct answers, if a student only selects 2 of the 3 correct answers they will get 0 points, not 2.

The workaround for this is to use a checkboxGrid with only 1 column where each row is an answer choice. Points can then be awarded for each correctly selected row.

I'm at a point where I want to create revision quizzes on the fly using this method, a snippet of my code that does this is here:

   var question = questions[Math.floor(Math.random() * questions.length)];
   var item = tasks.addCheckboxGridItem();
   item.setTitle(question[1]);
   item.setRows([ question[3],question[4],question[5],question[6],question,[7],question[8],question[9] ]);
   item.setColumns(['Click if correct']);

I'm at a loss as to assign the correct answer and points to specific rows. I can see how to do this for a simple multiple choice question but not for this checkBoxgrid.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Issue:

GridItem and CheckboxGridItem currently don't support scoring. You cannot assign correct answers and points for these Items using Apps Script (e.g. createChoice(value, isCorrect), .setPoints(points)), nor retrieve this information (e.g. .isCorrectAnswer(), .getPoints(), .getScore()).

Feature Request:

There's currently a Feature Request related to this in Issue Tracker:

I'd suggest you to click the star on the top-left of the page in order to keep track of this and to help priorizing it.

Workaround:

In the meantime, your only options would be to use the UI instead, or to write a grading function yourself, as explained in the referenced issue:

- Find your Grid Item and grab it's ItemResponse.
- Then get the response array.
- Compare it to some grading function you create.
- Return a score and use that number instead.

Of course, this workaround wouldn't add the scoring system to the Form itself, but it would be a way to handle quiz points programmatically.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...