{"id":517,"date":"2024-10-15T18:30:10","date_gmt":"2024-10-15T11:30:10","guid":{"rendered":"https:\/\/nbvps.anhtuanlqd.com\/?p=517"},"modified":"2025-01-09T10:02:46","modified_gmt":"2025-01-09T03:02:46","slug":"tao-google-form-quiz","status":"publish","type":"post","link":"https:\/\/nbvps.anhtuanlqd.com\/?p=517","title":{"rendered":"T\u1ea1o Google Form Quiz"},"content":{"rendered":"\n<p>T\u1ea1o m\u1ed9t Form m\u1edbi, Make Quiz, \u0111\u1eb7t &#8220;anyone can edit&#8221;<\/p>\n\n\n\n<p>T\u1ea1o m\u1ed9t file csv c\u00f3 c\u00e1c c\u1ed9t theo th\u1ee9 t\u1ef1: Question, Option 1, 2, 3, 4, Answer<\/p>\n\n\n\n<p>M\u1edf App script tr\u00ean google form, copy \u0111o\u1ea1n m\u00e3 sau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function importCSVToGoogleForm() {\n  var formUrl = 'YOUR_FORM_URL';  \/\/ Replace with your Google Form URL\n  var form = FormApp.openByUrl(formUrl);\n  \n  var csvFile = DriveApp.getFilesByName('YOUR_CSV_FILE_NAME.csv');  \/\/ Replace with your CSV file name\n  if (csvFile.hasNext()) {\n    var file = csvFile.next();\n    var content = file.getBlob().getDataAsString();\n    var rows = Utilities.parseCsv(content);\n    \n    \/\/ Loop through each row in the CSV\n    for (var i = 1; i &lt; rows.length; i++) {  \/\/ Skip header row\n      var question = rows&#91;i]&#91;0];  \/\/ First column is the question\n      var options = rows&#91;i].slice(1, -1);  \/\/ All but the last column are options\n      var correctAnswer = rows&#91;i]&#91;rows&#91;i].length - 1];  \/\/ Last column is the correct answer\n\n      \/\/ Add the question to the form\n      var item = form.addMultipleChoiceItem();\n      item.setTitle(question)\n          .setChoices(options.map(function(option) {\n            return item.createChoice(option, option === correctAnswer);  \/\/ Mark correct answer\n          }));\n    }\n  } else {\n    Logger.log('File not found');\n  }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Steps to Use the Updated Script<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Replace Placeholders<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Replace\u00a0<code>YOUR_FORM_URL<\/code>\u00a0with your Google Form edit URL.<\/li>\n\n\n\n<li>Replace\u00a0<code>YOUR_CSV_FILE_NAME.csv<\/code>\u00a0with the name of your CSV file containing questions and options.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Save and Run<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Save the script and run the\u00a0<code>importCSVToGoogleForm<\/code>\u00a0function.<\/li>\n\n\n\n<li>Ensure the CSV file is uploaded to Google Drive.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Authorize<\/strong>:\n<ul class=\"wp-block-list\">\n<li>If prompted, authorize the script to access your Google Drive and Google Forms.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Important Notes<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The correct answer should match exactly one of the options provided.<\/li>\n\n\n\n<li>If there are any duplicates in options, they will still be treated as separate choices, but the correct answer will be marked correctly.<\/li>\n<\/ul>\n\n\n\n<p>This setup should now work to import questions with the correct answer specified for each question. Let me know if you need any more help!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>T\u1ea1o m\u1ed9t Form m\u1edbi, Make Quiz, \u0111\u1eb7t &#8220;anyone can edit&#8221; T\u1ea1o m\u1ed9t file csv c\u00f3 c\u00e1c c\u1ed9t theo th\u1ee9 t\u1ef1: Question, Option 1, 2, 3, 4, Answer M\u1edf App script tr\u00ean google form, copy \u0111o\u1ea1n m\u00e3 sau: Steps to Use the Updated Script Important Notes This setup should now work to import questions with the [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[1,23],"tags":[182,179,180,181],"class_list":["post-517","post","type-post","status-publish","format-standard","hentry","category-others","category-tips-and-trick","tag-csv_to_form","tag-google-forms","tag-google-quiz","tag-quiz"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/posts\/517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=517"}],"version-history":[{"count":2,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/posts\/517\/revisions"}],"predecessor-version":[{"id":519,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/posts\/517\/revisions\/519"}],"wp:attachment":[{"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}