Saturday, February 14, 2015

Datalogging to the Web with Python, Requests, and Phant

wikimedia.org
I've been looking at various ways of logging data to a web-accessible location, both for students and for my own learning. I think I've come across the simplest and most elegant way of doing this, using data.sparkfun.com (a free data logging service based on their phant engine).

Basically there are three parts to this, setting up the phant storage location, getting the data, and pushing it to the web. Aside from the hardware setup, this all should take about five minutes.

To set up the data storage location, visit data.sparkfun.com/streams/make and enter the appropriate information. Title and Description are required, and the Fields are the things you will be recording (e.g. humidity and temperature). You can change these later. For more information, check the documentation.

After you click Save, it is very important to make a note of the provided values since this is the only time you will get to see them. Copy them to a document and also use the "Send yourself a copy of your keys" option at the bottom of the page.

So now you have a free, Internet-accessible place to log your data. Of course if you'd like, you can even set up your own phant server.

Step two is developing a way to collect data. This could be something like a barometric pressure sensor connected to an ESP8266 module, a button connected to the GPIO pins of a Raspberry Pi, or data that are already available on the Internet. For this post, we'll use weather data from openweathermap.org.

Step three is to push the data. I like Python and I've recently discovered the excellent Requests HTTP library. If you're using a Chromebook or you don't want to bother setting up Python 2.7 and installing that library, you can use c9.io.

Assuming that you have Python 2.7 set up and the Requests library installed, here's some code that will log the current atmospheric pressure.


And there you have it, a few minutes to set up and a few lines of Python to start logging data to the web. Next I'd like to see this all done with a sensor or two connected directly to an ESP8266 module.

Friday, December 19, 2014

Grade 2 Social Studies Interactive eBook

Cross-posted from our previous blog site.

Exploring Iqaluit, Meteghan, and Saskatoon

Shannon Pasma and Karla Holt have created a universally-designed for learning (UDL) student eBook for Alberta's Grade 2 Social Studies Topic 2.1: Canada's Dynamic Communities. The free eBook explores how to get to each of the three communities as well the land, weather, activities, and seasonal clothing in Iqaluit, Meteghan, and Saskatoon. UDL activities and assessment activities are included in the eBook.

Below is a preview of the eBook.


Please note that the eBook is not interactive in the preview. Download the eBook for the interactive version.

Friday, November 28, 2014

French Immersion Social Studies Minecraft Project: Government (Grade 6)

Cross-posted from our previous blog site.

Check out this Prezi created by grade six students at one of our elementary schools. They created an island in Minecraft to learn about government, laws, charter of rights, and services provided by government.

Voir cette Prezi créé par élèves de sixième année à l'une de nos écoles élémentaires. Ils ont créé une île dans Minecraft à apprendre sur le gouvernement, les lois, la Charte des droits, et les services fournis par le gouvernement.

Monday, October 27, 2014

A Picture is Worth a Thousand Dollars

Recently one of our schools received an invoice for $1000 for their use of a small copyrighted image on one of their newsletters. After determining that it was in fact a legal invoice, they were forced to pay the royalty for their use of that image.

To avoid this, there are a few ways you can find images (or other media such as songs) that are safe to use for newsletters, websites, etc.

The easiest way to find usable images is the "Usage rights" menu on Google Image Search results. After searching for something, click the Search tools button.


Then click Usage rights and select Labeled for reuse with modification.

This will filter your results to display only images that are likely able to be used. Remember that you still need to provide attribution, unless the image is explicitly tagged as Public Domain. Attribution can be as simple as providing a link to the original source.

For more information, check out the different types of Creative Commons licenses. For songs that you can use in projects check out Jamendo or the YouTube Audio Library.

Thursday, October 9, 2014

Python and Google Apps Provisioning with the Admin SDK Directory API

After wading through documentation, blog posts, and StackOverflow answers I've finally figured out a way to authenticate using OAuth 2.0. Since we didn't want to have to interactively grant "user consent" for each of our domains, this is acting as a "web server" for computer-computer interactions.

I assume that you have Python 2.7 installed (three shalt thou not use), but I'd recommend installing Anaconda to make your life easier for all of this. You'll also need to install the Google APIs Client Library for Python.

EDIT: I was finally able to get it to work with the default SignedJwtAssertionCredentials.
 as well as PyCryptoSignedJWT. To install PyCryptoSignedJWT, download and unzip, then from the command line (in the directory you unziped to) type python setup.py install in order to install.

The next step is to set up your project. Here's the documentation from here to "Set up your API":
  • Enable the API access from the Admin console in order to make requests to the Directory API. To enable the API, log in to your admin account and select Security. If you do not see Security listed, select More controls and then Security from the options shown in the gray box. Select API reference, and then select the checkbox to Enable API access. Save your changes.
  • Set up a new project in the Google APIs Console and activate Admin SDK service for this project. See the Google APIs Console Help in the upper right corner of the Console page for more information about creating your API project.




Still in the Developers Console, you'll need to create credentials for your project. Click on Credentials (under APIs) and click the button Create new Client ID and then select Service account.


Download the key file, and make a note of the private key password (which is always "notasecret"). Then click the Okay, got it button.

You'll need to make a note of the Service Account EMAIL ADDRESS that is displayed (a long string of characters ending in @developer.gserviceaccount.com) and the CLIENT ID (the same string ending with .apps.googleusercontent.com).

