Can a Google Form spawn another Google Form - google-forms

Is it possible, (via Appscript), for one Google Form "Form A" to create and open another Google Form "Form B" during the onSubmit trigger of Form A?
I want to ask a user how many entries they want to make on Form A. Then I want Form A to effectively "call" Form B for each entry desired.
I can create the form dynamically or FormApp.openByUrl() but they both fail with an error. I'm beginning to wonder if a Form cannot be subordinate to a Form?
Any experience with this?

You can create a copy of your form with the onSubmit trigger of your source Google form.
function createGoogleForm() {
const sourceFormId = "xxyy";
const file = DriveApp.getFileById(sourceFormId);
return file.getUrl();
}

Related

Automatically import google forms quiz results to google classroom

When students in google classroom submit my google forms, they are automatically graded and students can see their results. Despite that when I want to import these quiz results into my google classroom, I need to do it manually with import grades button. Is there a way to automate this process? That means that when student submits the form, the results will be immediately visible in his google classroom.
Please do not tell me to change LMS, google classroom is a requirement for me.
There's no need to use Forms outside Classroom, you can integrate it
As a teacher go to your Class > Classwork and click on Create > Quiz assignment, fill the needed data like Title, Instructions, Students, Points, etc. Then click on the Form and edit it as required.
When you are done editing, save it and close the Form, then on the Classroom side click on Assign. Once you assigned the quiz to the students, this automatically will be reflected on the student classwork and this student can access your quiz trough the Classroom Platform.
If you want to export this data to another service then use Google Apps Script in order to automate your process
You can skip this if it's not necessary
As an approach to export this data using Apps Script, open the Form and open the Script Editor then copy this code:
function myFunction() {
var form = FormApp.getActiveForm();
form.setCollectEmail(true);
var responses = form.getResponses();
responses.forEach(response => {
let email = response.getRespondentEmail();
let score = 0;
response.getGradableItemResponses().forEach(item => {
score += Number.parseFloat(item.getScore());
});
// Handle your submit and export this data to an extra service
});
}
Then you can handle the submit event by creating a onSubmit trigger in your Apps Script project.
Reference
Class FormApp
FormApp.getActiveForm()
Class Form
Form.setCollectEmail(collect)
Form.getResponses()
Class FormResponse
FormResponse.getRespondentEmail()
FormResponse.getGradableItemResponses()
Class ItemResponse
ItemResponse.getScore()
What you want cannot be achieved for now.
The reason for this is essentially because before importing the grades, the teacher can modify/change the already existing grades if needed before sending them to the students.
What you can do in this situation is to file a Feature Request on Google Issue Tracker here and provide all the necessary details.

How to get the User Agent of a user triggering a GTM event?

I have a Data Layer event push in JS and was wondering if it is also possible to learn the User-Agent of the users triggering the event.
You need to create variable which will return user agent
1) Go to Variables -> New
2) Name: User Agent
3) Type: Custom JavaScript
4) Code:
function () {return navigator.userAgent;}
Then you can use this variable in your tags like that {{User Agent}}
Even more simply, can't you use a "JavaScript Variable" (instead of a "Custom JavaScript" and then just set navigator.userAgent?
Google analytics custom dimension field can be maximum 150 characters and user agent data (when encoded) usually exceed the limit. You need to find a way to shorten the user agent information within a custom js script before sending to GA. You may crop the first 150 character of the user agent information or remove the unnecessary sections or remove the blank characters.

Google Form email notification

I'm looking to have the information submitted on a google form to be on the email notification that I receive. I have tried several things but I can't seem to get it to work. Any ideas?
Create a new form in Google Docs, if you haven’t done that yet, add the necessary fields to the form and save your changes. Now go back to Google Docs and open the spreadsheet corresponding to that particular form.
Choose Tools > Notification rules... and select the option that says Notify me when... A user submits a form. You can also set how frequently you would like to be notified – right away or with daily digest.
Reference: https://support.google.com/docs/answer/91588
To get the notification in your email, you can refer to the this Google add-on.
Also to enable the data or responses to appear in notification you have to enter a script in the form. which basically tries to extract the columns from the spreadsheet. Sample:
var p = SpreadsheetApp.getActiveSheet();
var column = p.getRange(1,1,1,s.getLastColumn()).getValues()[0];
I hope you build the script by yourself!

custom variable issue in google analytics

Hi am using the following code to track the clicks of the users using custom variable. But in my custom variables report the count is getting increased for user log in but not for button click event. Am storing logged in user id in a variable and passing in the custom variable method as the value.
jQuery(document).ready(function(){
jQuery('#buybutton').on('click', function() {
_gaq.push( ['_setCustomVar', 2, 'gaid', <?php echo(json_encode($userName));?>, 1 ] );
_gaq.push(['_trackEvent','button-webtrader','Click','webtrader-buttonclickevent']);
});
});
I have find a solution for this. Instead of custom variables, i have used event tracking to achieve this. I have used the following function in the click event of the button.
_gaq.push(['_trackEvent','button-category','Click','Clicked by the user:<?php echo(json_encode($userName));?> ']);
"$userName" above contains the logged in user id from my site. Now, i can see the clicks of a particular user using his id under Behavior->Events->Pages->Your Page->Event Category->Event Action->Event Label. As username is personally identifiable info according to google, i didn't use username.

Silently create a user account when another form is submitted

I have a form created from another module. I want to add 2 fields to that form: 1. email, 2. password. I think I can do this with hook_form_alter. Then I would like to create a user account and log the user in when the submit button is clicked, then go ahead and execute the action defined by the form.
The original form doesn't have a #submit property...it just has a #action property.
I add the #submit property like this: $form['#submit'] = array('accesscustom_submit');
but accesscustom_submit doesn't seem to be getting called. I think the form is just getting redirected to the #action url that's already defined. Any ideas?
Are you trying to edit the comment form? $form['#action'] is a pretty rare property ... the comment form is the only one I can think of that uses it.
In any case, you can create an account pretty easily by settings up a user array ($account = array('name' => $username, 'pass' => $pass)) and sending it to user_save. See http://api.drupal.org/api/function/user_save/6 for more details.
Once the account is created, you can call user_external_login to log them in (http://api.drupal.org/api/function/user_external_login/6)

Resources