. cgi . irev

74
.cgi .irev Dave Brooks University of Nebraska – Lincoln September 1, 2009

description

. cgi  . irev. Dave Brooks University of Nebraska – Lincoln September 1, 2009. Unified Learning M odel. Since this probably is the most important work I’ve ever done, I needed to make my Web tools more versatile to support teaching of this model. Two kinds of early courses: - PowerPoint PPT Presentation

Transcript of . cgi . irev

Page 1: . cgi   . irev

.cgi .irev

Dave BrooksUniversity of Nebraska –

LincolnSeptember 1, 2009

Page 2: . cgi   . irev

2

Unified Learning ModelSince this probably is the most important work I’ve ever done, I needed to make my Web tools more versatile to support teaching of this model.

Two kinds of early courses: Chemistry – much automatic assessment Theory – much reading, writing, & discussion 9/1/09

Page 3: . cgi   . irev

39/1/09

Page 4: . cgi   . irev

49/1/09

Page 5: . cgi   . irev

59/1/09

Page 6: . cgi   . irev

69/1/09

Page 7: . cgi   . irev

79/1/09

Page 8: . cgi   . irev

89/1/09

Page 9: . cgi   . irev

99/1/09

Page 10: . cgi   . irev

109/1/09

Page 11: . cgi   . irev

11

In my first draft of this talk, I forgot to mention something very important. There’s a reason why people like me fool around with RunRev. It’s this:

All of the pages I showed were built using one RunRev stack!

9/1/09

Page 12: . cgi   . irev

129/1/09

Page 13: . cgi   . irev

139/1/09

Page 14: . cgi   . irev

14

The chemistry courses were developed in HyperCard, and used to run on an old System 9 server with WebStar. Used stacks to store data, and used appleEvents to exchange information with Web pages.

I was unable to migrate directly from HC to RunRev – because Apache does not use appleEvents and never got a tool that would move enough information using an appleEvents strategy.9/1/09

Page 15: . cgi   . irev

15

In January, 2004, heard talk by Jackie Landman Gay at a RunRev workshop in SF. Went home to work on new backend.

Thought I had it until I came across a data transfer limit – that I never successfully worked around. Had one chemistry course “moved,” but could not move the other course format.

9/1/09

Page 16: . cgi   . irev

16

Switched to a straight Rev cgi.

Moved everything to that.

It ran (and runs) successfully

9/1/09

Page 17: . cgi   . irev

17

Reason to change now:

• Impetus of ULM (new work)

• Server protection from the vagaries of retirement

• Academic excuse to travel to Scotland

9/1/09

Page 18: . cgi   . irev

18

A Digression on Retirement Plans

I’m on a 24/10 retirement plan. If I go into the office tomorrow (24 h) and decide that’s it, the desired books and wall memorabilia go into boxes (90 minutes), and the e-mail saying I won’t be back (30 seconds) is sent.Since I’m 67, that day is coming in the next 10 years.

9/1/09

Page 19: . cgi   . irev

19

I bought on-rev space as soon as it was available (like April, 09).

As I started to mess with irev, I realized how much fun it was. Further, since much of what I had been doing was:• reading in Web form data,• deciding what to do with it, and • composing an html response

irev was a natural for me.9/1/09

Page 20: . cgi   . irev

20

Keep in mind that I don’t make a living programming, and that I am in awe of the likes of Daniels Garzia Gaskin Wieder ….I’m much more like Looney, but, since I have tenure, I don’t have to make a living with my stuff (even though I sort of do that anyway).

9/1/09

Page 21: . cgi   . irev

21

Yes, I guess I could have moved my cgi stuff to the on-rev server and just used it as is, but what fun would that be?

9/1/09

Page 22: . cgi   . irev

22

Back to a RunRev Conference in Monterey. Jerry Daniels showed use of text files to store data, and I’ve been quite suspicious of databases. If you learned about databases when you were middle-aged and haven’t kept up, you ascribe many problems to them that were resolved long ago. un-paid plug So, my cgi data is stored in text files. It’s not necessarily the best way, but it keeps me comfortable.9/1/09

Page 23: . cgi   . irev

23

Around the same time that I decided to go to text files, I was sitting in on a computer science course in which the teacher advocated xml formats. Now, I never had much luck with my versions of RunRev and the xml functions, but I decided to use that approach in a way that could be adopted later. So, …

9/1/09

Page 24: . cgi   . irev

24

My files looked like this.

<?xml version='1.0' ?><Administrators> <AtheAdmins> [email protected],aaa,David W. Brooks [email protected],bbb,Roger Smith </AtheAdmins> <CtheEditDate> 01/02/09 </CtheEditDate></Administrators>

9/1/09

Page 25: . cgi   . irev

25

While that may be a Kosher xml file, I really couldn’t get those functions to work. So, I used my old tricks as follows:

