bs2facdev

LearningProgramming

D.R.Y. for Teachers

If it wasn't for SJIS (or some sort of MS Windows Encoding Page) troubles, this script would probably be useful and reliable. I'm fudging the possible encoding issues by, using “key” and “value” as backups when assoc doesn't find what it should in an associative list (alist, als). Playing with Scheme/Racket gives you the confidence to deal with any problem, if some detail isn't working, just throw in an if or cond statement, and maybe the results will help you figure out where the trouble is. DrRacket is great for showing where errors are, it even produces bright red lines that trace the errors for you...

There is a pattern, where I develop the script to generate useful pages to process one data file and then adapt it to handle several files in a directory. After the script seems to work for one data file, I get all the define definitions used to transform data (not those used to make functions) from the original file, and put those definitions into a let* expression (or clause) within a procedure that is used with for-each to go through a list of data files. Some definitions remain global, but all the definitions that rely on the data file go into a let* clause.

This code is re-working of earlier code (fn:1) that, from one .csv data file generated three files: a racket data file, a browser page to print roll sheets, and a browser page to print a seating chart. To get code that will generate three useful files (a rkt data file, a roll sheet, and a seating chart) for each .csv data file in a directory, I just had to see what belongs in a let* clause of the function that is mapped (with for-each for the side-effects and the list-generation) over a list of file paths.

A typo(bug) that disturbed my flow made me appreciate first and second in place of car and cadr. I had build-path errors that confused me for a while. when I moved the define cls-als (class associative list: alist: als) into the let* clause, I forgot the a in cadr. In place of a one-key one-value associative list, I ended up with, not a string, but a long list as the value. Without the string, I could build paths for file-generation. I imagine using first and second could make it easier to spot a mistake like that. But cddr is probably still useful instead of (rest (rest ....

There is another bug, where the first seat is taken up by the keys for associative list, or what could be viewed as column headers in a table of data. If there is time I'll see where in the chart-generation process to intervene, and get rid of the header intrusion. But the bug could be a feature, it can be nice to have an open table at the front of the room for returning papers, for set-up. With the Graded Direct Method teachers haul a lot of “realia” into the classroom, and tend to need tables and seats for demonstrations...

code

Read more...

It might be easier to share Dont' Repeat Yourself (D.R.Y. or OnceAndOnlyOnce) techniques if I get the Guile Scheme scripts(fn:1) to work in DrRacket(fn:2). If Convention Over Configuration principles can direct teachers toward a directory in their home-directory, and toward keeping their .csv data in particular folders, and to look for useful pages in particular folders… Given all that, a script like this could be useful for other people too.

Screenshot of Generated Pages: Roll Sheet and Seating Chart in Firefox Windowshttps://snap.as/bsmall2/racket-facdev/Binke65

I got a Guile script go through a directory of .csv data files (encoded in SJIS) and produce three useful files (encoded in UTF-8) for each data file. The next step is to get DrRacket to do the process below for several .csv files. And then another script should make it possible to use an edited ~-roll-data.rkt file to produce another seating chart. Sometimes the class needs a different ordering of seats: for example, people with hearing trouble might do better at the front of the class. And some class-rooms demand a wider row, in stead of a six-person row, a large class might need a ten-person row. But for now, this code, with build-path is probably more portable than my first attempt in Guile Scheme. (fn:1)

And comparing this Racket Script with the Guile Script is a chance to see differences among regexp-replace\* and regexp-substitute/global, scribble\html\html with its output-xml and sxml simple with its sxml->xml. I enjoyed the oppornity to practice quasiquote while learning to work with sxml->xml, but for the pages I generate here scribble\html and output-xml seems simpler. My regular expression needs are met by the simpler regexp-replace\* , but with more complex processes the pre andpost approach for regexpt![img](images/SJIS-csv-to-RollSheet-SeatingChart-1.png) -substitute/global might be helpful.

A Screenshot of DrRacket with the code used to generate  Roll Sheet and Seating Chart pages https://snap.as/bsmall2/racket-facdev/SNzGnvo

code

Read more...