Algebra and Programming – A Peek Ahead

I’m starting a new unit reviewing algebraic skills tomorrow. My students have most certainly moved through evaluating algebraic expressions, solving linear equations, and combining like terms before. Much of tomorrow’s class will involve me drifting between students working on this to get an idea of their skill level – certainly not a developmental lesson on these ideas unless I really see the need.

My question is on making these concepts new. The thing that comes to mind most immediately is using this as an opportunity to get students started on concepts of computational thinking. Students have seen the concepts of variables, substitution, and evaluation, but I think (and hope) that the ideas of using a computer to do these things is new enough to whet their appetites to potentially learn more.

What does the computer do well? (Compute).

What must we do to get it to do so? (Communicate to the computer correctly what we want to compute.)

After having my students do some algebraic evaluation on their own, I’m having them watch this short video:
M9 U2D1.1 – Web Browser & Math Hacking

Side Note:

Now that I see I can increase the font size in Chrome for the console, or zoom in using Camtasia, I can make the code much more visible than it is now. Work for the morning.

I can’t see an easier way to get students into a programming environment than this. Everyone has a web browser, and Safari and Chrome both give access to a Javascript console without too much work. There are websites like Code Academy that have a similar environment on their front page, but this method barely even requires accessing a web page.

I’ve had students install Python on their computers before, and it works well enough as long as there aren’t any operating system related hiccups. (IDLE does not run so well on OSX 10.5). I just like that this Javascript environment is hiding on student computers without having to do anything.

Other thoughts:

  • We have to tell the computer explicitly that 2x is 2*x. This is a fact that often gets glossed over when students haven’t seen it for a while.
  • Javascript doesn’t have an easy to access exponent symbol like Python or other languages do. To enter x3, you have to either type x*x*x (reinforcing the idea of the exponent for the win) or Math.pow(x,3) which is too abstract to even consider using with students.
  • Selling programming as a fast and easily accessible calculator isn’t a compelling pitch – I completely get that. At this point though, I’m not trying to sell the computer as the way to do things. My students all have computers with them in their classes. If making them unafraid to do something that feels a bit ‘under the hood’ might lead them to know what else is possible (which is a pitch that is coming really soon), I’m happy with this.

My latest app project: 5K Race Timer

I happened to attend a meeting a little more than a month ago for the committee that organizes the Dragon Run. This is one of the school’s biggest events and requires quite a group of people to make happen. One of the biggest challenges that the group faces is the timing of the race and management of this data for the 120+ runners that participate in the official event.

The scheme used in previous years has been a very well thought out system of spotters with pencil and paper lists and a race timer placed at the finish line. When runners register, they give an estimated time for their run, which places them in a few different speed categories. Each spotter has a list of runner numbers from each category so that they are searching for particular runner numbers throughout the time span of the race. When a runner crosses, the spotter records the time on their sheet. This time is then later fed into a spreadsheet that gives everyone’s time. These results are then collated and printed to give the results list after the race.

I’m trying not to be a hammer looking for a nail here, but this seemed like a perfect opportunity to try to use the power of the computer to reduce some of the mental and paper load of this task. My learning obsession with Python web apps and even more recent desire to learn about databases quickly helped me see some easy ways to do this. These were the main points that I wanted as part of the UI:

  • Upon seeing a runner approach the finish line, the spotter should be able to send a ‘stop’ command at the moment that runner crosses the line. Calculating the finish time relative to the start of the race and recording that information is screaming for a computer solution. This capitalizes on the human spotter’s ability for to recognize a runner’s number by sight, leaving the rest of the work to the program to do.
  • We would need a simple interface for starting the race and stopping individual runners with a button press.
  • A non-trivial number of runners register on the day of the race. There needs to be a way to manually add runners to the database easily.
  • Mistakes also come up in recording times and entering data. Editing a runner’s information, including finish time, is a necessity.
  • Manually entering all the runners into the database before the race? Heck no. The organizers use a spreadsheet to record all of the registration information, which is a CSV file asking to be made and inputted to the database automatically.
  • Creating a list of runners based on category and ranked according to race finish time is another exhausting task when done purely by spreadsheet. This process in the program should make the most of SQL queries and Python/Bottle template features to generate the race results automatically.
  • To properly see if this system would work, I’d need a way of showing numbers passing by similar to what actually happens during a race. I put together a Javascript simulator to do this using Raphael that can be found here. This was especially important in testing the system with my student volunteers.

The organizers agreed to let me run my software as a beta test to see if it would work for future years. More insight and conversation led to the idea of a mobile application to be used to enter runner numbers. I agreed that this would be an easier way to locate runners than looking down a list, but had no idea how to do this. I did research and figured out the jQuery Mobile would be the way to do it. This was a difficult learning process having never done this sort of thing before. I battled with the “ghost click” problem for a while until discovering that the ‘touchend’ event was an easy fix.
Screen Shot 2013-05-26 at 5.12.20 PM


