Showing posts with label Cheat Sheet. Show all posts
Showing posts with label Cheat Sheet. Show all posts

Monday, September 30, 2013

Hacking Google Forms

A few months back I pitched the idea of using Google forms for all the forms on the new website. Our current forms were created through a Joomla-specific add-on, and I'm not proficient enough in PHP or SQL to feel comfortable recreating them from scratch. Also, the forms on our current site turned into a pretty huge security risk as they aged, and I like the thought of using Google's servers to house the forms and resulting data. However, on their own, Google forms are pretty limited in their functionality, just dumping data into a Google spreadsheet document (which can be exported, but you still have to regularly log into your Google account to view the data.)

Forms do have the option of sending an email alert whenever someone fills out the form, but the alerting email doesn't include the actual form data, so you're still tied to constantly logging into that account to get the information. Enter: Google Apps Script. With a little knowledge of JavaScript, you can use their library of classes and methods to add functionality to basic Google forms.

I started out just wanting to be able to receive an email when someone submitted a form, with all the responses included. For this I found a really nice tutorial from Amit Agarwal (http://www.labnol.org/internet/google-docs-email-form/20884/). If that's all you need your form to do, great! You got it, dude.

I needed a few extras though. First, some of the forms need to go to multiple people. You can easily do this with a slightly more advanced version of the sendEmail method. (You can find documentation on the MailApp class and various iterations of the sendEmail method here: https://developers.google.com/apps-script/reference/mail/mail-app. Also helpful, their Understanding Events cheat sheet: https://developers.google.com/apps-script/understanding_events)

Essentially, you just need to find this line in the original code:

MailApp.sendEmail(email, subject, message);

and change it to:

MailApp.sendEmail(email, subject, message, {cc: email 
   of person you want to copy});

You can cc multiple people by just separating their email addresses with commas.

One of the librarians, however, wanted users to indicate what department they were affiliated with, and then have a copy of the form results go to the department liaison. This is where things start to get a little complicated, and it's helpful to know a little bit about programming languages. I wrote a simple switch statement (with some help from Babs, of course, my go-to programming guru.)

 var dept = e.values[array location 
    of dropdown].toString();
 var contact = toString("xx");

 switch (dept) {
   case "dropdown value 1": 
     contact = "email address 1";
     break;
   case "dropdown value 2": 
     contact = "email address 2";
     break;
   default:
     contact = "default email address";
 }

The first line of code pulls whatever drop-down value the user selected (the associated Google spreadsheet stores these values as an array. 'e.values' accesses the values in this array. Position [0] of the array is the time-date stamp that gets put in automatically, so your array location is just the exact question number of the drop-down question.)

Your switch statement is then just comparing that value to values that you associate with email addresses, and then assigning the associated email address to the variable "contact", so now your method call looks like this:

MailApp.sendEmail(email, subject, message, {cc: contact});

Ok, if I haven't given you a headache yet, there's one more tweak you can do to increase the usability of the form submission email. Using 'e.values' again, you can pull the user's email address from their form submission, and set it as the reply-to on the resulting email. That way, if the person who gets the email has a question for the submitter, they can just hit reply (default reply-to is the gmail account that you're using to create the form.)

Again, since the time-date stamp is [0], you just need the question number where you ask for the user's email address, and now you've got:

var reply = e.values[array location of user’s 
   email].toString();

MailApp.sendEmail(email, subject, message, {cc: 
   contact, replyTo: reply});

You can check out the whole script, as I use it, here.

If you've done any Google form hacking, I'd love to hear about it in the comments. I've only just begun delving into the possibilities here!

5/23/14 - I just stumbled across this post about using Google Forms for leaderboards/summer reading programs. It's also another good example of hacking Google Forms with formulas and scripts.


Wednesday, May 22, 2013

Spring cleaning your LibGuides

I'm in the process of revamping my library's LibGuides, and I've come across a few small changes you can make to your guides that make a world a difference for design and usability. First of all, as far as headers/banners go, I am NOT a graphic designer, so I kept it simple, with just the school logo, and "Library Research Guides" in our official font. I don't recommend random images and color-fading if you're not really, really good at it. Otherwise it looks like a page for your local pre-K, coded with Microsoft Word.

old design

new design
Second, take advantage of SpringShare's excellent documentation. As a company that markets guide-creation software, they really put their money where their mouth is. Seriously, they've created a guide for pretty much everything. Here are some I found particularly useful:
As the library's LibGuides admin, I'm currently building a template that all librarians can start from when creating new guides. They are free to not use it if they don't want to, but if the majority of them do use it, this will ensure some consistency across guides. It also acts as a repository for all the custom search-boxes I've built, so other librarians can pick and choose which ones they want to add to their guides.

I've also created a hidden tab (hidden from public view, that is. It's visible to anyone signed in through the admin interface.) I'm using this tab to post instructions, screenshots, and tips for guide creators. I'm also using it as a content repository for boxes I want to be available, but that don't necessarily have a logical home in the template itself (more on this in a minute...)