The next step requires you to authorize your API client to access your admin console. Assuming your're still logged in to your Super Admin account, go to Manage API client access (or go to Security, Advanced Settings, Authentication, Manage third party OAuth Client access). For the Client Name, paste in the CLIENT ID that you noted previously. In the One or More API Scopes, put in a comma-separated list of the scopes that you'll be using. For our example I'd suggest https://www.googleapis.com/auth/admin.directory.user, https://www.googleapis.com/auth/admin.directory.orgunit (you can always change this later). Then click the Authorize button.



The file you downloaded previously will be something like APIProject.p12 but we'll need to convert it to a PEM file. On a Mac or Linux machine this can be done from the command line ( openssl pkcs12 -passin pass:notasecret -in APIProject.p12 -nocerts -out APIProject.pem ), but on Windows other software is required (try Win32OpenSSL that can be downloaded from here). As a last resort for those who don't worry about security, you can convert it using this site.

So you now have a p12 key file, a Service Account Email Address, and of course your Super Admin account. You're set to start writing some code. I like the Spyder development environment that is installed with Anaconda, but feel free to just use Notepad (or Notepad++) if you're so inclined.

Here's the minimum Python code that works for me, fill in the appropriate values for yourself.


superAdmin = 'you@example.com'
serviceAccount = 'somethingorother@developer.gserviceaccount.com'
pemFile = 'APIProject.p12'
scope = 'https://www.googleapis.com/auth/admin.directory.user'

import httplib2
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials

keyFile = file(p12File, 'rb')
key = keyFile.read()
keyFile.close()
credentials = SignedJwtAssertionCredentials(serviceAccount,
  key,
  scope,
  prn=superAdmin)

http = httplib2.Http()
httplib2.debuglevel = False #change this to True if you want to see the output
http = credentials.authorize(http=http)
directoryService = build(serviceName='admin', version='directory_v1', http=http)

# You are now authenticated, so you can say something like this:
user = directoryService.users().get(userKey = 'me@example.com')
print user.execute()



Hopefully that's enough to get you started. The documentation about what you can do with the Admin Directory API is here. just remember that some of them will require you to declare other scopes.

Tuesday, September 2, 2014

What Your Teacher Wants You To Know

On this first day of school I wanted to post a letter that one of my high school colleagues gave to all of her students.

What Mrs. _____ wants you to know:

I do care about you. Not just the person next to you, but YOU. I know that you may not believe me when I say that, but it’s true. There will be days that you and/or I don’t do things perfectly and there may be conflict, but I beg you to not forget that I do want what’s best for you. I’m going to be honest with you: I struggle with remembering names. I study photo class lists in an attempt to memorize names as quickly as possible, but I’m much better at remembering your name if we actually interact… so when I say I’m available for individual help inside or outside of class time, I’m secretly hoping that you will take me up on that so that I can get to know you individually and we can get past this awkward stage of not really knowing each other. As much as I am generally busy at school because I thrive on efficiency and because I have a child at home that I enjoy spending time with, I am willing to stop what I am doing to help you. PLEASE ASK!

I am generally a rule-follower and I don’t truly understand why others aren’t. I think it’s a very valuable skill in life to be able to follow rules that you don’t necessarily agree with. Police officers or your future boss likely won’t care if you disagree with a rule that they caught you breaking. Truth and justice are not completely relative and societies need rules in order to function for the common good. If I crack down on you for doing something that you shouldn’t, don’t try to make excuses or say someone else was doing it too. Most people speed when driving, but only some get caught… if you get caught, you’re responsible for your own actions. Even if someone is trying to ‘force’ you to do it.

You will not use every fact/concept that you learn in school in your life. You likely don’t even know every job that you will do in your life. But, public education walks a tight-rope line between focussing on individuals while moving towards a common goal. Even if you may not ‘need to know’ something, the person beside you may. Regardless of what’s being taught, the act of training your brain to learn is the necessary skill for you to develop. Another key skill in life is the ability to focus past your own nose and do something that doesn’t immediately give you great joy. Sometimes that’s simply delaying gratification, but it’s true even if you never reach the point of finding joy in doing it. Some things just plain need done, whether you want to or not, like cleaning the bathroom or mowing the lawn.

I will be doing my best to help you learn what Alberta Education asks you to. Please know that I welcome constructive comments on how I can do so better. Remember that I cannot read your mind, and may not hear EVERY conversation you have with your friends in class, so please communicate requests directly with me if you want me to be able to address them. If you have any questions/objections/comments, please feel free to share them with me, either in person or via email. I am willing to openly discuss anything, at an appropriate time. :)

I look forward to spending a semester with you,

Mrs. _____

Friday, June 20, 2014

Online Student Forums: Some Options

I've had a few teachers ask me lately about options for students to interact online. They're usually looking for some sort of discussion forum, where students (and teachers) can post ideas and responses. Here are a few options, with some brief descriptions of each. Ideally these will be tools that you also use for other purposes with your students, but discussion forums might just be one way to start getting students involved in blended learning.

Google Groups
Students use their school Google accounts, teachers (and students) can create groups for specific discussion topics or for general class discussions.

Moodle
If you are using this already, your class has a default general discussion forum. You can also create additional discussion forums for specific topics or groups of students.

Edmodo
This is designed primarily as a discussion forum, but it also includes some of the features of Moodle such as the ability to upload files and collect assignments. Unlike Google Groups and Moodle we don't create user accounts for students, they need to create their own accounts and then join your class using the appropriate code.

TodaysMeet
A quick and easy way to set up an online discussion for a day (or longer), it doesn't require student accounts or any other preparation.


There are other options, of course, but these are a few that we use often. Let us know if you'd like help implementing any of these or other tools.