Friday, February 14, 2014

Testing substituting Desmos script inside Form programatically

Thursday, February 13, 2014

Testing posting via Email

Testing to Get HTML Source COde of a Form via Script

This form was created from a spreadsheet. I am trying to run a script to get the HTML source code and then post it via email to blogger. If you see this on blogger, my script works!
This is a required question

Sunday, February 9, 2014

Individualized Math Quizzes Project, update #3

I have updated my project further.

Some additions: There is now a working Popup window to ask you how many questions you want to have and it will automatically write the headers. The pullResponses will autograde, color-code answers based on Correct and Incorrect, and give the total number of correct solutions per student.

Here are the things I am still working on (the strikethrough items have been completed). You can find the most updated version here: http://goo.gl/KXDU83

Some things I still am working on when I get some more spare time this week:
1. I want to add are better functionality of the number of questions and make them dynamic.
2. I will also add the function to grade the quiz based on the student response
3. I will also work on the randomization of questions.
4. Make an option for a level of difficulty. For example, you could have 3 levels of questions Basic, Intermediate, and Advanced and choose from those questions.
5. I need to stop the script when there are no names left in the spreadsheet.

Wednesday, February 5, 2014

Updated Individual Math Quizzes Project

Here are the things I am still working on (the strikethrough items have been completed). You can find the updated spreadsheet at the same place:
http://goo.gl/of3NZu

Some things I still am working on when I get some more spare time this week:
1. I want to add are better functionality of the number of questions and make them dynamic.
2. I will also add the function to grade the quiz based on the student response.
3. I will also work on the randomization of questions.
4. Make an option for a level of difficulty. For example, you could have 3 levels of questions Basic, Intermediate, and Advanced and choose from those questions.
5. I need to stop the script when there are no names left in the spreadsheet.


Getting the student responses from the Individualized Math Quizzes

In my post yesterday I detailed how to make Individualized Math Quizzes for students using Google Forms. I have updated that script to now go to the forms and pull the responses back into the spreadsheet.

You can find the testing spreadsheet at the same location,  containing the updated script in the Script Editor: http://goo.gl/of3NZu

The additions I made were to add a Menu, which currently has 2 items: the quiz generator and the response puller.

Some things I still am working on when I get some more spare time this week:
1. I want to add are better functionality of the number of questions and make them dynamic.
2. I will also add the function to grade the quiz based on the student response.
3. I will also work on the randomization of questions.
4. Make an option for a level of difficulty. For example, you could have 3 levels of questions Basic, Intermediate, and Advanced and choose from those questions.
5. I need to stop the script when there are no names left in the spreadsheet.

Hope you can find something useful here!

The menu was created using this script:
// The onOpen function is executed automatically every time a Spreadsheet is loaded
 function onOpen() {
   var ss = SpreadsheetApp.getActiveSpreadsheet();
   var menuEntries = [];
    menuEntries.push({name: "Create Individualized Quizzes", functionName: "createForm"});
    menuEntries.push(null); // line separator
   menuEntries.push({name: "Pull First Student Response from Quiz", functionName: "pullResponses"});
   ss.addMenu("Individualized Quiz Creator Menu", menuEntries);
 }

The script to pull the responses is here:
function pullResponses(){
  
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getSheets()[0];
 var studentInformationRange = sheet.getRange(2,1,sheet.getMaxRows()-1,sheet.getMaxColumns());
 var studentObjects = getRowsData(sheet, studentInformationRange); 
  
 for (var i = 0; i < 3; ++i)  
 {
 var currentStudentObject = studentObjects[i]  //get the ith row of data from the studentObjects array
 var formURL = currentStudentObject.urlOfPublishedForm; //get the URL of the form for the student
 // Open a form by URL and log the responses to each question. from: https://developers.google.com/apps-script/reference/forms/form-response
 var form = FormApp.openByUrl(formURL);
 var formResponses = form.getResponses(); //get all of the responses
  for (var k = 0; k < formResponses.length; k++) {
   var formResponse = formResponses[k]; //get each response (this is a submission)
   var itemResponses = formResponse.getItemResponses(); //get all of the item responses
   for (var j = 0; j < itemResponses.length; j++) {  
     var itemResponse = itemResponses[j];  //take each item response 1 by 1
     //now write the student response into the spreadsheet
     //**need to index the columns by number dynamically, right now I use j+9
     var writeStudentAnswerCell = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Student Data').getRange(i+2, j+9).setValue(itemResponse.getResponse());
   }
  }
 }
}

Tuesday, February 4, 2014

Creating Individualized Math Quizzes using Google Forms

I have been working on using Google Apps to give problems individualized math assignments. It is quite an arduous task since nice Math Type doesn't play so well with Google Apps since they got rid of their LaTeX editor back in 2009 or 2010...