Here’s the software as used on race day:

UPDATE Mar. 2016: I’ve taken down the site to save some memory on my server. Write me if you are interested in the details.

The system worked really well, but ran into some of the same challenges that the pencil-and-paper spotters have been battling since the event’s inception. It’s really hard to simultaneously grab the numbers of a group of 4-5 runners that all come in at once. The system that my students devised for identifying who was going to enter a particular runner approaching the finish line broke down in two specific instances of this, and we missed runners. Luckily pencil and paper picked up the ones we missed. Definitely still in beta. The process of generating results lists and recording times overall worked quite smoothly, and I’m really happy with how it turned out.

Notes:

  • Bottle, Twitter Bootstrap, jQuery Mobile, and vanilla Javascript were all in play.
  • I learned at the race that there are already software packages out there. Now that I’ve done a quick search, it seems that while there is a lot of software out there, the ease of running it through a web interface (and snagging runners through a mobile interface) is a relatively young feature. This project was about me learning to do some new things, and in the end it cost me (and the school) nothing other than time.
  • I learned a lot about user centered design through this project. Usability was a necessity, so I had to start from there and work backwards to build the code needed to make it happen. I really like thinking this way,

Rethinking the headache of reassessments with Python

One of the challenges I’ve faced in doing reassessments since starting Standards Based Grading (SBG) is dealing with the mechanics of delivering those reassessments. Though others have come up with brilliant ways of making these happen, the design problem I see is this:

  • The printer is a walk down the hall from my classroom, requires an ID swipe, and possibly the use of a paper cutter (in the case of multiple students being assessed).
  • We are a 1:1 laptop school. Students also tend to have mobile devices on them most of the time.
  • I want to deliver reassessments quickly so I can grade them and get them back to students immediately. Minutes later is good, same day is not great, and next day is pointless.
  • The time required to generate a reassessment is non-zero, so there needs to be a way to scale for times when many students want to reassess at the same time. The end of the semester is quickly approaching, and I want things to run much more smoothly this semester in comparison to last.

I experimented last fall with having students run problem generators on their computers for this purpose, but there was still too much friction in the system. Students forgot how to run a Python script, got errors when they entered their answers incorrectly, and had scripts with varying levels of errors in them (and their problems) depending on when they downloaded their file. I’ve moved to a web form (thanks Kelly!) for requesting reassessments the day before, which helps me plan ahead a bit, but I still find it takes more time than I think it should to put these together.

With my recent foray into web applications through the Bottle Python framework, I’ve finally been able to piece together a way to make this happen. Here’s the basic outline for how I think I see this coming together – I’m putting it in writing to help make it happen.

  • Phase 1 – Looking Good: Generate cleanly formatted web pages using a single page template for each quiz. Each page should be printable (if needed) and should allow for questions that either have images or are pure text. A function should connect a list of questions, standards, and answers to a dynamic URL. To ease grading, there should be a teacher mode that prints the answers on the page.
  • Phase 2 – Database-Mania: Creation of multiple databases for both users and questions. This will enable each course to have its own database of questions to be used, sorted by standard or tag. A user can log in and the quiz page for a particular day will automatically appear – no emailing links or PDFs, or picking up prints from the copier will be necessary. Instead of connecting to a list of questions (as in phase 1) the program will instead request that list of question numbers from a database, and then generate the pages for students to use.
  • Phase 3 – Randomization: This is the piece I figured out last fall, and it has a couple components. The first is my desire to want to pick the standard a student will be quizzed on, and then have the program choose a question (or questions) from a pool related to that particular standard. This makes reassessments all look different for different students. On top of this, I want some questions themselves to have randomized values so students can’t say ‘Oh, I know this one – the answer’s 3/5’. They won’t all be this way, and my experience doing this last fall helped me figure out which problems work best for this. With this, I would also have instant access to the answers with my special teacher mode.
  • Phase 4 – Sharing: Not sure when/if this will happen, but I want a student to be able to take a screenshot of their work for a particular problem, upload it, and start a conversation about it with me or other students through a URL. This will also require a new database that links users, questions, and their work to each other. Capturing the conversation around the content is the key here – not a computerized checker that assigns a numerical score to the student by measuring % wrong, numbers of standards completed, etc.

The bottom line is that I want to get to the conversation part of reassessment more quickly. I preach to my students time and time again that making mistakes and getting effective feedback is how you learn almost anything most efficiently. I can have a computer grade student work, but as others have repeatedly pointed out, work that can be graded by a computer is at the lower level of the continuum of understanding. I want to get past the right/wrong response (which is often all students care about) and get to the conversation that can happen along the way toward learning something new.

