If I had a clone, all of my code would be beautiful.

St. Paul's butte

Last week, I was a speaker at the Tribal Disability Conference in Turtle Mountain, where I spoke on starting a business. Then, I went for a site visit at Spirit Lake Vocational Rehabilitation followed by another talk on self-employment at the Tribal Disability Awareness conference. In a nutshell, I talked about how having a disability often teaches people to persevere, to not accept when told they can’t do something, to find different ways of meeting goals and solicit other people to help them – and pointed out that all of these traits can be an advantage in starting a business.

Along the way, I was working on a couple of grants, edited a couple of papers – and just this second remembered I have to finish editing a paper I co-authored for something – crap!

There was also the usual matter of approving payroll and invoices, answering email and reviewing work people did while I was gone – new teaching videos to go into the game, artwork, animation, sound files,documentation, bug fixes. Haven’t nearly finished with that.

I’m super-stoked to be on a panel on Monday at the National Council of La Raza conference, “Economic Empowerment in a Wireless World”. I’m planning on going Sunday as well, to a lot of the sessions on education.

Heidi Heitkamp

I got to hear Heidi Heitkamp speak at Turtle Mountain last week and with any luck I’ll be able to attend Elizabeth Warren’s talk on Sunday. Must be my week for Democratic senators.

Somewhere in all of that, I finished my slides and video for the Serious Play conference, also this week, which I am also excited to attend.

Then, there was the meeting people for lunch, stopping in on my daughter who had surgery and checking on her and all of the other general life things. There is a board meeting I have to get up and go to in about nine hours, which I am definitely NOT excited about, but I’m the chair, so I kind of have to show up.

In the midst of all of this, there are 77 fixes and improvements in the Fish Lake game, from “add a better message when the pretest is completed” to “Revise quiz code for re-routing students. This is replicated in many quizzes. Make external file ref & just call it in all of those”.  Some of those are crucial – like I never wrote the quiz for one spot and so that is a dead end.

There are another 47 improvements for Spirit Lake. All of those are to make the game better. For example, we recorded voices from kids at Spirit Lake, and when a student gets a problem wrong, I want to add a video clip that shows one of the game characters and says something like,

“No, 7 x 8 = 56. Now your village burned down.”

The kids did a great job and I think those clips will really help players remember their multiplication tables.

burning village

But … back to my missing quiz. It has to be on mixed fractions, with questions answered using both improper fractions and mixed fractions. There also should be a question with two answers for the numbers that the mixed fraction falls between. Also, at least two word problems, with answers that are whole numbers.

As each question is answered, the program needs to determine if it is the right answer, and, if so, add to the total score, then show a slightly more difficult problem. At the end of the quiz, the student is shown  a success message and the student data written to our database and routed back to the game. If it is the wrong answer, the student is shown a failure message and routed to the appropriate page to study.

In the process of writing this, by the way, I noticed that one of the links on the study page is wrong, so I need to fix that. Apparently, I meant to write something involving turtle eggs. Also, there is a video Diana did on mixed fractions which I have yet to review because I got back at midnight on Wednesday and dived into everything else.

So … back to my no-longer-missing quiz. It is done. I even put in a few comments. As I was writing it, I was thinking, “some of this code is duplicated” and “I bet I could re-write some of these functions so they were more general and then not have so many functions” and a whole lot of other ideas for making it just a better program.

I KNOW that the world is full of code that gets written to be fixed “another day” is still sitting there six years later. In my defense, I will say that I do often loop back around and fix that code – although it might be a year or two later.

Here is my compromise – when I am in town, I try, come hell or high water, to make at least one substantive improvement on one of the games every day – a new video clip, a new quiz. At worst, I may not get any more done than fixing a broken link or touching up a graphic or sound file, but I really try to do more than that. Those 124 fixes are down from 266. It is not perfect but it is progress and it is 1 a.m. In addition to writing this post, I did review one more instructional video and sent feedback, finished the first draft of editing the paper and added improving the code in this quiz as a lower priority game fix.