9/1/09

Page 26: . cgi   . irev

26

AtheAdmins CtheEditDate<?xml version='1.0' ?><Administrators> <AtheAdmins> [email protected],aaa,David W. Brooks [email protected],bbb,Roger Smith </AtheAdmins> <CtheEditDate> 01/02/09 </CtheEditDate></Administrators>

9/1/09

Page 27: . cgi   . irev

27

The idea was this. If you strip out the first line, you have a real xml file. But, since the first line was designed to contain the names of every element, you could parse the file – element by element – and create a data array from the result.

9/1/09

Page 28: . cgi   . irev

28

You would end up with an array:

Administrators[“AtheAdmin”]Administrators[“CeditDate”]

Administrators[“theKeys”]You then can work with the data in this array, change the values according to the needed operations, and then rebuild the file by using theKeys for the first line and then rebuilding each file element.

9/1/09

Page 29: . cgi   . irev

29

Systematic naming

It also was helpful to name the elements systematically: Lxxxxxx (read in from an ordinary text field) Fxxxxxx (read in from a text area field) Axxxxxx (read in from a text area but with strutured data in a fixed format) Cxxxxxx (something calculated that really shouldn’t be edited by just anyone)

9/1/09

Page 30: . cgi   . irev

30

Several years back I asked Jackie L-G to look over my scripts. She pointed out that I really didn’t need this xml stuff (unless the files are VERY large, xml files are easily readable).

She recommended using parsing characters that cannot be typed into a Web page – her choices being:

numtochar(3) & numtochar(8)

9/1/09

Page 31: . cgi   . irev

31

File to Array:

function ExtractNew recordPathput url("file:"&recordPath) into BigData split BigData by numtochar(3) and numtochar(8)return BigDataend ExtractNew

Create variable bigData from file in which what had been element names are separated from the data by numtochar(3) and what had been different elements were separated by numtochar(8)

9/1/09

Page 32: . cgi   . irev

32

Array to file, reverse the process:

on RebuildNew BigData, recordPath combine BigData by numtochar(3) and numtochar(8) put BigData into URL( "file:"&recordPath)end RebuildNew

9/1/09

Page 33: . cgi   . irev

33

With the exception of a small number of files that have just one type of data in a structured format, that’s how I retrieve/store data.

The BIGGEST virtue of this approach is that I don’t have to know what kind of data I’ll have when I start – so long as I have a systematic way of naming data. In other words, I don’t have to know what the exact data structures will look like in advance. With xml, I had to know at first what the data looked like, so I had to have templates built in advance.

9/1/09

Page 34: . cgi   . irev

34

Today, if I add another question to the 7th week of school, I just do that.

No template modification.

No problem that the current data files don’t have an “element” for that.

9/1/09

Page 35: . cgi   . irev

35

Changing templates during a course because you wanted to add something was not unlike what I imagine one of Dante’s first five circles (the self-indulgent circles) to be like.

On the other hand, these text files with invisible characters are much less easy to read than were the xml files. For one thing, the systematics for sequencing the elements are obscure. My mental structure of an array turns into a hodge-podge sequence in the text file.

9/1/09

Page 36: . cgi   . irev

36

A VERY nice feature in on-rev is that Web data goes into a global array,

$_POST.

So, from my previous example:$_POST[“AtheAdmins”] can be manipulated by moving it into a new variable.

9/1/09

Page 37: . cgi   . irev

37

Also, Web data is streamed in a different format than you might expect:

Explain+how+convection+could+contribute+to+the+controversial+issue+of+how+fast+hot+and+cold+water+freezes.

Explain how convection could contribute to the controversial issue of how fast hot and cold water freezes.

9/1/09

Page 38: . cgi   . irev

38

irev handles the management of encoding/decoding very well. It needs a bit of help with some things, like “+” and “%”.

9/1/09

Page 39: . cgi   . irev

39

Returns work well in a textarea. They don’t count in html – so you need a function like this:function BRdecode bbb replace "%" with "&#37;" in bbb replace "+" with "&#43;" in bbb --put URLdecode(bbb) into bbb put “<br />”&return into tag replace return with tag in bbb return bbbend BRdecode

9/1/09

Page 40: . cgi   . irev

40

Remember, I need TWO different systems.

What the student sees.What the teacher sees.

9/1/09

Page 41: . cgi   . irev

419/1/09

Page 42: . cgi   . irev

429/1/09

Page 43: . cgi   . irev

439/1/09

Page 44: . cgi   . irev

449/1/09

Page 45: . cgi   . irev

45

Everything works on visible and hidden variables.

9/1/09

Page 46: . cgi   . irev

46

tTask = function to which data is directed

tTask is written as a hidden; it might be changed in the browser using javascript. Sometimes it is set to “none” and all of the choices end up resulting from javascripting.