Today I tried my prototype of Phase 1 with students in my Geometry class. The pages all looked like this:

Image

I had a number of students out for the AP Mandarin exam, so I had plenty of time to have conversations around the students that were there about their answers. It wasn’t the standard process of taking quiz papers from students, grading them on the spot, and then scrambling to get around to have conversations over the paper they had just written on. Instead I sat with each student and I had them show me what they did to get their answers. If they were correct, I sometimes chose to talk to them about it anyway, because I wanted to see how they did it. If they had a question wrong, it was easy to immediately talk to them about what they didn’t understand.

Though this wasn’t my goal at the beginning of the year, I’ve found that my technological and programming obsessions this year have focused on minimizing the paperwork side of this job and maximizing opportunities for students to get feedback on their work. I used to have students go up to the board and write out their work. Now I snap pictures on my phone and beam them to the projector through an Apple TV. I used to ask questions of the entire class on paper as an exit ticker, collect them, grade them, and give them back the next class. I’m now finding ways to do this all electronically, almost instantly, and without requiring students to log in to a third party website or use an arbitrary piece of hardware.

The central philosophy of computational thinking is the effort to utilize the strengths of  computers to organize, iterate, and use patterns to solve problems.  The more I push myself to identify my own weaknesses and inefficiencies, the more I am seeing how technology can make up for those negatives and help me focus on what I do best.

Coding IS a super(edu)power

I’ve been really impressed by the Dan Meyer/Dave Major collaboration. If you don’t know what I’m talking about, you need to click on that link immediately. Seeing both Dan and Dave post on their respective blogs about the thought and rationale that goes into these activities is like a masters class in pedagogy, digital media, and user design.

The common thread that I really like about these tools is the clean and minimalist way they pose an idea, encourage a bit of play and intuition, and then get out of the way. Dan has talked about these ideas philosophically for a while, and seeing Dave make these happen is really exciting. They talk about this being the future of textbooks, but I am willing to wager that textbooks will get fidgety at displaying a task to a user atop a blank white screen. The trend has been so far in the other direction that I am skeptical, but I am hopeful that they will start to listen. These exercises are like a visit to the Museum of Modern Art. Textbooks and online learning otherwise tends to look either like a visit to Chuck-E-Cheese or the town library, over-thinking or under-thinking the power of aesthetics to creating a learning environment that is stimulating enough, but not distracting.

Being a committed Twitter follower, I of course interrupted their workflow with suggestions. I was looking for an easy way to collect student responses to a question along the lines of Activeprompt, but for tasks that are not about finding a location. I had posed a question to my Geometry class and was really excited about greasing the rails for gathering student responses and putting them in one place. This is the same idea as what Dan/Dave had done, but with a bit less of a framework pushing it in a direction.

Dave’s suggestion was, well, intimidating:

Screen Shot 2013-03-21 at 4.48.19 PM

I had been playing around with web2py, Django, Laravel, and other template frameworks that said they would make things easy for me, but it just didn’t click how they would do this. I have done lots of small Python projects, but the prospect of making a website seemed downright unlikely. I spent three hours putting together this gem using the CSS I had learned from CodeAcademy:
Screen Shot 2013-03-21 at 4.56.54 PM

I was not proud of this, but it was the best I thought I could do.

Through the power of Twitter, I was able to actually have a conversation with Dave and learn how he put his own work together. He uses frameworks such as Raphael.js and Sinatra in a way that does just enough to achieve the design goal. I learned that he wasn’t doing everything from scratch. He took what he needed from what he knew about these different tools and constructing precisely what he envisioned for his application. I prefer Python to Ruby because, well, I don’t know Ruby. I found Bottle which works beautifully as a small and simple set of tools for building a web application in Python, just as Dave had done with his tools.

Using Bottle and continuing to learn how it works, I made this yesterday.
BFwz3k5CQAEE2ts.png-large

I shared it with Dave, and he revealed another of his design secrets: Bootstrap. Again, dumbstruck by the fact this sort of tool exists, but also that I hadn’t considered that it might. This led me to clean up my previous submission and reconsider what might be possible. With a bit more tinkering, I turned this into what I had envisioned: a flexible tool for collecting and sharing student responses to a question
Screen Shot 2013-03-21 at 5.12.14 PM

I was just tickled pink. Dave had shown me his prototype for what he made in response to my prompt – I was blown away by it, as with the rest of his work. Today, however, I proudly used my web app with two of my classes and was happy to see that it worked as designed.

The point behind writing about this is not to brag about my abilities – I don’t believe there is anything to brag about here. Learning to code has gotten a good mix of press lately on both the positive and negative side. It is not necessarily something to be learned on its own, for its own sake.