My code is not perfect but it works, and I will come back and try to do better tomorrow because, at the end of the day, there’s another day. That’s how time works.

 

 

 

More notes from the text mining class. …

This is the article I mentioned in the last post, on Singular Value Decomposition

ftp://ftp.sas.com/techsup/download/EMiner/TamingTextwiththeSVD.pdf

Contrary to expectations, I did find time to read it, on the ride back from Las Vegas and it is surprisingly accessible even to people who don’t have a graduate degree in statistics, so I am going to include it in the optional reading for my course.

Many of these concepts like start and stop lists apply to any text mining software but it just happens that the class I’m teaching this fall uses SAS

———
In Enterprise Miner, you can only have 1 project open at a time, but you can have multiple diagrams and libraries, and of course, zillions of nodes, in a single project

In Enterprise Miner, can use text or text location as a type of variable. Documents < 32K in size can be contained in project as a text variable. If greater than 32K, give a text location.

Dictionaries

  • start lists – often used for technical terms
  • stop lists, e.g. articles like “the”, pronouns. These appear with such frequency in documents they don’t contribute to our goal which is to distinguish between documents. May also include words that are high frequency in your particular data. For example, mathematics, in our data, because it is in almost every document we are analyzing

Synonym tables
Multi-word term tables – standard deviation is a multi-word term

Importing a dictionary — go to properties. Click the …. next to the dictionary (start or stop) you want to import. When it comes up with a window, click IMPORT

Select the SAS library you want. Then select the data set you want. If you don’t find the library that you want, try this:

  1. Close your project.
  2. Open it again
  3. Click on the 3 dots next to PROJECT START CODE in the property window
  4. Write a LIBNAME statement that gives the directory where your dictionaries are located.
  5. Open your project again