I've recommended that users link to boxes in the template, rather than copying them, so the template can also act as a content hub, where changes can be made in one place and pushed to all guides linking to the content. This is also why it's a good idea to import your database A-Z list into LibGuides, even if you have one on your library website. If librarians link to links in the database A-Z guide, it will automatically pull the description (which can be hidden or changed if they want) and it will allow you to make changes to database links and names in one place, that, again, will be pushed to all guides that use those links.

I've also noticed that most libraries that use LibGuides just use the default homepage options, which include a list of guides (featured, popular or recent,) a random user profile, email sign-up and/or a tag cloud. But you can choose instead to display a box from elsewhere in the site, by just entering the box id. So, on my hidden template page, I created a box of popular links (I called them "quick links") and put that on the homepage. I also replaced one of the boxes with our "help" box, that contains our various methods of contact. A good example of a nice customized LibGuides homepage is Worcester Poly's site: http://libguides.wpi.edu/

I also like how Rutgers made their homepage a complete list of guides, listed alphabetically on one tab, and by discipline on another: http://libguides.rutgers.edu/home

This is still a work-in-progress, so if anyone has any other helpful hints, please leave them in the comments!

Wednesday, January 25, 2012

Twitter RSS Feed Cheat Sheet (Redux)

Some notes on constructing searches that I've learned the hard way, but you don't have to:
  • Find a handy url-encoding cheat-sheet, like this one: http://www.blooberry.com/indexdot/html/topics/urlencoding.htm. You will have to replace special characters  (@, #, :, etc.) with their url-encoded version.

  • + and %20 (a url-encoded space) seem to be interchangeable when constructing complex search queries. If one doesn't work in between each search parameter, try the other. (Replace the "+" with OR for searches that return any of the keywords/search parameters, as opposed to all the keywords/search parameters.)

  • To see how Twitter itself is constructing a query, do the search in their advanced search (https://twitter.com/#!/search-advanced), then follow this formula to construct your feed:

    Take the url that is produced from your search and replace the first part (https://twitter.com/#!/search/) with the rss version (http://search.twitter.com/search.atom?q=).

    You will go from this: https://twitter.com/#!/search/librarian%20tattoo
    to this:
    http://search.twitter.com/search.atom?q= librarian%20tattoo

  • You can probably replace the ".atom" with ".rss" if you prefer. (As pointed out by @calimae.)

************************


Here are some pre-constructed feeds, where you just replace the bold info with the info you want to use:

Hashtag search: http://search.twitter.com/search.atom?q=%23library

User mention search: http://search.twitter.com/search.atom?q=%40val_forrestal

Specific user's entire timeline: http://search.twitter.com/search.atom?q=from%3Aval_forrestal

Keyword search: http://search.twitter.com/search.atom?q=research+paper

Location + keyword search: http://search.twitter.com/search.atom?geocode=40.744544%2C-74.027593%2C5.0mi&q=+research+paper+near%3A%22hoboken%2C+nj%22+within%3A5mi

User mention + hashtag: http://search.twitter.com/search.atom?q=%40val_forrestal+%23library

User + hashtag: http://search.twitter.com/search.atom?q=from%3Aval_forrestal+%23library

Hashtag + date: http://search.twitter.com/search.atom?q=%23library%20since%3A2012-01-24%20until%3A2012-01-25



*For the original version of this post, with more details, see: http://theinfobabe.blogspot.com/2011/06/twitter-rss-feed-creation-cheat-sheet.html