IF the task is determined by javascripting, then that scripting must somehow either be in or be created by the function that is creating the page.

9/1/09

Page 47: . cgi   . irev

47

FLOW of processing:

start timer (gDBstart)store the current defaultFolder (path)designate globalspull standardized Web values ($_POST)load core functionsuse switch, tTask PROCESS (call other functions)build bottom

9/1/09

Page 48: . cgi   . irev

489/1/09

Page 49: . cgi   . irev

499/1/09

Page 50: . cgi   . irev

50

The switch function acts on the basis of the tTask.

9/1/09

Page 51: . cgi   . irev

51

Whatever function is called, it creates the title that is written at the top of the file. It decides what a title should be and writes – including setting up the form and directing the action to either of TWO irev scripts.

parse.irev – handles studentsULMAdmin.irev – handles teachers

9/1/09

Page 52: . cgi   . irev

parse – uses many “include” scriptstakes about 2 milliseconds to handle anything.

ULMAdmin – uses one large script and takes about 8 milliseconds to handle anything. Because teacher traffic is much lower traffic, this is fine.

Comparable cgi scripts running on a top Mac server take 10-15 times longer!

9/1/0952

Page 53: . cgi   . irev

539/1/09

Page 54: . cgi   . irev

54

Although the top script is split out, the title comes from the function, so the file writing doesn’t start until one of the task-specialized functions opens. The function that writes the top of the page always is called by another function.

9/1/09

Page 55: . cgi   . irev

55

The “guts” are provided by the individual functions. They determine the next task AND write (usually as hiddens) the data for the NEXT process. The user need not know this.

9/1/09

Page 56: . cgi   . irev

56

All of this stuff is written to one variable.

In the parse script, it is “put” out as it is built.

In the ULMAdmin script, it is stored in a global variable until complete and then written out at once. (This was done to facilitate debugging – as discussed later.)

9/1/09

Page 57: . cgi   . irev

57

The last thing to do before sending this newly constructed page out is to write a bottom.

9/1/09

Page 58: . cgi   . irev

58

The bottom function:

writes the globals as hiddens closes the form calculates the time elapsed writes access information adds a Google Analytics tracker function closes the body and the html

The page is then sent.

9/1/09

Page 59: . cgi   . irev

59

Debugging is VERY difficult

The on-rev tool helps find obvious mistakes, but it really doesn’t help enough.

So, ---

9/1/09

Page 60: . cgi   . irev

60

On-rev debugging:

9/1/09

Page 61: . cgi   . irev

61

Capture Web inputs

9/1/09

Page 62: . cgi   . irev

629/1/09

Page 63: . cgi   . irev

639/1/09

Page 64: . cgi   . irev

64

Download current irev script file

Pull it into ScriptTester:

9/1/09

Page 65: . cgi   . irev

65

Run the test script; copy result, paste into ScriptTester, load globals into ScriptTester

9/1/09

Page 66: . cgi   . irev

66

Since $_POST is not available, do a replace of $_POST with bigData – which now is global variable loaded with the data that would have come in from the Web form.

9/1/09

Page 67: . cgi   . irev

679/1/09

Page 68: . cgi   . irev

68

Goal – keep the switch and the function to be tested in one button, and put everything else into the card script. The button script accretes the forming page in a global variable (gDBtheHTML). In irev, this is sent to the Web with a put statement. In debugging, it is written to a file that can be examined at the desktop.

SO: run with debugging, fix (iteratively), take “repaired function”, replace bigData with $_POST, paste back into original script, save as text file, and upload overwriting original script.

9/1/09

Page 69: . cgi   . irev

69

This is a supreme pain in the butt – and I wish someone who knows what s/he is doing will build a debugger for these scripts

9/1/09

Page 70: . cgi   . irev

70

Problems can result from a simple typo.

They can represent a really stupid coding decision or really bad code.

BUT, whatever the problem, you don’t get much help. MOST of the simple problems were detected by the on-rev tool.

If you were to look at my scripts, you would see commented out MANY cases where I was reporting the value of a variable at a particular point in time.

9/1/09

Page 71: . cgi   . irev

719/1/09

Page 72: . cgi   . irev

72

Where am I today?

Well, I’m happy. It took about 13 days to make this happen. I wish I’d trashed the xml right away. I still can make some changes based on better understanding of what-does-what in irev. I wish I’d mucked with a debugging stack earlier, since that might have saved time. It’s so clunky that it didn’t help save as much time as it cost to build – but building it was fun!

HyperCard was both forgiving and easy to debug.

9/1/09

Page 73: . cgi   . irev

73

Thank you for inviting me.

BTW, my university offers at-a-distance doctoral programs in education, so anyone interested in receiving a degree from a bona fide AAU member, feel free to ask.

9/1/09

Page 74: . cgi   . irev

74

I’m pleased to try to answer any of your questions.

9/1/09