I resorted to running the LaTex through the Google Charts API which creates an image of the math with "nice" formatting. See my post here detailing the process: Blog Post
Then I created a set of problems in Mathematica, exported them in TeX format as a .csv and then uploaded them to my Google Sheet.
I needed to have them URLencoded to play well with the Google Charts API so I created a custom function in the Spreadsheet to do that and then Concatenated them.

Now I have a list of problems in the right form in the spreadsheet (see the Questions tab in my example below).
I then created a script that will create a Form for each student and add questions to it so each student will get an individualized quiz. (I do need to randomize the questions, but that wasn't the focus of my creation. I needed it to run first :)
The script also writes the answer key to the problems it chooses on the Student Data sheet.

I will work on randomizing the questions and post when it is finished (hopefully tomorrow), but here is an example:

http://goo.gl/of3NZu

Here is the script (it is still an alpha copy,  I need to stop the script when there are no more names). You also will need to add the URLencoder script if you don't copy the Spreadsheet:

function createForm(){
  //get the student data from the spreadsheet
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];
  var studentInformationRange = sheet.getRange(2,1,sheet.getMaxRows()-1,sheet.getMaxColumns());
  var studentObjects = getRowsData(sheet, studentInformationRange);
 
  //get the student info by row from the student sheet
  for (var i = 0; i < studentObjects.length; ++i)
  {
   var currentStudentObject = studentObjects[i]  //get the ith row of data from the studentObjects array
   Logger.log(currentStudentObject);
   //This fetches a document by ID (found in the URL) and opens it up.
   var studentLastName = currentStudentObject.lastName;
   var studentFirstName = currentStudentObject.firstName;
   var studentEmailAddress = currentStudentObject.emailAddress;
   
    // Create a new form, then add image item followed by a blank text item for the student response from https://developers.google.com/apps-script/reference/forms/
   var form = FormApp.create('New Quiz for ' + studentFirstName + " " + studentLastName);
   
   //find out where the form is
   var publishedURL = form.getPublishedUrl();
   var editURL = form.getEditUrl();
   //write the URLs to the spreadsheet on the Student Data sheet in column D and E respectively
   var rowNumber = i + 2;
   var publishedURLCell = 'D' + rowNumber;
   var writePublishedURL = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Student Data').getRange(publishedURLCell).setValue(publishedURL);
   var editURLCell = 'E' + rowNumber;
   var writeEditURL = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Student Data').getRange(editURLCell).setValue(editURL);
   
   //find the question from column G on the Questions sheet (Need to randomize later)
   //find the answer from column G on the Questions sheet (Need to randomize later)
   var problemCell = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Questions').getRange('G'+ (i+2)).getValue();
   var answerCell = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Questions').getRange('C'+ (i+2)).getValue();
 
   //Problem 1
   //add the question to the form
   var problem = UrlFetchApp.fetch(problemCell);
    form.addImageItem() //add an image item
     .setTitle('Please write your answer in the box below the problem')
     .setHelpText('Solve This Problem') // The help text is the image description
     .setImage(problem); //the actual image with the question in LaTeX format
    form.addTextItem(); //puts a blank text question below so the student can answer the imageproblem
   
   //write the answer to the spreadsheet
   var problemAnswer = answerCell;
   var writeAnswerCell = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Student Data').getRange('F'+ (i+2)).setValue(problemAnswer);
 
   //Problem 2
    //find the question from column G on the Questions sheet (Need to randomize later)
   //find the answer from column G on the Questions sheet (Need to randomize later)
   var problemCell = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Questions').getRange('G'+ (i+3)).getValue();
   var answerCell = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Questions').getRange('C'+ (i+3)).getValue();
   //add the question to the form
   var problem = UrlFetchApp.fetch(problemCell);
    form.addImageItem() //add an image item
     .setTitle('Please write your answer in the box below the problem')
     .setHelpText('Solve This Problem') // The help text is the image description
     .setImage(problem); //the actual image with the question in LaTeX format
    form.addTextItem(); //puts a blank text question below so the student can answer the imageproblem
   
   //write the answer to the spreadsheet
   var problemAnswer = answerCell;
   var writeAnswerCell = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Student Data').getRange('G'+ (i+2)).setValue(problemAnswer);
   
   
   //Problem 3
   //find the question from column G on the Questions sheet (Need to randomize later)
   //find the answer from column G on the Questions sheet (Need to randomize later)
   var problemCell = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Questions').getRange('G'+ (i+4)).getValue();
   var answerCell = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Questions').getRange('C'+ (i+4)).getValue();
   //add the question to the form
   var problem = UrlFetchApp.fetch(problemCell);
    form.addImageItem() //add an image item
     .setTitle('Please write your answer in the box below the problem')
     .setHelpText('Solve This Problem') // The help text is the image description
     .setImage(problem); //the actual image with the question in LaTeX format
    form.addTextItem(); //puts a blank text question below so the student can answer the imageproblem
   
   //write the answer to the spreadsheet
   var problemAnswer = answerCell;
   var writeAnswerCell = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Student Data').getRange('H'+ (i+2)).setValue(problemAnswer);
 
 

   }
 
}