title: Script to automatically make a copy of a Google Document for editing
body: <p>I feel like a total noob posting here.  I know CSS, HTML, and XML pretty well but have always avoided JS.  I know very little javascript and recently started a Lynda.com course to catch up.  Sorry for my ignorance.  As such, I am really struggling learning Google Apps Script.  Obviously, I need to learn JS before I can make sense of any of it.</p>
  
  <p>The school I work for  (5000 students) has set up an online curriculum.  I created the curriculum in the form of thousands of google document worksheets.  These worksheets are linked on various websites. </p>
  
  <p>The problem we are facing is that when students open the documents, they have to make a copy of them before they can edit them (I of course don't want them to be able to edit the originals).  This really sucks for students using mobile browsers on their tablets as making a copy in Google Docs doesn't really work well when using the desktop UI on mobile devices.</p>
  
  <p>I know this kind of thing can be automated with script.  I've looked <a href="https://developers.google.com/drive/v2/reference/files/copy" rel="noreferrer">here</a>, and low and behold, it works!  I'm pissing my pants with joy as I've been searching for such functionality for three years.  (Yes, I know that's sad). </p>
  
  <p>So, what I'm asking is, <strong>would anyone be willing to help a noob figure out how to adapt this code so that students click a button on a website lesson and it automatically makes and opens a copy of the worksheet in a new tab?</strong> </p>
  
  <pre><code>/**
   * Copy an existing file.
   *
   * @param {String} originFileId ID of the origin file to copy.
   * @param {String} copyTitle Title of the copy.
   */
  function copyFile(originFileId, copyTitle) {
    var body = {'title': copyTitle};
    var request = gapi.client.drive.files.copy({
      'fileId': originFileId,
      'resource': body
    });
    request.execute(function(resp) {
      console.log('Copy ID: ' + resp.id);
    });
  } 
  </code></pre>
  
  <p>Spending all day yesterday learning Javascript, I've still got a long way to go.  Not sure how long it'll take for me to be able to figure this out on my own.  </p>