I do want to emphasize the following:

  • My comfort with coding is developed enough at this point that I could take my idea for how to do something in the classroom using programming and piece it together so that it could work. I got to this point by messing around and leaving failed projects and broken code behind. This is how I learn, and it has not been a straight line journey.
  • If I was not in the classroom on a regular basis, I doubt I would have these ideas for what I could do with coding if I had the time to focus on it completely. In other words, if I ditched the classroom to code full time (which I am not planning to do) I would run out of things to code.
  • Twitter and the internet have been essential to my figuring out how to do this. Chatting virtually with Dave, as an example, was how I learned there was a better way than the approach I was taking. There are no other people in my real world circles who would have introduced me to the tools that I’ve learned about from Dave and other people in the twitterverse. Face to face contact is important, but it’s even better getting virtual face time with people that have the expertise and experience to do the things I want to learn to do.
  • I have been writing code and learning to code from the perspective of trying to do a specific and well defined task. This is probably the most effective and authentic learning situation around. We should be looking for ways to get students to experience this same process, but not by pushing coding for its own sake. As with any technology, the use needs to be defined and demanded by the task.
  • The really big innovations in ed-tech will come from within because that’s where the problems are experienced by real people every day. Outsiders might visit and see a way to help based on a quick scan of what they perceive as a need. I’m not saying outsiders won’t or can’t generate good ideas or resources. I just think that tools need to be designed with the users in mind. The best way to do this is to give teachers the time, resources, and the support to build those tools themselves if they want to learn how.

You can check out my code at Github here. Let me know if you want to give it a shot or if you have suggestions. This experiment is far from over.

Cell phone tracking, Processing, and computational thinking

I gave a survey to my students recently. My lowest score on any of the questions was ‘What I learn in this class will help me in real life.’ I’ve given this question before, and am used to getting less than optimal responses. I even think I probably had a higher score on this question than I have received previously, but it still bothers me that we are having this discussion. Despite my efforts to include more problem solving, modeling, and focusing on conceptual understanding related tasks over boring algorithmic lessons, the fact that I am still getting lower scores on this question compared to others convinces me that I have a long way to go.

I came up with this activity in response. It combines some of the ideas I learned in my Udacity course on robotic cars with the fact that nearly all my students carry cell phones. While I know many cell phones have GPS, it is my understanding that phones have used cell towers for a while to help with the process of locating phones. It always amazes me, for example, how my cell service immediately switches to roaming immediately when driving across the US-Canada border, even when I had a non-GPS capable phone.

My students know how to find distance using the distance formula and sets of coordinates, but they were intrigued by the idea of going backwards – if you know your distance from known locations, can you figure out your own location? The idea of figuring this out isn’t complicated. It can most easily be done by identifying intersections of circles as shown below:

One of my students recalled this method of solving the problem from what he saw in the movie Taken 2 , and was quickly able to solve the problem this way graphically in Geogebra. Most students didn’t follow this method though – the general trend was to take a guess and adjust the guess to reduce the overall error until the distances were as close to the given distances as possible.

I got them to also look at other situations – if only two measurements to known locations are known, where could the cell phone be located? They played around to find that there were two locations in this case. I again pointed out that they were following an algorithm that could easily be taught to a computer.

I then showed them a Processing sketch that went through this process. It is not a true particle filter that goes through resampling to improve the guessed location over time, but it does use the idea of making a number of guesses and highlighting the ones with the lowest error. The idea of making 300,000 random guesses and choosing the ones that are closest to the set of distances is something that computers are clearly better at than humans are. There are analytical ways of solving this problem, but this is a good way of using the computational power of the computer to make a brute force calculation to get an approximate answer to the question.

You can look at the activity we did in class here:
Using Cell Phones to Track Location

Who’s gone overboard modeling in Physics? This guy, part I.

I’ve been sticking to my plan this year to follow the Modeling Instruction curriculum for my regular physics class. In addition to making use of the fantastic resources made available through the AMTA, I’ve found lots of ways to use Python to help drive the plow through what is new territory for me. I’ve always taught things in a fairly equation driven manner in Physics, but I have really seen the power so far of investing time instead into getting down and dirty with data in tables, graphs, and equations when doing so is necessary. Leaving equations out completely isn’t really what I’m going for, but I am trying to provide opportunities for students to choose the tools that work best for them.

So far, some have embraced graphs. Some like working with a table of data alone or equations. The general observation though is that most are comfortable using one to inform the other, which is the best possible outcome.

Here’s how I started. I gave them the Python code here and asked them to look at the lines that configure the program. I demonstrated how to run the program and how to paste the results of the output file into Geogebra, which created a nice visualization through this applet. Their goal through the activity was to figure out how to adjust the simulation to generate a set of graphs of position and velocity vs. time like this one:

Some used the graph directly and what they remembered from the constant velocity model (yeah, retention!) to figure out velocity and initial position. Others used the table for a start and did a bit of trial and error to make it fit. While I have always thought that trial and error is not an effective way to solve these types of problems, the intuition the students developed through doing came quite naturally, and was nice to see develop.

After working on this, I had them work on using the Python model to match the position data generated by my Geogebra Particle Dynamics Simulator. I had previously asked them to create sets of data where the object was clearly accelerating, so they had some to use for this task. This gave them the chance to not only see how to determine the initial velocity using just the position data, as well as use a spreadsheet intelligently to create a set of velocity vs. time data. I put together this video to show how to do this:

[wpvideo bQyM2woe].

It was really gratifying to see the students quickly become comfortable managing a table of data and knowing how to use computational tools  to do repeated calculations – this was one of my goals.

The final step was setting them free to solve some standard  Constant-Acceleration kinematics problems using the Python model. These are problems that I’ve used for a few years now as practice after introducing the full set of constant acceleration equations, and I’ve admittedly grown a bit bored of them.Seeing how the students were attacking them using the model as a guide was a way for me to see them in a whole new light – amazingly focused questions and questions about the relationship between the linear equation for velocity (the only equation we directly discussed after Day 1), the table of velocity data, and what was happening in position vs. time.

One student kept saying she had an answer for problem c based on equations, but that she couldn’t match the Python model to the problem. In previous classes where I had given that problem, getting the answer was the end of the story, but to see her struggling to match her answer to what was happening in her model was beautiful. I initially couldn’t do it myself either until I really thought about what was happening, and she almost scooped me on figuring it out. This was awesome.

They worked on these problems for homework and during the beginning of the next class. Again, some really great comments and questions came from students that were previously quiet during class discussions. Today we had a learning standard quiz on constant acceleration model questions, and then decided last night during planning was to go on to just extending the constant acceleration model to objects in free fall.

Then I realized I was falling back into old patterns just telling them that all objects in free fall near Earth’s surface accelerate downward at roughly 9.81 m/s^2. Why not give them another model to play with and figure this out? Here’s what I put together in Python.

The big plus to doing it this way was that students could decide whether air resistance was a factor or not. The first graph I showed them was the one at right – I asked whether they thought it could represent the position versus time graph for an object with constant acceleration. There was some inconsistency in their thinking, but they quickly decided as a group after discussing the graph that it wasn’t. I gave them marble launchers, one with a ping-pong ball, and another with a marble, and asked them to model the launch of their projectiles with the simulation. They decided what they wanted to measure and got right to it. I’m also having them solve some free fall problems using the gravity simulation first without directly telling them that acceleration is constant and equal to g. They already decided that they would probably turn off air resistance for these problems – this instead of telling them that we always do, even though air resistance is such a real phenomenon to manage in the real world.

A bit of justification here – why am I being so reliant on the computer and simulation rather than hands on lab work? Why not have them get out with stopwatches, rulers, Tracker, ultrasonic detectors, air tracks, etc?

The main reason is that I have yet to figure out how to get data that is reliable enough that the students can see what they have learned to look for in position and velocity data. I spent an hour working to get a cart on an inclined air track to generate reasonable data for students to use in the incline lab in the modeling materials from AMTA on constant acceleration, and gave up after realizing that the students would lose track of the overall goal while struggling to get the mere 1 – 2 seconds of data that my 1.5 meter long air track can provide. The lab in which one student runs and other students stand in a line stopping their stopwatches when the runner passes doesn’t work when you have a small class as I do. The discussions that ensue in these situations can be good, but I have always wished that we had more data to have a richer investigation into what the numbers really represent. The best part of lab work is not taking data. It’s not making repetitive calculations. Instead, it’s focusing on learning what the data tells you about the situation being measured or modeled. This is the point of spending so much time staring and playing with sets of data in physics.

I also find that continuing to show students that I can create a virtual laboratory using several simple lines of code demonstrates the power of models. I could very easily (and plan to) also introduce some random error so the data isn’t quite so smooth, but that’s something to do when we’ve already understood some of the fundamental issues. We dealt with this during the constant velocity model unit, but when things are a bit messier (and with straight lines not telling the whole picture) when acceleration comes into play, I’m perfectly comfortable with smooth data to start. Until I can generate data as masterfully as Kelly does here using my own equipment, I’m comfortable with the computer creating it, especially since they can do so at home when they think nobody is looking.

Most of all, I find I am excited myself to put together these models and play with the data to model what I see. Having answered the same kinematics questions many times myself, being able to look at them in a new way is awesome. Finding opportunities for students to figure out instead of parrot responses after learning lists of correct answers is the best part of teaching, and if simulations are the way to do this, I’m all for it. In the future, my hope is to have them do the programming, but for now I’m happy with how this experiment has unfolded thus far.

Simulations, Models, and the 2012 US Election

