Class Comment Lists to Printable Browser Page

At some point, I should use student comments to help explain teaching English with the Graded Direct Method. (fn:1) At the start of the semester more than half the students write comments at the bottom of the class worksheets. (fn:2) I print out the comments and leave them on the table where students collect the previous's classes worksheets at the start of every class. With emacs org-mode I used two windows and a keyboard shortcuts to keep a list of comments and their student's numbers in sync. Then I exported just the comments. Without consent to publicize the comments it seemed like a decent way to share the comments in class. (The few comments included in the script were edited and/or translated beyond recognition from among 58 comments.) After working with Guile and Racket over the past month or so, it seems simpler to just work with nested association lists. At least the data entry part will be simpler. I might end up re-inventing the wheel in the area of data-base-like approaches, but re-discovery will be good for my learning when/if I ever need to learn/use databases.

Nested Association Lists to Generate Pages of Class Comments.

During a rainy afternoon, I wondered how working with nested association lists would be. The exercise helped me clear up vague misunderstandings about association lists.

It also made reminded my about working with directories and paths in Racket. Eventually I'll script this to read in a data-file with a big-nested association list of comments for years of classes, and use the student numbers to check for consent to use the comments. But in the meantime it was fun to get from-keys-get-inner-alist-value to work along with the als-ref utility that I use all the time.

By chance I also discovered require racket\date and (date->string (current-date)) which I might use to generated working-directories later. Useful little one-page scripts help me, maybe it will be possible to share them and thereby foment interests in coding and free software...

code

#lang racket

(current-directory-for-user "/home/brian/Racket/school-stuff/comments/")
(define working-directory (current-directory-for-user))

(define als-ref
  (lambda (key als)
    (let ((tmp (assoc key als)))
      (if tmp (cadr tmp) #f))))

;; no need to quote C1 as 'C1
(define 2019ZEC1C1-keys '(2019 1 "English Communication I" C1))

(define from-keys-make-title
  (lambda (keys)
    (define list-to-strings
      (lambda (lst)
	(map (lambda (elmt) (cond ((number? elmt)
				   (number->string elmt))
				  ((symbol? elmt)
				   (symbol->string elmt))
				  (#t elmt)))
	     lst)))
    (string-join (list-to-strings keys) " ")))

(define from-title-make-class-fname-comments
  (lambda (title)
    (string-append
     (string-replace title " " "")
     "-comments.html")))
;; (from-title-make-class-fname-comments (from-keys-make-title 2019ZEC1C1-keys))  ;; "20191EnglishCommunicationIC1-comments.html"


(define from-keys-get-inner-alist-value
  (lambda (keys alst)
    (cond
     ((empty? (cdr keys)) (als-ref (car keys) alst))
     (#t (from-keys-get-inner-alist-value (cdr keys) (als-ref (car keys) alst))))))


;; (year (semester (class (studentnumber name comments)... )))
(define Class-Comments
  '((2019
     ((1
       (("English Communication I"
	 ((C1
	   ((12119016 "I think this class is a lot of fun.")
	    (12118100  "It was clear and fun")
	    (12119003  "It is fun.")
	    (12119006 "I want to try hard in this class.")
	    (12119011 "It was not what I expected.")
	    (12119009 "I learned how to really use 'there' for the first time.")
	    (12119006 "What a surprise. This was a first experience for me.")
	    (12119015 "I forgot my English ...  But I'll try English with passon!")
	    (12119018 "I am enjoyed English.")
	    (12119019 "It was a good class because I understood.")
	    (12119020 "The use of Youとheやthey was easy to comprehend")
	    (12119021 "It was a clear class ")
	    (12119027 "It was interesting to see how the words changed when the eyes met, or didn't meet.")
	    (12119028 "The teacher was interesting and easy to understand.")
	    (12119031 "This class was easy to understand.")
	    (12119033  "Understandable and interesting")
	    (12119034 "This Lesson is very enjoyable.")
	    (12119036 "The differences between Subject, predicat, there, here, were easy to learn through voicing and pictures")
	    (12119037 "Very happy!")
	    (12119040 "So much fun!")
	    (12119041 "It was a good learning-through-experience class.")
	    (12119042 "I had a good time")
	    (12119044 "very nice!  It was fun!")
	    (12119089 "very fun!!")
	    (12119091 "very happy")
	    (12119099  "enjoyable")
	    (12119111 "I understood well."))))
	 );; end 1 Seme
	) ;; EnglishCommunication 
       )) ;end 1
     )))

(define 2019EC1ZC1-Comments
  (map cadr (from-keys-get-inner-alist-value 2019ZEC1C1-keys Class-Comments)))

;; 2019EC1ZC1-Comments

(require scribble/html) ;; for output-xml
(require scribble/html/html) ;; for table etc


(define comments->li
  (lambda (keys comments)
    (map (lambda (cmnt) (li cmnt))
	 (map cadr
	      (from-keys-get-inner-alist-value
	       keys comments)))))

(define class-comments-html
  (lambda (keys-list cmnts-alist)
    (let* ((page-ttle (from-keys-make-title keys-list))
	   (page-fle (from-title-make-class-fname-comments page-ttle))
	   (page-out (open-output-file
		      (build-path working-directory page-fle) #:exists 'replace)))
      (output-xml
       (xhtml (head
	       (title page-ttle)
	       (meta http-equiv: "Content-Type" content: "text/html;charset=utf-8")
	       (map style (list
			   "h2 { font-weight: normal; font-size: 12pt; margin: 0 0 .2em .4m; }"
			   "ol { margin-top: .2em; }"
			   "li { line-height: 1.5em; }")))
	      (body (h2 page-ttle)
		    (ol
		     (comments->li keys-list cmnts-alist))))
       page-out)
      (close-output-port page-out))))


(class-comments-html 2019ZEC1C1-keys Class-Comments)

#FS4FT #FS2FT #FreeSoftware4Teachers #FreeSoftwareToFreeTeachers #Racket #DrRacket #Classroom