[Note:  Re-read that last part on start code. This applies to any time you aren't finding the library you are looking for, not just for dictionaries. You can also use start code for any SAS code you want to run at the start of a project. I can see people like myself, who are more familiar with SAS code than Enterprise Miner, using that a lot.]

Filter viewer – can specify minimum number of documents for term inclusion

 

—————-

Jenn and ChrisSpeaking of Las Vegas, blogging has been a little slow lately since we took off to watch The Perfect Jennifer get married. It was a very small wedding, officiated by Hawaiian Elvis. Darling Daughter Number Three doubled as bartender and bridesmaid then stayed in Las Vegas because she has a world title fight in a few days.

Given the time crunch, I was particularly glad I’d attended this course that gave me the opportunity to draft at least one week’s worth of lectures in the fall. When I finish these notes, my plan is to to edit them and turn it into the last lecture in the data mining course. If it’s helpful to you, feel free to use whatever you like. I’ll try to remember to post a more final version in the fall. If you have teaching resources for data mining yourself, please let me know.

My crazy schedule is the reason I start everything FAR ahead of time.

 

Captain Obvious wearing her obvious hat

Captain Obvious is wearing a hat

Maybe this is obvious, but I have often found that what is obvious to some people is not so obvious to others, so here are a few random tips.

1. Enterprise Miner can take a REALLY long time to load during which you wonder if anything is happening at all.

task manager

Open up the task manager and look for something that says javaw.exe *32  You can see it near the bottom in the image above. The number next to it should be going up, from 30,000 to 50, 000 etc. If it is, you should probably be patient for a few more minutes and your session will start.

2. Let’s say you want to change the properties of something. For example, I don’t want the data set to be partitioned into Training, Validation and Test in a 40, 30, 30 split. I want it to be 50, 50, 0.  So, I right-click on the DATA PARTITION node, get a drop-down menu and

diagram window with properties at left

 

there is all of this stuff about Edit Variables all the way down to Disconnect Nodes, where the hell are the properties to change? They’re on the left, in that window with the title Property!  Funny, but it’s so easy to focus on the diagram window and completely forget about everything else. Click on a node and it’s properties will show up in the window.

3. While the three screens you see when you run the StatExplore node are pretty interesting, it would be nice to have a more detailed look at your data. Just go to the VIEW menu and you can get more statistics, like the cell chi-square values, descriptive statistics of numeric variables broken down by the levels of your target variable.

Menu with window optionsNow that you are starting to see some of what you can do with Enterprise Miner, you’ll be wondering what MORE you can do, like decision trees, for example. I’m glad you asked that question ….

After all of the effort to get Enterprise Miner installed, I thought it better do something good. It is interesting to use. Unlike programming where you can get a program to run but give you errors or unexpected results, so far (key phrase!), with Enterprise Miner I have found the problem to be knowing exactly what to select, for example, with CREATE DATA sources. Once you know that, however, it seems pretty hard to make an error.

Goat on a mountainEnterprise Miner does do some pretty cool stuff, which makes it worth the pain of getting it installed. Even way cooler, unlike back in the day when no one could get their hands on it without paying approximately $4,893,0893.16 , their first born child, their left kidney and an albino goat, if you are an instructor or a student, you can get it for free through SAS On-Demand for Academics.

(And, yes, for the record, I *am* aware that said goat is not an albino. I was fresh out of pictures of albino goats. Deal with it.) 

Speaking of Enterprise Miner,  I thought I would ramble on about the good parts for a few posts, since I’m getting ready to teach data mining in the fall and I hate to do anything at the last minute.

One of the good parts is StatExplore. At first glance, it looks good, but at second glance, it looks better.

All you need to do is create a diagram by going to the FILE menu, then selecting NEW and then DIAGRAM.

You can start by dragging a data source on to the diagram. In this example, I used the heart data set from the Framingham Heart Study, which happens to ship with Enterprise Miner in the SASHELP library.

I drag the data set from data sources to the diagram window.

Next, I click on the EXPLORE tab just above the diagram window. This gives you a bunch of icons. Enterprise Miner is just rife with icons. Never fear, though, if you have no idea what this bunch of colored boxes is supposed to mean versus  that bunch, just hover over the icon with your mouse and it will tell you.

diagram

Here is my diagram. Simple, no?  It gives you a bunch of cool stuff. First, you have the plot of chi-square values for all nominal variables.

Chi-square plot

You can see that sex has the highest chi-square (as in gender, not as in frequency of), followed by cholesterol status, smoking status and weight status.  I find this rather surprising. I knew women lived longer than men, but with all of the discussion of obesity, I thought weight would be higher up there.

The next chart gives me the worth of each variable in predicting my target, which in this example is death.

plot of variables in order of predictive value

The variable on the far left is age at start. Not surprisingly, the older people are when you start following them, the more likely they are to die in a given period of time. The next variable is Age at CHD Diagnosis, followed by two blood pressure measures, their cholesterol, then cholesterol status – weight status is down at the end.

statistics

 

This analysis produces A LOT of statistics. This, I found interesting because despite some people arguing Enterprise Miner allows analysis by someone without extensive programming or statistics background, certainly in the case of statistics, the more knowledge you have, the better you could make use of the results.

For example,  in the top right (all three of the screen shots above are one screen, I broke them up at an attempt at legibility), the output pane gives descriptive statistics broken down by each level of the target variable. I can see how many people who died had missing data for age at CHD diagnosis, skewness and kurtosis values for variables by status, living or dead, the mode for weight status for people who were living or dead, and a whole lot more. Interestingly, 68% of the whole sample was overweight.

Scrolling through the statistics output I can get a good idea of the data quality – is it skewed, is it missing, is it missing at random.

Without some background in statistics, that’s probably no more than a bunch of numbers. Personally, I found it very helpful. That’s another assignment for the students, to write a brief summary of their data, including any concerns. There weren’t any real problems with these data except for the obvious fact that variables like cholesterol and cholesterol status,smoking and smoking status are going to be highly correlated. It would be a good idea to include one of those as input in any predictive analyses and reject the other to prevent multicollinearity problems.

(NOTE to self: Make sure to explain variable roles, changing variable roles in EM and multi-collinearity.)

You might think this is adequate for running just one node, but, in fact, there is much more here than meets the eye. More on that tomorrow because speaking of overweight, I have been at a computer for 13 hours today and I want to hope on the  bike and get some exercise in before I knock out the last task I need to do today. Although @sammikes just pointed out on twitter that round is a shape, it is not the one I want to be in.

Most likely, you,too, have experienced homicidal urges when confronted with a problem you have spent five hours trying to solve on your computer, only to call tech support and have them report,

Well, it works fine on my computer.

You’d think if that solved the problem that they would offer to box up their computer and send it over to your house but, alas, they never do.

This is the reason that any software I use for class I test on several computers under different conditions. After having initially failed to get SAS On-Demand for Enterprise Miner to work with boot camp on the Mac, I tried it on a Lenovo machine running Windows 8. I had to install the JRE and ignore a few security warnings, but after that it worked.

[For how I did eventually get it working with boot camp, click here, and thank Jason Kellogg from SAS. ]

Next, I needed to upload some data. The SAS instructions say to use your favorite FTP client and coincidentally, I do have a favorite FTP client (Filezilla), so I downloaded it to the testing machine.

Only the professor can upload data to the class directory, and most professors probably have an FTP program on their personal computer (or maybe not, do you?) Even if you normally do, you may, like me, have borrowed a machine to use for testing or have a new computer. Whatever, this just reinforces my argument that you should never, never plan to use any kind of software in a class unless you have ample time to prepare.

I know that there are schools that ask adjuncts to teach on a week or two notice. That seems to me a recipe for disaster for both the professor and students, unless maybe you are doing something that hasn’t changed in 50 years and requires no technology,  like reading Chaucer, I recommend you follow the advice of Nancy Reagan and “Just say no.”

Here are my first few hints:

  1. Test the software on multiple machines and multiple operating systems.
  2. Make sure one of those machines is on the older, under-powered end of the spectrum, as students often don’t have a lot of extra cash and may not have the shiniest, newest machine like you have on your desk.
  3. Test it on the latest operating system. It may turn out that the version your school has does not work with Windows 11. (I did not have that problem with the Enterprise Miner this time, but I’ve had it with other software in the past so it is a good idea.)
  4. Find out what other software you might need, for example, some kind of FTP program in this case, and install it on your computer, if necessary.
  5. Give yourself plenty of time to do all of the above.

You might think these types of things would be handled by the information technology department at your university, and you may be really lucky and that will be so. In many schools, the IT department basically helps re-set passwords, assigns school email addresses, helps to get discounts on software and upload files to Blackboard and not much else.

For years, I have been trying to figure out where the $50,000 a year or so tuition goes. It isn’t to adjunct professors and it isn’t to the IT staff. It also isn’t  to buying the latest technology because, more and more often, students are expected to bring their own device.

You may think that none of the above should be your job and you may be right, but I am just saying if you want to anticipate the frustrations your students will experience and be able to solve their problems during the lecture by directing them to a link on your class website/ blog your life and theirs will both be a lot easier.

 

Thank you to Jason Kellogg from SAS Technical Support, SAS On-Demand Enterprise Miner is now running on my Mac using Windows 8.1 with boot camp. Here were his instructions.

Note, this is after you have a SAS profile, registered a course, changed the security settings in Java, now you are here

The steps are:
  1. Download and save jre-6u24-windows-i586.exe.
          http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jre-6u24-oth-JPR
  2. Open the Windows Run window and run
"C:\users\[userid]\Downloads\jre-6u24-windows-i586.exe" STATIC=1
          where [userid] is your user account name
  3. Click OK to start the installation
  4. After finishing the installation, on the desktop, 
right click empty area and select “Create Shortcut”
(NOTE: on Windows 8.1 this was NEW and then SHORTCUT)
  5. In the location, Browse to Desktop and click Next
  6. In the next screen provide name of shortcut, 
for example “Enterprise MinerJWS”
  7. Once the shortcut is created, Right Click and select Properties.
 In the Target enter the following:
"C:\Program Files (x86)\Java\jre1.6.0_24\bin\javaws.exe"

 https://academic93.oda.sas.com/SASEnterpriseMinerJWS/main.jnlp
  8. Click Apply

You now have a clickable shortcut to Enterprise Miner. Please use it when starting Enterprise Miner.

This worked and I now have SAS Enterprise Miner working on my laptop, which is going to be extremely convenient.

PLEASE NOTE THAT ALL OF THE QUOTATION MARKS NEED TO BE THERE OR IT WILL GIVE YOU AN ERROR.

ALSO,  under #7 that is all one command.  I had to break into two lines on this blog to be legible.

 

Although it was still a huge pain in the ass to get started, it is leaps and bounds ahead of the first time I tried Enterprise Miner years ago.

 

chicken

Back then, it required back flips and sacrificing a chicken (okay, finding a machine running Windows XP, installing a bunch of files – just take my word it was a pain in the ass).  As for the on-demand version, it was so slow as to be useless.

In contrast, once I got up and running, it was not bad at all, and that was running off the wireless in the office. Now, our internet speed is good here, so your mileage may vary, but at least under good conditions it runs fine using a small dataset.

So, I just uploaded a dataset with 10,000 records and 6,000 variables. We’ll see what it does with that.

==== Random shameless plug =====

When I’m not playing around with statistical software, I’m running a company that makes adventure games to teach math. If you want your children to do something educational this summer, you can buy a copy here for $9.99.

 

A few years ago, when I was at USC, I tried to get a desktop version of Enterprise Miner to run on a virtual machine on my Mac and that never happened, although I did get it working on a Windows machine I had at home.

Last week, I wrote about my failed attempt to get SAS Enterprise Miner from SAS On-demand to run on a Mac running Windows under boot camp.

Since then, I have successfully installed Enterprise Miner and started it using a Windows native machine.

Sadly, the same cannot be said for my Macs. Using boot camp on two different Macs, one running Windows 7 and another with Windows 8.1 I have had the same problems.

Be aware that if you are going to run Enterprise Miner on any operating system you are going to need at least some idea of what a C: prompt is and feel comfortable poking around things like .dll files.

You might think that this can be assumed and goes without saying if you are teaching, or even taking, a course in data mining. You would be wrong. Nothing can be assumed or goes without saying. Trust me on this.

I am not going to assume that you checked your configuration and the appropriate Java Runtime Environment is installed. If that is not the case,or you are not sure, go here and take care of that now. (See how this not assuming thing works?)

If that is taken care of, regardless of operating system, you will probably have a problem on Java security blocking the application from starting.  For me, changing Java security setting to medium fixed that on all 3 machines. I tried several other things that did NOT fix it. To find your Java security settings, you can go to the control panel (in Windows 8, search for control panel first) and then search for Java with control panel. Click on Java, then the security tab to find the slider to move to medium.

At this point, the Windows machine worked, even though I had to click on several boxes where Java asked me was I ***SURE*** I wanted to do this.

With the Mac though, after I click on Start SAS On Demand Software, Enterprise Miner – it downloads a main.jnlp file which when I open  it,  I eventually get a message an error exists in the user services configuration. You can see screenshots here The same exact problems occurred with both Mac computers running boot camp.

The ever-helpful Rebecca Ottesen said that two of her students using Macs last semester had the same problem and sent me an email directing me to this site.

So, I did a PROC OPTIONS in SAS, which I had loaded on my desktop and verified that the .dll file was located where expected

— and this led me to thinking, wait a minute, my students aren’t going to have SAS loaded on their computers so what are THEY going to do to troubleshoot.

That was kind of a moot point, though, because …

When I got to step 3 and type in the command as directed in the exact directory directed.

C:\Program Files (x86)\Java\jre1.6.0_24>java -fullversion

I get the error message ‘java’ is not recognized as an internal or external command, operable program or batch file.

Now, there could be any number of other things to try but the fact is, I have other things to do and the course is not for a few months. I will keep plugging away and keep you abreast here. If I do decide to go with Enterprise Miner in the fall, I am sure these posts will be helpful references for students.

I do want to advise anyone who is thinking about using the on-demand version of Enterprise Miner to be aware that you are definitely going to have at least a few problems with getting it installed, for example, the security thing, and if you have any students using boot camp, they are going to most likely hate you.

New semester coming up when I will be teaching data mining.  Because I never do anything at the last minute, I’m registering my course and testing the SAS on-demand for Enterprise Miner now.

I have learned from experience not to ignore it when the instructions say to check your configuration. You should find how to do that here.

http://support.sas.com/ondemand/emconfig.html

The first step is to open a command window and see if you have the appropriate Java Runtime Environment installed (JRE). Haven’t had to do anything from a C prompt in a while. On Windows 7, go to the start window at the bottom left of the screen and type in Command in the search box. Command prompt should pop right up.

I followed the instructions and it seemed my JRE was hunky-dory but the first time I started SAS On-Demand with Enterprise Miner it told me my Java was out of date. I went ahead and downloaded the latest version and installed it.

Your mileage may vary but total time getting up and running was about 2 minutes – but don’t get excited yet.

I clicked on start SAS Enterprise Miner and I got this message

Security warning from Java

I clicked RUN anyway but it was blocked from running.

So … I went into the control panel, typed in Java to search the control panel and in the Java security settings added the SAS on-demand login site as an exception. Still no luck.

Next, I went and changed the Java security settings from high to medium. A lot of people would not feel comfortable doing this, but I at least wanted to get Enterprise Miner to work. I could always set it back later.

At this point, I actually got Enterprise Miner to sort of start. That is, there were a couple of screens of security warnings I had to accept and then I got this error message.

error1

After this message, I got another saying the components failed to load.

failed to load

Perhaps, I thought, I should not have updated Java. So, I went back to the configuration instructions, checked to make sure I had a 32-bit JRE even though I have a 64-bit computer (check).

I went and downloaded the recommended version of the JRE from the Oracle site which required me to create an Oracle ID.

After that was downloaded and installed, I went to the Java control panel and disabled the later version so only one version of Java was installed …

and I got the same error!

 

I checked the SAS documentation and it recommended clearing the Java cache. I did that. I got further that time with lots of messages about downloading the application and verifying the application, but just when I was getting excited, it came up and asked me if I wanted to run with an older version of Java. I picked to continue with the older version. After some more security warnings, I got the same error messages as before.

So … I went through the whole circle again, cleared the cache, started again, selected the newer version of Java – and still the same messages.

It’s past midnight on Memorial Day weekend, so I’m not going to bother calling SAS technical support. I have a laptop running Windows 8, so I’m going to try installing it on that tomorrow and see if I have any better luck.

One thing is pretty clear – my students in the fall better have a lot more familiarity with computers than just pointing and clicking or they are going to have a really hard time – and I still haven’t gotten Enterprise Miner to run!

P.S. At one time, years ago, I had gotten SAS Enterprise Miner to run with version 1.6.0_18    so I tried that and it also failed to start with the same error messages.

I’m running on boot camp on a Mac.  I have a Windows laptop, so I’ll try it on that tomorrow also and see what happens.

I am suspecting this is going to be a disaster, but I’m hoping to be mistaken.

During the time since I started this series of posts on a little thing I knocked out one evening to illustrate long division, I’ve probably done a dozen other somewhat interesting pieces of code – I am sad that Java has co-opted the use of the word codelet because it is such a nice term for a bit of programming that is more than a function but not a real application. Anybody has a good word, let me know. While we’re on the subject of words, what exactly is the difference in Dreamweaver between an extension and a widget?

Anyway …. our games include hundreds of bits like this, where if a student misses a problem, he or she gets routed to a page to pick an option to study.

So … here is the rest of the story. Yes, it could have been done more beautifully, and when I go back and revise it, I think I will change the answer button instead of having two buttons to have one that is changed after the first onClick.

The DOCTYPE (html5) and title are pretty obvious.

All of our web pages have a container ID that is set in the style sheet. That makes all of the content fall within a defined window size, regardless of the screen size.

The w class is just so the background is white in the spot where the problem is. The Invisible Developer wanted some type of background and he liked the specky one.

You might wonder why something like w is a class instead of an ID if it is only used once. In fact, I simplified this example for the blog. Actually the w class is in an external style sheet so their could be pages with more than one element using this same style.

As a commenter on an earlier post pointed out (thank you!) it would really be better practice to give these more descriptive names like white_back because in the future I’ll probably be looking at this page and wondering what the hell ‘w’ was supposed to do. Of course, I can look in the style sheet, but it still is better to name things something descriptive.

You can see that the input field for the second digit of the answer is hidden, as is the button for getting another problem.

The forms have an ANSWER button because we found that students in this age group (9- 12 years) often type something by accident or as their first impulse. This forces them to think, at least for a second, whether or not they really meant that and gives them a chance to change  their mind. We added this at the request of several teachers after our first year of beta testing.

The table width is set at 40% and since the container width is defined, the table will always be the same size.
The q class (again, should be renamed and shame on me), has a border at the bottom of the cell. That is used to give the top part of the division problem and used again when each digit of the quotient is found and multiplied by the divisor. The product is then put in a cell with a line underneath.

The first input field is where the first digit of the quotient will be entered. Onclick this will be hidden and the correct answer shown in the element yans1. If the student had entered an incorrect answer, they’ll also get a message telling him or her it is an incorrect answer. All of this is handled by the javascript.

For the remaining rows of the table – the left cell is underneath the divisor, so it will remain empty. The right cell will have each step in the division problem entered, as the student enters the first digit and then the second.  Again, this is handled by the javascript, all I need to do is make sure the id values for each cell match what is in the script.

Once the problem is finished, the div with the id fin will be shown, as will the button for trying another problem. The student now can select one of three choices:

Get another problem (button3), go back and select another option for studying division, or take a quiz to go back to the game. Five correct answers and he or she can go back to playing Spirit Lake.

<!DOCTYPE html>

<html>
<head>
<title>Practice division</title>

</head>

<body >
<div id=”container”>
<div class=”w”>

<h3>PRACTICE LONG DIVISION</h3>
<p></p>
<h3 id=”hd1″> Enter the FIRST digit in the answer</h3>
<h3 id=”hd2″ class=”hidden”> Enter the SECOND digit in the answer</h3>
<input type=”button” class =”hidden” value=”ANOTHER PROBLEM” size=”5″ name=”button3″ id=”button3″ onclick=”window.location.reload()”>
<p></p>

<p></p>
<form name=”formx” id=”formx” >

<input type=”button” value=”ANSWER” name=”button1″ id=”button1″ size=”5″ onClick=”checkProb(1)”>
<input type=”button” value=”ANSWER” size=”5″ name=”button2″ id=”button2″ class=”hidden” onClick=”checkProb(2)”>
<table width=”40%” border=”0″ cellpadding=”0″ >
<tr>
<td width=”20%” >&nbsp;</td>
<td width=”20%” class=”q” ><input type=”text” name=”ans1″ id=”ans1″ size=”3″><scan id=”yans1″ class=”hidden”></scan>
<input type=”text” name=”ans2″ id=”ans2″ size=”3″ class=”hidden”><scan id=”yans2″ class=”hidden”></scan></td>
</tr>
<tr >
<td ></td>

<td></td>
</tr>
<tr>
<td id=”c” ></td>

<td id= “divide”>&nbsp;</td>
</tr>
<tr>
<td ></td>

<td id= “d”class=”d” >&nbsp;</td>
</tr>
<tr>
<td ></td>

<td id= “e” >&nbsp;</td>
</tr>
<tr>
<td ></td>

<td id= “f” class=”d”>&nbsp;</td>
</tr>
</table>

</form>
<div id=”fin” class=”hidden”>

<p></p>
<a href=”../learndividelong.html”><img src=”../scenephotos/arrowhead_point_left.gif” width=”130″ height=”70″ alt=”back arrow” />
Go back to study more</a>
<img src=”../scenephotos/smalls/handblue.jpg” alt=”blue hand” /> <img src=”../scenephotos/smalls/handyellow.jpg” alt=”yellow hand” />
<a href=”../quizzes/dividelongerquiz.html”>Take a quiz to go back to the game<img src=”../scenephotos/arrowhead_point_right.gif” alt=”next arrow” /></a></div></td>
<p></p>
</div>
</div>
</body>
</html>

 

Yesterday I posted the code to get the problem, now here is where we check it. As I said yesterday, may way of programming is to knock out something that works and then go back and make it work better, like a first draft for a journal article. So, this is my first draft.

Keep in mind the point here is NOT a quiz but for them to review and see how long division works. So, if they get the wrong answer, they get an alert message that this is the wrong answer, but then the correct answer is shown. This happens for both the first and second digit of the quotient.  There are two digits in the quotient in these problems. We are trying to show students that when you do long division, you find the first digit, multiply that by the divisor, write the product below the dividend and subtract. Then, you do the same thing again for the next digit.

Also, I showed using alert here, but we actually use a function we wrote in our game because there are problems with using multiple alert boxes in the same page with Unity. The alert is included here for generalizability. This post is the second half of the javascript. You also need a bit of css and html that I’ll put up next.

You can see the final product here.

This is one of hundreds of applets we have written that are just auxiliary to the main game. You get sent here to study if you miss one of the math challenges in Spirit Lake: The Game.

Here is what this code does in order …

When they type in an answer, it is one digit at a time. The function checkProb, if it is the 1st digit,  hides the input box and answer button for the first digit and shows the correct answer. It also shows the input box and button to answer the second digit. The correct first digit is shown.

The product of the divisor and that first digit is computed, set to a value for a new variable d1, and that is shown.

The result is subtract from the dividend, and that result, e1 is shown but with a space included so the digits are lined up correctly.

If their answer is wrong, a message is shown telling them it is wrong and what the correct answer is. Actually, that message comes up first so once they click OK they can see the correct answer, product, etc.

Then, they enter the second digit and all of the steps execute again. After they have done a complete problem, the instructions on how to complete the problem are hidden and two new options are shown, to either get a new problem or go back to the game.

function checkProb(num){
this.num = num ;
if (this.num == 1)
{
var theirs = document.formx.ans1.value ;

$(“#ans1″).hide() ;
$(“#hd1″).hide() ;
$(“#button1″).hide() ;
$(“#hd2″).show() ;
$(“#ans2″).show() ;
$(“#button2″).show() ;
document.getElementById(“yans1″).innerHTML = rightans1 ;
$(“#yans1″).show() ;
var d1 = rightans1*divisor *10 ;
var e1 = dividend – d1 ;
document.getElementById(“d”).innerHTML = d1 ;
$(“#d”).show() ;
document.getElementById(“e”).innerHTML = ‘&nbsp;’ +e1 ;
if (theirs != rightans1){
alert(“Sorry,the correct answer is ” + rightans1) ;
}

}
else if (this.num ==2)
{
var theirs = document.formx.ans2.value ;
var d2 = rightans2*divisor ;
document.getElementById(“yans2″).innerHTML = rightans2 ;
document.getElementById(“f”).innerHTML = d2 ;
$(“#f”).show() ;
$(“#ans2″).hide() ;
$(“#yans2″).show() ;
$(“#fin2″).hide() ;
$(“#fin”).show() ;
$(“h3″).hide() ;
$(“#button3″).show() ;
$(“#button2″).hide() ;
if (theirs != rightans2){
alert(“Sorry,the correct answer is ” + rightans2) ;
}

}
}
</script>

Next Page →