After the elections last night, I found I was looking back at Nate Silver’s blog at the New York Times, Five Thirty Eight.

Here was his predicted electoral college map:

Image

…and here was what ended up happening (from CNN.com):

Image

I’ve spent some time reading through Nate Silver’s methodology throughout the election season. It’s detailed enough to get a good idea of how far he and his team  have gone to construct a good model for simulating the election results. There is plenty of description of how he has used available information to construct the models used to predict election results, and last night was an incredible validation of his model. His popular vote percentage for Romney was predicted to be 48.4%, with the actual at 48.3 %. Considering all of the variables associated with human emotion, the complex factors involved in individuals making their decisions on how to vote, the fact that the Five Thirty Eight model worked so well is a testament to what a really good model can do with large amounts of data.

My fear is that the post-election analysis of such a tool over emphasizes the hand-waving and black box nature of what simulation can do. I see this as a real opportunity for us to pick up real world analyses like these, share them with students, and use it as an opportunity to get them involved in understanding what goes into a good model. How is it constructed? How does it accommodate new information? There is a lot of really smart thinking that went into this, but it isn’t necessarily beyond our students to at a minimum understand aspects of it. At its best, this is a chance to model something that is truly complex and see how good such a model can be.

I see this as another piece of evidence that computational thinking is a necessary skill for students to learn today. Seeing how to create a computational model of something in the real world, or minimally seeing it as an comprehensible process, gives them the power to understand how to ask and answer their own questions about the world. This is really interesting mathematics, and is just about the least contrived real world problem out there. It screams out to us to use it to get our students excited about what is possible with the tools we give them.

Automating conference scheduling using Python

I’ve always been interested in the process of matching large sets of data to a set of constraints – apparently the Nobel committee agreed this past week in awarding the economics prize. The person in charge of programming at my school in the Bronx managed to create an algorithm that generated a potential schedule for over four thousand students given student requests and needs. There was always some tweaking that needed to be done at the end to make it work, but the fact that the computer was able to start the process always amazed me. How do you teach a computer to do this sort of matching in an efficient way?

This has application within my classroom as well – generating groups based on ability, conflicting personalities, location – all complex situations that required time and attention to do correctly. In the end though, this is the same problem as arranging the schedules. It’s easy to start with a random arrangement and then make adjustments based on experience. There has to be a way to do this in an automated way that teaches the computer which placements work or do not. Andy Rundquist does this using genetic algorithms – I must know more about how he does it, as this is another approach to this type of problem.

This became a more tangible challenge for me to attempt to solve last year when I saw that the head of school was doing the two days of parent-teacher conference scheduling by hand. This is a complex process given the following constraints he was working to fulfill:

  • Parent preferences for morning/afternoon conference times.
  • Consecutive conference times for parents that had siblings so that the amount of time parents had to wait around was minimized.
  • Balanced schedules between the two days for all teachers.
  • Teachers with children had breaks in their schedule to attend conferences of their children.

This was apparently a process of 4 – 5 hours that sometimes required starting over because he discovered that the schedule he had started putting together was over constrained and could not meet all requirements. During this process, however, he had figured out an algorithm for what was most likely to work. Schedule the families with the largest number of children first, and work down the list in order of decreasing size. Based on the distribution of younger vs. older children in the school, start by scheduling the youngest children in a family first, and move to the older ones. Save all families with single children for last.

Hearing him talk about this process was interesting and heartbreaking at the same time – he works incredibly hard on all aspects of his job, and I wanted to provide some way to reduce the requirements of at least this task on his schedule. I was also looking for a reason to really learn Python, so this challenge became my personal exercise in problem based learning.

It took a while to figure out all of the details, but I broke it down into stages. How do you input the family data based on how it is already stored by the front office? (I didn’t want to ask the hard-working office staff to reformat the data to make it easier for me – this was supposed to make things easier on everyone.) How do you create a structure for storing this data in Python? How do you implement the algorithm that the head of school used and balance it with the idea of fairness and balance to all families and teachers?

Over the following few months, I was able to piece it together. It was, needless to say, a really interesting exercise. I learned how to ask the right questions that focused on the big picture needs of the administration, so that I could wrestle with the details of how to make it happen. The students learned that I was doing this (“Mr. Weinberg is using his robots to schedule conferences!”) and a few wanted to know how it worked. I have posted the code here as a gist.

I put in more than the 4-5 hours required to do this by hand. It was a learning experience for me. It also paid serious dividends when we needed to schedule conferences again for this year. We wanted to change the schedule slightly to be one full day rather than two half days, and it was a simple task adjusting the program to do this. We wanted to change the times of conferences so that the lower and upper schools had different amounts of time for each, rather than being a uniform twenty minutes each. (This I was not able to figure out before we needed conferences to go out, but I see a simple way to do it now.)

