Getting Random Post Suggestions from Custom Google Search Engines

Update 3/31 – After more tinkering, I’ve changed the code to be more stable with any changes Google makes in the future. Code snippets are up to date and irrelevant instructions are now struck out.


You can create a custom Google search engine for your website (or group of websites) which can be very handy for a variety of reasons. If you’ve got a gigantic website, like Jerry Blumengarten, having a custom search bar can help find materials. If you’re working with students, a custom search can help limit where their information comes from. They’re easy to do, but there are some limitations, so be sure to read the Terms of Service if you’re going to set one up.


John Stevens asked on Twitter if there was a way to get a random post from a custom search. I felt like there ought to be some way to do that, so I started digging. Because the MTBoS index of blogs is on all different platforms and not networked in any particular way, it turned into more of a chore than I originally thought. Really, when you get down to it, randomizing search results is the anthesis of what search engines do, so we have to accomplish the “random” aspect of the Google search with a different method.

I’ll be using a search for my own blog for the demo here (down below). Brace yourself for some code.

First, rather than using the Google script you get from the Control Panel, use this HTML instead:

You’re given one line of HTML to put in your page where you want to search bar to appear. Simply add the button line to add the random button:

google-cse-html





Line 5 adds a new button – the Random button – to the search form. That button is important. Rather than needing some text in the input field, a user can click on the Random button and some JavaScript magic will happen.


If you want to use this, you’ll need to do a couple things:

Make sure your site has jQuery installed. If you’re not sure, go to your site’s code and paste this in before the closing header tag:

You’ll need to put a script in the footer of your site. You can also do this with a widget with a lot of platforms…there are too many to list, and the footer solution is usually the best approach. If you’re not sure what to do, leave a comment, and I can try to help you out.

`
// This is the array holding the serach terms
var queries = [‘animals’,’dogs’,’cats’, ‘emu’,’fish’,’snakes’, ‘panda bears’,’meerkats’,’spiders’,’birds’];

// When you click on the Random button, it'll grab a random search term and run it through Google
document.querySelector('button').addEventListener('click', function() {
var search = google.search.cse.element.getElement('standard0');
var rand = Math.floor(Math.random() * queries.length);
search.execute( queries[rand] ); }, false);
` This script will take that Random button we added earlier and pop a random term into the search box and carry out the search. yOu need to set the terms in the array (line 3), each term in single quotes and each term separated by a comma. Make sure to keep that syntax correct or else it won’t work. Also, if you try this on any site other than your own, you can run into issues. I’ve been testing this on Codepen.io with mixed results. Once thrown into my own page, though, it works just fine. I’d create a new page on your site and drop the code into place. Test it as a draft page to make sure everything is kosher and then run with it. If you want to see a sample implementation (proof of concept, not really helpful), check out this spartan search page. You can type in a search term and hit submit to see how it works. Then, try hitting Random without putting any text in to see what it does. Do note that WordPress has a pretty good random post feature built-in. This is meant more for wider searches across multiple platforms using the Google index of sites.

Making Sub Plans Easier

I hate missing school. It’s stressful. I have to do multiple days worth of planning ahead of time, plus know what’s happening the day I get back. Then, I have to turn those plans into a written document that anyone in the world can follow to the letter.

It’s stressful.

I still leave a document with some specific notes for a substitute – things like management or specifics to take note of. But now, instead of writing out a ton of information on what to do, I record a simple video and post it to a static page on my class website. There are a couple little tricks I learned along the way:

1. The page should be bare bones. Don’t worry about making it “feel” like the rest of your class site. It should be something easy to display on a projector without having to hunt through menus to get the information. That also allows you to just replace the video and written instructions for the next time you’re out. Flexibility is key.

2. Embed the video right in that page. If you’re like me, you want to make sure that video is responsive, too. I found a super-handy little snippet of CSS to make YouTube videos responsive, and I used that so students can access the information on their own later on any platform.

3. Keep your video unlisted so it stays within context. I have a lot of content on YouTube, I want to keep the sub plans isolated because they don’t really fit in the flow of anything else there. This way, the video only “exists” when student need it – while I’m gone.

It’s not totally un-stressful now, but it’s way better than it used to be. If you’d like to see my “away from school page,” or even copy the source for your own page (self-hosted), that’d be dandy.

Another Casualty of the Free-Only Economy

Geddit, a response-system app will be turning off its servers on June 30th, 2015. I heard about this software about a year ago when I sat down next to one of the co-founders at CUE. I was really excited about the platform because they not only allowed for students to respond to questions in the live lesson, but they also gave confidence scores for those answers. It’s fantastic way to do formative assessment both before, during, or after a lesson.

But, Geddit tried the free route because that’s what educators respond to. Lots of people signed up and started using it. Love and tweets don’t pay the bills.

Sure, there are other response apps out there thrown around – Kahoot being the current favorite – but I’m staying away from that one with a 10 foot pole because of this gem in their terms:

We do not assume any liability for any content posted by you or any other 3rd party users of our website. However, any content posted by you using any open communication tools on our website, provided that it doesn’t violate or infringe on any 3rd party copyrights or trademarks, becomes the property of Kahoot! AS, and as such, gives us a perpetual, irrevocable, worldwide, royalty-free, exclusive license to reproduce, modify, adapt, translate, publish, publicly display and/or distribute as we see fit. This only refers and applies to content posted via open communication tools as described, and does not refer to information that is provided as part of the registration process, necessary in order to use our Resources. (emphasis added)

