Mantieni tutto organizzato con le raccolte Salva e classifica i contenuti in base alle tue preferenze.
ItemResponse
Una risposta a un elemento di domanda all'interno di un modulo. È possibile accedere alle risposte agli elementi da FormResponse e crearle da qualsiasi Item che chieda al rispondente di rispondere a una domanda.
// Open a form by ID and log the responses to each question.constform=FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');constformResponses=form.getResponses();for(leti=0;i < formResponses.length;i++){constformResponse=formResponses[i];constitemResponses=formResponse.getItemResponses();for(letj=0;j < itemResponses.length;j++){constitemResponse=itemResponses[j];Logger.log('Response #%s to the question "%s" was "%s"',(i+1).toString(),itemResponse.getItem().getTitle(),itemResponse.getResponse(),);}}
Imposta il punteggio per la risposta inviata dal partecipante.
Documentazione dettagliata
getFeedback()
Recupera il feedback fornito per la risposta inviata dal rispondente.
Invio
Object: un QuizFeedback per l'elemento della domanda
Autorizzazione
Gli script che utilizzano questo metodo richiedono l'autorizzazione con uno o più dei seguenti ambiti:
https://www.googleapis.com/auth/forms.currentonly
https://www.googleapis.com/auth/forms
getItem()
Recupera l'elemento della domanda a cui risponde questa risposta.
Invio
Item: l'elemento della domanda a cui risponde questa risposta
Autorizzazione
Gli script che utilizzano questo metodo richiedono l'autorizzazione con uno o più dei seguenti ambiti:
https://www.googleapis.com/auth/forms.currentonly
https://www.googleapis.com/auth/forms
getResponse()
Recupera la risposta inviata dal rispondente. Per la maggior parte dei tipi di elementi di domanda, viene restituito un valore String.
Per le domande CheckboxItem, restituisce un array String[] contenente le scelte del rispondente. L'ordine delle stringhe nell'array può variare.
Per le domande GridItem, restituisce un array String[] in cui la risposta all'indice n corrisponde alla domanda nella riga n + 1 della griglia. Se un rispondente non ha risposto a una domanda nella griglia, la risposta viene restituita come ''.
Per le domande CheckboxGridItem, restituisce un array String[][] in cui le risposte all'indice di riga n corrispondono alla domanda nella riga n + 1 della griglia di caselle di controllo. Se un rispondente non ha risposto a una domanda nella griglia, la risposta viene restituita come ''.
Invio
Object: un String, un String[] o un String[][] di risposte all'elemento della domanda
Autorizzazione
Gli script che utilizzano questo metodo richiedono l'autorizzazione con uno o più dei seguenti ambiti:
https://www.googleapis.com/auth/forms.currentonly
https://www.googleapis.com/auth/forms
getScore()
Recupera il punteggio della risposta inviata dal partecipante.
Invio
Object: un Double che rappresenta il punteggio per l'elemento della domanda
Autorizzazione
Gli script che utilizzano questo metodo richiedono l'autorizzazione con uno o più dei seguenti ambiti:
https://www.googleapis.com/auth/forms.currentonly
https://www.googleapis.com/auth/forms
setFeedback(feedback)
Imposta il feedback da visualizzare per la risposta inviata dal rispondente.
Questo metodo non salva effettivamente il feedback in Moduli finché non viene chiamato Form.submitGrades(responses) con le risposte del modulo aggiornate. Per un esempio, vedi setScore().
Gli script che utilizzano questo metodo richiedono l'autorizzazione con uno o più dei seguenti ambiti:
https://www.googleapis.com/auth/forms.currentonly
https://www.googleapis.com/auth/forms
setScore(score)
Imposta il punteggio per la risposta inviata dal partecipante. Un valore nullo comporta l'eliminazione del voto esistente.
Questo metodo non salva effettivamente il punteggio in Moduli finché non viene chiamato Form.submitGrades(responses) con le risposte ai moduli aggiornate.
// For a multiple choice question with options: "Always true", "Sometimes true",// and "Never", award half credit for responses that answered "Sometimes true".constformResponses=FormApp.getActiveForm().getResponses();// Go through each form responsefor(leti=0;i < formResponses.length;i++){constresponse=formResponses[i];constitems=FormApp.getActiveForm().getItems();// Assume it's the first itemconstitem=items[0];constitemResponse=response.getGradableResponseForItem(item);// Give half credit for "Sometimes true".if(itemResponse!=null && itemResponse.getResponse()==='Sometimes true'){constpoints=item.asMultipleChoiceItem().getPoints();itemResponse.setScore(points*0.5);// This saves the grade, but does not submit to Forms yet.response.withItemGrade(itemResponse);}}// Grades are actually submitted to Forms here.FormApp.getActiveForm().submitGrades(formResponses);
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-26 UTC."],[[["\u003cp\u003eAn \u003ccode\u003eItemResponse\u003c/code\u003e represents an answer to a single question within a Google Form.\u003c/p\u003e\n"],["\u003cp\u003eYou can access individual item responses through a \u003ccode\u003eFormResponse\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eItemResponse\u003c/code\u003e objects provide methods to get and set feedback and scores for answers, as well as retrieve the question itself and the respondent's answer.\u003c/p\u003e\n"],["\u003cp\u003eScores and feedback set using \u003ccode\u003eItemResponse\u003c/code\u003e methods must be saved to the form using \u003ccode\u003eForm.submitGrades()\u003c/code\u003e to take effect.\u003c/p\u003e\n"]]],[],null,["ItemResponse\n\nA response to one question item within a form. Item responses can be accessed from [FormResponse](/apps-script/reference/forms/form-response) and created from any [Item](/apps-script/reference/forms/item) that asks the respondent to answer a question.\n\n```javascript\n// Open a form by ID and log the responses to each question.\nconst form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');\nconst formResponses = form.getResponses();\nfor (let i = 0; i \u003c formResponses.length; i++) {\n const formResponse = formResponses[i];\n const itemResponses = formResponse.getItemResponses();\n for (let j = 0; j \u003c itemResponses.length; j++) {\n const itemResponse = itemResponses[j];\n Logger.log(\n 'Response #%s to the question \"%s\" was \"%s\"',\n (i + 1).toString(),\n itemResponse.getItem().getTitle(),\n itemResponse.getResponse(),\n );\n }\n}\n``` \n\nMethods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------|-------------------------------------------|-----------------------------------------------------------------------------------|\n| [getFeedback()](#getFeedback()) | `Object` | Gets the feedback that was given for the respondent's submitted answer. |\n| [getItem()](#getItem()) | [Item](/apps-script/reference/forms/item) | Gets the question item that this response answers. |\n| [getResponse()](#getResponse()) | `Object` | Gets the answer that the respondent submitted. |\n| [getScore()](#getScore()) | `Object` | Gets the score for the respondent's submitted answer. |\n| [setFeedback(feedback)](#setFeedback(Object)) | [ItemResponse](#) | Sets the feedback that should be displayed for the respondent's submitted answer. |\n| [setScore(score)](#setScore(Object)) | [ItemResponse](#) | Sets the score for the respondent's submitted answer. |\n\nDetailed documentation \n\n`get``Feedback()` \nGets the feedback that was given for the respondent's submitted answer.\n\nReturn\n\n\n`Object` --- a `Quiz``Feedback` for the question item\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/forms.currentonly`\n- `https://www.googleapis.com/auth/forms`\n\n*** ** * ** ***\n\n`get``Item()` \nGets the question item that this response answers.\n\nReturn\n\n\n[Item](/apps-script/reference/forms/item) --- the question item that this response answers\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/forms.currentonly`\n- `https://www.googleapis.com/auth/forms`\n\n*** ** * ** ***\n\n`get``Response()` \nGets the answer that the respondent submitted. For most types of question items, this returns a\n`String`.\n\nFor [CheckboxItem](/apps-script/reference/forms/checkbox-item) questions, this returns a `String[]` array containing the\nresponder's choices. The order of the strings in the array may vary.\n\nFor [GridItem](/apps-script/reference/forms/grid-item) questions, this returns a `String[]` array in which the answer at\nindex `n` corresponds to the question at row `n + 1` in the grid. If a respondent\ndid not answer a question in the grid, that answer is returned as `''`.\n\nFor [CheckboxGridItem](/apps-script/reference/forms/checkbox-grid-item) questions, this returns a `String[][]` array in which the\nanswers at row index `n` corresponds to the question at row `n + 1` in the checkbox\ngrid. If a respondent did not answer a question in the grid, that answer is returned as `''`.\n\nReturn\n\n\n`Object` --- a `String` or `String[]` or `String[][]` of answers to the question\nitem\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/forms.currentonly`\n- `https://www.googleapis.com/auth/forms`\n\n*** ** * ** ***\n\n`get``Score()` \nGets the score for the respondent's submitted answer.\n\nReturn\n\n\n`Object` --- a `Double` representing the score for the question item\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/forms.currentonly`\n- `https://www.googleapis.com/auth/forms`\n\n*** ** * ** ***\n\n`set``Feedback(feedback)` \nSets the feedback that should be displayed for the respondent's submitted answer.\n\nThis method does not actually save the feedback in Forms until [Form.submitGrades(responses)](/apps-script/reference/forms/form#submitGrades(FormResponse)) is called with the updated FormResponses. See `set``Score()` for an example.\n\nParameters\n\n| Name | Type | Description |\n|------------|----------|-------------|\n| `feedback` | `Object` | |\n\nReturn\n\n\n[ItemResponse](#) --- a `Item``Response` for chaining\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/forms.currentonly`\n- `https://www.googleapis.com/auth/forms`\n\n*** ** * ** ***\n\n`set``Score(score)` \nSets the score for the respondent's submitted answer. A null value will clear the existing\nscore.\n\nThis method does not actually save the score in Forms until [Form.submitGrades(responses)](/apps-script/reference/forms/form#submitGrades(FormResponse)) is called with the updated FormResponses.\n\n```javascript\n// For a multiple choice question with options: \"Always true\", \"Sometimes true\",\n// and \"Never\", award half credit for responses that answered \"Sometimes true\".\nconst formResponses = FormApp.getActiveForm().getResponses();\n// Go through each form response\nfor (let i = 0; i \u003c formResponses.length; i++) {\n const response = formResponses[i];\n const items = FormApp.getActiveForm().getItems();\n // Assume it's the first item\n const item = items[0];\n const itemResponse = response.getGradableResponseForItem(item);\n // Give half credit for \"Sometimes true\".\n if (itemResponse != null && itemResponse.getResponse() === 'Sometimes true') {\n const points = item.asMultipleChoiceItem().getPoints();\n itemResponse.setScore(points * 0.5);\n // This saves the grade, but does not submit to Forms yet.\n response.withItemGrade(itemResponse);\n }\n}\n// Grades are actually submitted to Forms here.\nFormApp.getActiveForm().submitGrades(formResponses);\n```\n\nParameters\n\n| Name | Type | Description |\n|---------|----------|-------------|\n| `score` | `Object` | |\n\nReturn\n\n\n[ItemResponse](#) --- a `Item``Response` for chaining\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/forms.currentonly`\n- `https://www.googleapis.com/auth/forms`"]]