The big question that administration was about the upper school conferences. Last year we had seven different rooms for simultaneous conferences, and the question was whether we could reduce the number to five. I ran the program with five rooms a number of different times, and it was unable to find a working schedule, even with different arrangements and constraints. It was able to find one that worked with six rooms though, which frees administrators from needing to be in individual conference rooms so that they can address issues that come up during the day. Answering that question would not have been possible if scheduling was done by hand.

The question of using computers to automate processes that are repetitive has been in my head all this year. I’ve come to recognize when I am doing something along these lines, and try to immediately switch into creating a tool in Python to do this automatically. On the plane during a class trip last week, we needed to arrange students into hotel rooms, so I wrote a program to do this. I used it this week to also arrange my Algebra 2 students in groups for class. Generating practice questions for students to use as reassessment? I always find myself scrambling to make questions and write them out by hand, but my quiz generator has been working really well for doing this. Yesterday I had my first day of generating quizzes based on individual student needs.

The students get a kick out of hearing me say that I wrote a Python program to do XXX or YYY, and their reactions certainly are worth the effort. I think it just makes sense to use programming solutions when they allow me to focus on more important things. I have even had some success with getting individual students to want to learn to do this themselves, but I’ll write more about that later.

Progress on Python-Powered randomized quiz generator

One of the projects floating around in my head since the end of last year is creating an easy to use tool that will automatically generate questions for students to test their skills either on their own or while in class. My first attempt at this was during a unit in Geometry on translations, my first attempt at implementing standards based grading. I was taking a Udacity course on web applications and realized that if I could write a quiz generator online, it would be the easiest way to give students a sense of how they were doing without needing me to be part of the process.

As most people doing reassessments tend to be, I was a bit overwhelmed with the paperwork side of things, especially because many of the students just wanted to know if they were right or not. I had made some Python programs to generate quiz questions one by one and decided to try to adapt it to the web application so students could input their answers to questions that had different numbers every time. I had tried to use other options such as PollEverywhere, Socrative to at least collect the data and check it as right/wrong (which would have been good enough for a start in terms of collecting data, but left out the randomization part). The problem with these is that I believe they are hosted in the US and are incredibly slow without a VPN. I needed a solution that was fast, and if I could add the randomization, that would be even better. I decided to try to adapt my quiz generator to a Google App Engine hosted web application.

Needless to say (at least for me) this was not an easy task. I had a loose understanding of how to manage GET and POST requests and use cookies to store random values used. The biggest challenge came from checking answers on the server side. For someone figuring out Python concept as he goes, it involved a lot of fists on the keyboard at the time. My attempt is posted here. There were tons of bugs (and still are) but I at least got up the nerve to try it in class. The morning I was excited to premiere it, I also found out another interestingly infuriating nugget of info: Google App Engine is blocked in China.

I gave up at the time, as it was almost summer. I was interested in helping out with the development of the Physics Problem Database project during the summer, but opportunities for sitting down and coding while on a whirlwind tour of the US seeing friends and family weren’t that numerous. It’s amazing to see how John, Andy, and others have gotten the database site together and doing functionally cool things in a short amount of time. I spent some time over the summer learning PHP and MYSQL, but was pulled back into Python when I saw the capabilities of webpy and web2py to do applications. I see a lot of features and possibility there, but fitting my ideas to that framework is beyond what I know how to do and what I have been able to figure out during my time prepping and starting school. That will come later.

I keep coming back to the fact that randomization needs to be built into the program interface from the beginning. I want students that need to practice to be able to do so with different problems each time, because that frees them from needing me to be there to either generate them myself or prevent them from creating impossible problems. I want the reassessment process to be as simple as possible, and for the lowest level skills, they don’t necessarily need me to be testing them in person. That’s what in person interviews and conversations (including those through BlueHarvest) are all about. I won’t rely on a tool like this to check proficiency, but it’s a start for giving students a tool that will get them thinking along those lines.

I’ve had the structure for how to do this in my head for a while, and I started sketching out what it would be in a new Python program last week. This morning, after learning a bit more about the newer string formatting options in Python that offer more options than basic string substitution, I hunkered down and put together what is at least a workable version of what I want to do.

Please visit here to see the code, and here to give it a shot on repl.it.

The basic structure is that every question can use either random integers, an irrational decimal value, or signed integers in its text. With all of the messiness of methods to generate and replace the random numbers inside the Question class, it is fairly easy to generate questions with random values and answers. I admit that the formatting stinks, but the structure is there. I could theoretically make some questions for students this way that could be used on Monday, but I probably won’t just yet. I think a nap is in order.