In other words, “We won’t charge you, but we’ll take anything you upload and make money off of it without any attribution to your intellectual property.”

Now, I’m not saying Geddit is perfect either:

If Geddit, or substantially all of its assets, were acquired, or in the unlikely event that Geddit goes out of business or enters bankruptcy, user information would be one of the assets that is transferred or acquired by a third party. You acknowledge that such transfers may occur, and that any acquirer of Geddit may continue to use your personal information as set forth in this policy. (emphasis added)

Bill Fitzgerald has a fantastic post on the practice companies are using to hedge their investment: sell our user data.

So, the cycle perpetuates itself.

  1. Create company
  2. Let teachers use it for free to build up buzz and userbase.
  3. Try to monetize.
  4. Fail – “paid” in education is a no-no.
  5. Close doors and ship off user data.

We’re selling our data – our information and histories – so we don’t have to pay a few bucks to use a helpful service.

Data is worth more than money these days, and we’re selling ourselves short. The free-only economy in education has to change.

The Solemn Duty of Educating

Featured image is creative commons licensed ( BY ) flickr photo shared by Raed Mansour


The community is suffering. Students are frustrated and they’re looking to me to solve the problem. I’m faced with deciding whether or not my commitment to an individual students takes precedence over my commitment to the class as a whole.

creative commons licensed ( BY-NC-SA ) flickr photo shared by ShawnMichael

I mentioned earlier today in a tweet that Audrey Watters had a post back in January about applying the Hippocratic Oath (albeit, for education technology, but the application is the same) and it’s really stuck with me. I’d never read the oath, but now I have one printed and hanging next to my desk. I’ve started to re-purpose some of the lines in the 1964 rewrite of the Oath to apply a little more to my day to day work.

I will apply, for the benefit of students, all measures which are required, avoiding those twin traps of overtreatment and educational nihilism.

I think the first time I had a student leave my room was in my third year teaching. My temper doesn’t get pushed too much and I can usually let the little things roll on by. Small redirection and nuance have been powerful tools for me, and they’d worked relatively well. This year, though, it’s a whole different story. I don’t feel like I’ve given up hope that these students can learn or improve, but my toolbox is feeling more and more empty as I try more and more techniques to rein in the behaviors.

I will not be ashamed to say “I know not,” nor will I fail to call in my colleagues when the skills of another are needed.

I really resist having students leave my room. Perhaps it’s hubris, perhaps it’s stubbornness. I refuse to fall into a habit of removing problems rather than resolving. However, at what point do we move on from individual situations and focus on the whole? Am I shirking responsibility as a teacher by relegating individual students to situations where learning is impossible? On the other hand, by keeping students in the room, am I relegating the whole class to the same fate?

creative commons licensed ( BY-NC-SA ) flickr photo shared by E.L. Malvaney

I will remember that there is art to teaching as well as science, and that warmth, sympathy, and understanding outweigh the expectation of compliance or any grade awarded.

Finding nuance in a situation where patience feels like the enemy is difficult. The more time I take to try and weave a better plan together for individuals feels like time lost for the other 22 people in the room. I’m falling back on old habits and a bad attitude about students. My empathy is running out and I’m entering a realm where I’d rather have compliance than a real rich atmosphere for learning.

If it is given me to arouse curiosity, all thanks. But it may also be within my power to stifle the desire to learn; this awesome responsibility must be faced with great humbleness and awareness of my own frailty.

I realize that it’s the teacher’s burden to always remember the ones we lost – those we couldn’t connect with or engage. In the end, I’d love to have my cake and eat it, too. I think I can still do that – there are bright spots, and we celebrate those days. But, I’m responsible for the learning environment as a whole.

ἀσκέειν, περὶ τὰ νουσήματα, δύο, ὠφελέειν, ἢ μὴ βλάπτειν

Cleaning up PHP functions

Last year, I took some time to write a small blog theme for Anchor CMS using some PHP and a lot of CSS. Too much, if you ask me. If I had the time, I’d go back and clean a lot of it up. Maybe during a rainy day.

I haven’t logged into GitHub in a while. Teaching has been all consuming lately and I’ve not really had time to mess around with some coding projects I’d started so long ago. I hopped on tonight to grab some code for something else I’ve been working on, and alas, a problem with my theme.

Someone, somewhere thought my theme was good enough to use, which is pretty cool. But, some of the functions weren’t working correctly, and some were just plain missing (oops). I’d made a mistake somewhere in my cloning and rebasing, and I hadn’t taken the time to make sure I didn’t flub something up along the way. Anyways, long story short, he grabbed some code from my live demo site and got it working. But still. Customer support is our number one priority.

Here’s what I started with:

broke

function twitter_account() {
    return Config::get('meta.twitter');
}

function twitter_url() {
    return 'http://www.twitter.com/' . twitter_account();
}

The idea was to have someone create some metadata (twitter_account) once and then have it populate a link to their Twitter page as well as be the attribution info on any of the tweet links on posts. Easy enough, right? Wrong. The account function wasn’t returning the correct URL because I done messed up my PHP call. It should have been this:

fixed

function twitter_account() {
    return Config::get('meta.twitter');
}

function twitter_url() {
    return 'http://www.twitter.com/' . site_meta('twitter_account');
}

I’d forgotten that the twitter_account meta field only stores the data object. I have to tell the second function that there is some site metadata stored in the twitter_account call, not just the function itself. Oops.

All’s well now and it’s working fine, from what I can tell. Iteration is the game. Back to the workshop…