Friday, October 18, 2013

School Announcements: Auto-Generating Announcement Documents (printable and viewable online)

Rather than having to manually create a document every day with the daily announcements, I've created a script that will do it for you. There are, of course, other features that could be added, but this is good enough for today.

To start, announcements are submitted via a Google Form, so they end in a spreadsheet. There are three pieces of data: the text of the announcement, the category, and the expiry date.


The script creates a new Google Document (in a public folder), then takes data from the spreadsheet and pastes it into that newly created document. The code for the script follows. (Creative Commons Attribution-ShareAlike).


function createAnnoucementDocument() {
  // Set up a trigger to run this every weekday, perhaps at 8:00 am
 // Define a custom paragraph style.
var styleHeading = {};
 styleHeading[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.CENTER;
 styleHeading[DocumentApp.Attribute.FONT_SIZE] = 18;
 styleHeading[DocumentApp.Attribute.BOLD] = true;

var styleCategory = {};
 styleCategory[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.LEFT;
 styleCategory[DocumentApp.Attribute.FONT_SIZE] = 12;
 styleCategory[DocumentApp.Attribute.BOLD] = true;

var styleText = {};
 styleText[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.LEFT;
 styleText[DocumentApp.Attribute.FONT_SIZE] = 12;
 styleText[DocumentApp.Attribute.BOLD] = false;

  // Get the current date
  var app = UiApp.createApplication();
  var dateToday = new Date();
  // date formatting here: http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
  var formattedDateToday = Utilities.formatDate(new Date(), "MST", "yyyy-MM-dd");
  
  // Create the document
  var documentName = formattedDateToday + " School Announcements";
  var doc = DocumentApp.create(documentName);
  // Move the document to the shared folder entitled "Announcements"
  var documentFile = DocsList.getFileById(doc.getId());
  var folderName = DocsList.getFolder("Announcements");
  documentFile.addToFolder(folderName);
  
  // the spreadsheet that contains the results of the announcement submission form
  var sheet = SpreadsheetApp.openById("***INSERT_SPREADSHEET_KEY_HERE***").getSheets()[0];

  // Start creating the body of the document
  var body = doc.getBody();
  
  body.appendParagraph("Name of School Goes Here\r"+formattedDateToday).setAttributes(styleHeading);

  // Read the whole spreadsheet into a list
  //  if Expiry Date (column D) is > or equal to today's date then process it, else ignore
  //  switch if category match then append to document

  var data = sheet.getRange(2, 2, sheet.getLastRow(), sheet.getLastColumn()).getValues();
  for (var row=0, total=data.length; row < total; row++) {
    var rowData = data[row];
    var announcementText = rowData[0];
    var announcementCategory = rowData[1];
    var announcementExpiry = rowData[2];
    if (announcementExpiry >= dateToday) {
      switch (announcementCategory) {
        case "General":
          body.appendParagraph(announcementText).setAttributes(styleText);
        break;
      }
    }
  }
  body.appendParagraph("Events and Meetings").setAttributes(styleCategory);
    for (var row=0, total=data.length; row < total; row++) {
    var rowData = data[row];
    var announcementText = rowData[0];
    var announcementCategory = rowData[1];
    var announcementExpiry = rowData[2];
    if (announcementExpiry >= dateToday) {
      switch (announcementCategory) {
        case "Events and Meetings":
          body.appendParagraph(announcementText).setAttributes(styleText);
        break;
      }
    }
  }
  body.appendParagraph("Athletics").setAttributes(styleCategory);
    for (var row=0, total=data.length; row < total; row++) {
    var rowData = data[row];
    var announcementText = rowData[0];
    var announcementCategory = rowData[1];
    var announcementExpiry = rowData[2];
    if (announcementExpiry >= dateToday) {
      switch (announcementCategory) {
        case "Athletics":
          body.appendParagraph(announcementText).setAttributes(styleText);
        break;
      }
    }
  }
  body.appendParagraph("Cafeteria").setAttributes(styleCategory);
    for (var row=0, total=data.length; row < total; row++) {
    var rowData = data[row];
    var announcementText = rowData[0];
    var announcementCategory = rowData[1];
    var announcementExpiry = rowData[2];
    if (announcementExpiry >= dateToday) {
      switch (announcementCategory) {
          case "Cafeteria":
        body.appendParagraph(announcementText).setAttributes(styleText);
        break;
      }
    }
  }
  return app;
}

Monday, October 14, 2013

Gamification of Health

Feel free to correct me in the comments, but I'm seeing two main trends in the gamification of health. The first is using game mechanics for fitness, motivating us to get us off the couch. The second is gamified, or at least game-based, treatments.

Since I'm and educator and not a health professional, I'm not particularly qualified to comment on the latter. However I have been reading many interesting articles about video games for pain reduction or for treating ADHD, and I'm very interested in devices that help us measure ourselves. For example, check out this story about using an inexpensive EEG device together with video games as therapy for ADHD.

Of broader application, though, is the use of game mechanics to help reverse our sedentary patterns. Devices such as the FitBit products, and games such as Nike+ Kinect Training help us to measure ourselves and set goals. As I write this during a weekend of overeating, I realize that these things need to be as "frictionless" as possible. It's much easier to have another slice of pie than to go to the gym, or to turn on the Xbox and spend half an hour working out. There continues to be a lot of thought put into seamlessly incorporating fitness (and motivation) into our daily lives.

Often the best motivation, for fitness or anything else, involves collaboration or competition with other people. Upcoming competitions such as triathlons or games encourage us to train, and collaborations such the November Project motivate us because our friends are doing it. Of course this means that we need to convince our friends to participate.

In education, however, we have a unique environment with a captive audience. Students participate in events such as the Terry Fox Run, as well as school sports and intramurals. Some organizations try to replicate this with Corporate Challenges, or with online gamification systems such as OfficeVibe, but for some reason those don't seem as successful. Maybe because we don't usually have PhysEd teachers working in our offices.

So there are two things that I'm thinking about related to this. First, of course, is how to continue use our time with students to encourage lifelong fitness. The second, though, is how to replicate for adults the fitness motivation that we see in schools. I see the principles of gamification as one of the best ways to continue doing that.

But first I think I'll go have another slice of pie.

Gamification of Health

Feel free to correct me in the comments, but I'm seeing two main trends in the gamification of health. The first is using game mechanics for fitness, motivating us to get us off the couch. The second is gamified, or at least game-based, treatments.

Since I'm and educator and not a health professional, I'm not particularly qualified to comment on the latter. However I have been reading many interesting articles about video games for pain reduction or for treating ADHD, and I'm very interested in devices that help us measure ourselves. For example, check out this story about using an inexpensive EEG device together with video games as therapy for ADHD.

Of broader application, though, is the use of game mechanics to help reverse our sedentary patterns. Devices such as the FitBit products, and games such as Nike+ Kinect Training help us to measure ourselves and set goals. As I write this during a weekend of overeating, I realize that these things need to be as "frictionless" as possible. It's much easier to have another slice of pie than to go to the gym, or to turn on the Xbox and spend half an hour working out. There continues to be a lot of thought put into seamlessly incorporating fitness (and motivation) into our daily lives.

Often the best motivation, for fitness or anything else, involves collaboration or competition with other people. Upcoming competitions such as triathlons or games encourage us to train, and collaborations such the November Project motivate us because our friends are doing it. Of course this means that we need to convince our friends to participate.

In education, however, we have a unique environment with a captive audience. Students participate in events such as the Terry Fox Run, as well as school sports and intramurals. Some organizations try to replicate this with Corporate Challenges, or with online gamification systems such as OfficeVibe, but for some reason those don't seem as successful. Maybe because we don't usually have PhysEd teachers working in our offices.

So there are two things that I'm thinking about related to this. First, of course, is how to continue use our time with students to encourage lifelong fitness. The second, though, is how to replicate for adults the fitness motivation that we see in schools. I see the principles of gamification as one of the best ways to continue doing that.

But first I think I'll go have another slice of pie.