Next steps:

  • I need to work on the answer checking algorithm. At the moment it just compares an entered decimal answer to being within a certain tolerance of the calculated answer. My plan is to expand the Question definition to include another input variable for question type. Single numerical answers are one question type, Coordinates are another, and symbolic equations or expressions are yet another one I’d like to include. Based on the question type, the answer method in the Question class can be adjusted.
  • As an extension to this, I’d like to include sympy as part of this for making both question generation and answer checking. It has the ability to show that two symbolic expressions are equal to each other, among many other really nice capabilities. This will let me generate all sorts of nice Calculus and algebraic manipulation questions without too much difficulty.
  • I’d like to be able to format things nicely for algebraic questions, and possibly generate graphical questions as well.
  • The ultimate goal is to then get this nicely embedded as a web application. As I mentioned before, there is too much going on in the web2py framework for me to really get how to do this, but I think this is something I can do with a bit of help from the right sources.

I’m having a ball learning all of this, and to know that it will eventually make for a nice learning tool that students will benefit from using is a nice incentive for doing it.

Winning the battle over Python programming

Two stories to share after this week’s activities with students about programming. I have posted previously about my interest in making Python a fundamental part of my classes this year, and so I am finding ways to include it when it makes sense to do so.

I have a couple of students that are bridging the gap between Algebra 2 and Precalculus with an independent study that I get to design. The tentative title of the course for their transcript is ‘Fundamentals of Mathematical Thinking’ and the overall goal is to get these students a chance to develop their fundamental skills to be successful in later classes. I see it as an opportunity to really dig in to some cool mathematical ideas and get them to, well, dig into the fundamentals of mathematical thinking. I don’t plan too much emphasis on the algorithms (though we will spend some time working on skills in algebra, polynomial manipulation, functions, and other crucial topics where they are weak). Looking at a situation, exploring the way different variables might be used to model that situation, and then really digging in to abstract the variables into a model.

We are starting with what I think is the most fundamental application of this: sequences and series. Even simpler, the first task I gave the students was to look at the number of bricks in the rows of a triangular tower and use Python to add up the bricks in each row. This started as a couple of exercises getting to know Python’s syntax. They are then taking programs I wrote to model this problem and adjusting them to find other sums, including the sum of even and odd numbers. One student that completed this task was intrigued that the sum of the latter consisted of perfect squares, but we didn’t explore it any further at this point.

I then gave this student a bunch of sequences. His task was simple: model each one in Python and generate the given terms. This is a standard exercise for Algebra & Precalc students by hand, but I figured that if he could do this with Python, clearly he was able to figure out the pattern. I showed him how to write fractions using string concatenation (e.g. 1/3 = 1 + “/” + 3) which enabled him to develop the harmonic series. Today he figured out Fibonacci and a couple other new ones. It was really fascinating to see him mess around think deeply about the patterns associated with each one. I did tap him slightly in the right direction with Fibonacci, but I have otherwise been hands off. I am also having him write about his work to give him opportunities to work on his writing too. When he feels comfortable sharing it (and I have already warned him that this is the plan), I will post links to his work here.

The other new thing was in Calculus. I have shortened my review of Pre-Calculus concepts substantially, and have made the first unit a survey of limits, rate of change, and definite integrals. Most of this has required technology to explore local linearity and difference quotients. On Thursday, I introduced using rectangular sums to find area – they were otherwise stuck on counting boxes, and I could tell they felt it was like baby math. They really didn’t know any other way.

In showing them rectangular sums, we had some pretty good discussions about overestimating and underestimating. The students had conversations about how rough the approximation with only 3 – 5 rectangles gave for area under a parabola. A couple of them figured out how to use more rectangles. I told them I was going to write a program to do this while they were sitting and working. I created this program and talked them through how it works. They thought it was too complicated to be worth the time, but I think they did understand the basic idea. I then changed the value of N and asked them what they thought that meant. They got it right the first time. I then pushed the value to higher and higher values of N and they immediately saw that it was approaching a limit. Game, set, match.

Today I had the AP students together working on another definite integral activity that focused on the trapezoidal rule. I showed them the code again and gave them the line that calculates area. It wasn’t too much of a stretch for them to work their way to adjusting the program to work for the Trapezoidal rule. We ran out of time to discuss comparisons between the two programs, but they stayed late after class and into their lunch getting it working on their own computers and playing a bit. Here is what we came up with.

The big battle I see is two-fold.

  • Help students not be intimidated by the idea of writing a program to do repetitive calculations.
  • Give students opportunities to see it as necessary and productive to use a computer to solve a problem.

Sometimes these battles are the same, other times they are different. By using the built-in version of Python on their Macs, I have already started seeing them run commands and use text editors to create scripts without too much trouble. That’s the first battle. My plan is to give lots of examples supporting the second one in the beginning, and slowly push the burden of writing these programs on to the students as time goes by and they become more comfortable with the idea. So far I am feeling pretty good about it – stay tuned.