Online Student Exam

⚠️ SETUP REQUIRED: Before publishing, replace YOUR_DEPLOYMENT_ID in the JavaScript code at the bottom with your Google Apps Script deployment URL. See instructions section below.

Instructions for Students: Enter your name below, answer all questions, and click “Submit Exam” to submit your responses and download a copy.

Question 1

What is 2 + 2?






Question 2

What is the capital of France?






Question 3

What is the largest planet in our solar system?







Setup Instructions for Instructors

Step 1: Create Google Sheet

  1. Go to Google Drive
  2. Create a new Google Sheet named “Exam Results”
  3. Add these column headers in row 1:
    • A1: Student Name
    • B1: Question 1 Answer
    • C1: Question 2 Answer
    • D1: Question 3 Answer
    • E1: Submission Time

Step 2: Create Google Apps Script

  1. In your Google Sheet, click ExtensionsApps Script
  2. Delete any existing code and paste this exactly:
function doPost(e) {
  try {
    const data = JSON.parse(e.postData.contents);
    const sheet = SpreadsheetApp.getActiveSheet();
    sheet.appendRow([
      data.studentName,
      data.q1,
      data.q2,
      data.q3,
      new Date().toISOString()
    ]);
    return ContentService.createTextOutput(JSON.stringify({
      success: true,
      message: 'Response recorded successfully'
    })).setMimeType(ContentService.MimeType.JSON);
  } catch (error) {
    return ContentService.createTextOutput(JSON.stringify({
      success: false,
      error: error.toString()
    })).setMimeType(ContentService.MimeType.JSON);
  }
}
  1. Click DeployNew Deployment
  2. Type: Select Web app
  3. Execute as: Your Google account
  4. Who has access: Anyone
  5. Click Deploy

Step 3: Get Your Deployment URL

  1. After deployment, you’ll see your deployment URL (looks like: https://script.google.com/macros/s/AKfycbx...)

  2. Copy this entire URL (including /usercopy at the end)

  3. In this R Markdown file, find the line that says:

    const GOOGLE_APPS_SCRIPT_URL = 'https://script.google.com/macros/d/AKfycbw4M4c46T2zvRSGM0AXazl_62tY14ox7y7ufy_r2bZzX5pUk1EhwBhcxGtzfMzN7v70Lg/usercopy';
  4. Replace YOUR_DEPLOYMENT_ID with your actual deployment URL

  5. Save and re-knit this document

Step 4: Publish to RPubs

  1. Open this .Rmd in RStudio
  2. Click KnitKnit to HTML
  3. Click Publish → Select RPubs
  4. Share the published link with students

Step 5: Monitor Responses

  • All student responses will automatically appear in your Google Sheet
  • You can download the sheet as CSV at any time: FileDownloadCSV
  • Responses update in real-time as students submit