How to use programming logic (e.g. JS) on Google Forms? - javascript

Ok, maybe this question is not extremely well-formulated, but I have a problem and I want to solve it, hence the existence of this question. There is a Google Forms form in which, in its current state, users answer questions and, after they have answered such questions, they themselves have to compute their results (a simple algorithm) (it's, to be precise, it's a Vark-style questionnaire (not that it matters)). That is cumbersome and prone to error, so I am in charge of making the form itself compute the thing and show it to the user afterwards.
So I figured I just gotta be able to program an output based on inputs of Google Forms. Such an output would ideally dinamically change on the screen (as the user changes his answers), but it can also be shown after the questionnaire has been answered. What is the way to go? I searched a bit about it and it seems one could use Google App Scripts to make an add-on for forms... Is this overkill or the way to go?
Thanks!

There is already an inbuilt system as to where the Google Forms form calculates the score. However, there is a catch , the questions need to be in MCQ format .

Related

Is there a way to accept formula inputs from a user in JavaScript?

I'm making a JavaScript application that basically has daily integral questions. The bit I'm stuck on is how to render the users answer like how Wolfram or Symbolabs does, I know I can use mathML to render the questions but it doesn't seem like this works for live user input. Any pointers would be great.

How to check is the form has not been "attacked" [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have to make some custom forms,
the thing is, I will need to use JavaScript to make them, here is a little image :
It's like a select, but in a carousel, so, I can know what items is selected, the thing is, I need to calculate a price over fields like that, and people can like, spoof the system, and just change the active element, make the element the cheapest with the element they really took, maybe the more expensive you see ?
But how can I ensure that the user didn't changed anything, I guess it will be an Ajax to ensure the information in the server, because they can't change anything on the server, but in the server how can I send the good data if the user spoofed it ? Maybe I could add on the HTML something like : data-server-element: 1, data-server-price = 50. But the data-server-price will only be here to calculate the price with Javascript and I would have an array in my server side which will tell me : data-server-element : 1 ====> 50. So if he change the data-server-price, he will pay the real price. But if he change the data-server-element he can do anything he want, I see how to resolve a problem, but that resolve add some more problems. I am certainly wrong in the process and in the logic, which is why I am calling on you to find out, because I cannot afford to let someone pay less than they should.
Thanks for your help.
(Maybe this question is already here on StackOverflow, but I didn't find out an answer that could help me, If so, I apologize, usually I do some research before I ask a question here)
You can't trust anything that happens in the browser.
If you want a different price for different regions, calculate it on the server and send it back to the browser to show the user.
However do not use this price when the user submits the form. Recalculate the price on your server then use that.
There is no way to stop the user from changing anything or everything in the web page or the data that they send back to you. Never trust anything you get from the browser.
It's great that you've realized this! A lot of people don't, and we get horribly insecure webpages. In fact, you can take the idea even further - an evil hacker will probably not bother with your webpage and javascript at all. They will just make their own HTTP request from scratch with all the fields set to whatever they please.
There really is only one solution to this and you've also come up with it yourself - you need to validate and re-calculate everything on the server side. Just take the basic data (like which choices he selected) and go from there. You can even make your form in such a way that it doesn't bother sending the calculation results that were done client side. You can't rely on them anyway. They're only good for the convenience of the legitimate users.

Generating any # of random math questions based on user input in Javascript using LOOPS

My task is to create a program in Javascript that generates however many math questions the user wants based on their answer through a prompt. So if the user were to answer the prompt saying they want 5 questions, I would need 5 math questions generated, all with random numbers that change every time the page is refreshed. (questions can be very simple math problems)
The program also needs to ask the user for the answers to the questions, and display their answer AND the correct answer to the questions on the webpage afterwards. Loops also need to be involved in the code for this exercise.
I am a beginners level web programming student, and I am not too sure where to start to code this, because my teacher has not given us many examples and practice for using loops to make this programs. Any suggestions?
You have to use Javascript? No other langaue possible? Javascript won't be the easiest language for a beginner...
But if you have to use it:
- Generate a HTML Unput field where User can enter a Number of how many math questions he want
Evaluate the number and run a loop, wich generates the numbers of question.
Use a Random Method for generating numbers.
Take look at this: https://gist.github.com/kerimdzhanov/7529623
Display the questions with a html input field for the answer of the user
Solve the question with javascript
Compare the answer of the user with your result
Display if true or false, display your calculated result for showing the correct answer.

Uncovering a hidden link [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm a complete layman and despite my utmost attempts (involving visiting about 100 different pages), I wasn't able to solve my problem. I'd be really grateful if anyone would be willing to help me out.
Say there is an elaborate website using Javascript, where you register, have your own profile etc. It asks you to register for one of a few time slots. You do it by clicking a hyperlink, which has this annoying feature (discussed elsewhere on this website, see here: how can url be hidden in hyperlink when mouse hover ) that it hides the link. Is there a way to uncover it?
By uncover I mean a way in which I would be able to register for a given time slot without clicking the hyperlink, but rather via copying that hidden link (or typing it in) to the address bar of the browser. I have tried using Firebug and Tamper Data, but to no success. Both programmes provided me with viable candidates for links, but when I copied them to address bar and pressed enter, it didn't result in a registration for a given time slot.
Finally, Tamper Data tells me that 'Content-Type=application/x-www-form-urlencoded', whereas Firebug indicates that 'enctype="multipart/form-data" right above the table with hyperlinks, so I begin to think there is some sort of encryption in place which is meant to prevent me from getting what I want. And I'm sure owners of this website would want to prevent me, but are they able to do it?
So all in all, is it even doable? Apologies if this all sounds too broad, I'll be more than happy to make it (or at least try to make it) more clear.
Thanks a lot and apologies, but I really don't know what I'm doing here.
As Yang Li said: it depends.
If a website is using a lot of javascript to perform on screen changes and network requests, the likelihood of you being able to just use a URL (even if it is the url used by a javascript script) to perform an action is low.
Most websites these days that rely on javascript would have data elements hidden to the user which may affect the way an action is relayed to the server. Think hidden form elements.
And on the server side, who is to say that the order you are trying to use that URL in is correct? You would have to run through the code piece by piece, along with observing the network requests to be certain.
So in answer to your question, it MAY be doable. The more important questions is: is it advisable? I would suggest not tampering too much with the way the website works on your browser, as it was intended to be used in a certian way. You can't be sure of all of the side effects of using it in an unintended fashion.

How do I build a multi-stage web form?

I'm trying to build a webform that has multiple stages. I'm patterning it off of the Stack Overflow / Stack Exchange flagging webform. The problem is, I'm not sure how to trigger the "next stage" action.
To illustrate, if one wants to flag a question on Stack Overflow, you click flag and then a popup prompts you to make a choice. If you choose the second option ("it doesn't belong here, or it is a duplicate") the form automagically takes you to a second screen.
First screen:
Upon click, it auto-redirects to:
The problem is that I don't know what the underlying trigger is. How does clicking that radio button send the end user to the next screen?
I tried checking the source, but I have a feeling I'm only seeing half the picture:
No amount of HTML tutorials I find have any practice example similar to this. I suspect this is JavaScript, but I can't find the linked .js file that would trigger these actions.
So: How does the webform auto-redirect upon click? As a follow-up, if it's using JavaScript, is there an HTML/CSS-only workaround I can use?
It might help to think about this at a lower level than frameworks. There are two ways one could make a multi-stage form.
The first (and generally older) way is to store the state on the server. Each stage of the form is actually a separate form, and the client's progress through the questionnaire is kept on the server (for example, as part of the session data).
The second way (the more modern one) is to use JavaScript, as you suspected. There is actually very little black magic in this case, and no auto-redirects on clicks at all. All you do is have one very long form where you show/hide some of the elements depending on the user's selections (of course, you could have multiple <form> elements which you show/hide).
Well, I'd use some sort of jQuery wizard plugin and adapt it to my needs. I did it very recently and it wasn't that hard. You should try SmartWizard 3.0, it's pretty active, the last release was about 2 months ago and the coders answered my questions pretty fast.
Here it is: https://github.com/mstratman/jQuery-Smart-Wizard
You can trigger the wizard to advance to the next step linking an event to the action of clicking the radio button.
Good luck :)

Categories