Приложения канала
[Разметка Markdown] 

Faculty-Development: added-varied-responses-script

Questionnaire Result Visualization

plot sample 1

A Racket Script and Text Data Convention.

The png images generated by this script and another are in a photo-album. 1

The scripts, data, and png samples are on gitlab too.2

Convention for Text Sections: newline separations and csv sections

year,2020
semester,2
classname, EC1


Registered,98
Responded,37


1, How many hours did you study for this class each week on average.

10 hours or more
5 to 10 hours
3 to 5 hours
1 to 5 hours
less than one hour
no time studying

1,1,2,4,15,14,1


2, Was the syllabus covered? 

well covered (80%)
mostly covered (60%)
not well covered (40%)
not covered (20%)

2, 8,26,3,0


3-1, Did you actively participate in the class?

very much so
so so
can't say
not much
not at all

3-1,13,17,5,1,1


3-2, Did you actively participate in groupwork, experiments, etc.?

yes actively
a little actively
not very actively
not actively
no such activities

3-2, 7,21,5,0,4


3-3, Did you ask questions?

10 times or more
5 times or so
1 to 2 times
never

3-3,2,4,11,20


4, Do you understand the class?

yes
mostly
Can't say
not much
no

4,15,21,1,0,0


5, Was the class one of active learning?

yes
mostly
can't say
not really
no

5,14,16,4,1,2

plot sample 2

Command Line script

#! /usr/bin/env racket
#lang racket
;; With the racket script and text data in your current directory
;; From the Command line if the script is executable:
;; > ./varied-responses-format-to-views-cli.rkt 
;; ;  to use the the  default filename and adjustment, or
;; > ./varied-responses-format-to-views-cli.rkt varied-responses-format-en.txt -en
;; ; to use alternate data text and filename adjustment, or
;; > racket varied-responses-format-to-views-cli.rkt
;; ; works the same way if adding to the script's mode is a troublesome detail;
;; ; > chmod +x varied-responses-format-to-views-cli.rkt
;; ; or default to Q-responses-format-2.txt and cli arguments

(require csv-reading plot)

(define formatted-results
  (if (< 0 (vector-length (current-command-line-arguments)))
      (vector-ref (current-command-line-arguments) 0)
      "varied-responses-format-ja.txt"))

(define f-name-adjust
  (if (< 1 (vector-length (current-command-line-arguments)))
      (vector-ref (current-command-line-arguments) 1)
      "-ja"))

(define (make-q-plot-filename str)
  (string-append str f-name-adjust))

(define text-string (file->string formatted-results))
;; text-string ; ok!
(define text-sections-list
  (string-split text-string "\n\n\n"))
;; text-sections-list ; ok!
(define class-data  (csv->list (first text-sections-list)))
;; class-data ; ok!
(define responder-turnout-list (csv->list (second text-sections-list)))
;; responder-turnout-list ; ok!
(define-values (regsd-num regsd-str respd-num respd-str)
  (values (string->number (second (first responder-turnout-list)))
         (first (first responder-turnout-list))
         (string->number (second (second responder-turnout-list)))
         (first (second responder-turnout-list))))

(define Qs-w-responses-results-sections
   (drop text-sections-list 2))
;;Qs-w-responses-results-sections ; ok!
(define Q-responses-results-lists
  (map (lambda (section) (string-split section "\n\n"))
      Qs-w-responses-results-sections))
;; Q-responses-results-lists ; ok!
;; (first Q-responses-results-lists)
#;'("2,当該科目のシラバスに達成されている(到達目標)について、どの程u達成できていると思いますか。"
  "達成できている(達成度80%)\nおおむね達成けいている(達成度60%)\nほとんど達成できていない(達成度20%)\n達成できていない(達成度20%)"
  "2, 8,26,3,0")

(define (Q-response-list->data Q-r-r-lst)
  (define n-w-q (car (csv->list (first Q-r-r-lst))))
  (define number (first n-w-q))
  (define question (second n-w-q))
  (define responses
    (string-split (second Q-r-r-lst) "\n"))
  (define frequencies
    (map string-trim
        (cdr (first (csv->list (third Q-r-r-lst))))))
  (list number question responses frequencies))
;; (Q-response-list->data (first Q-responses-results-lists)) ; ok!
#;'("2"
  "当該科目のシラバスに達成されている(到達目標)について、どの程u達成できていると思いますか。"
  ("達成できている(達成度80%)"
   "おおむね達成けいている(達成度60%)"
   "ほとんど達成できていない(達成度20%)"
   "達成できていない(達成度20%)")
  ("8" "26" "3" "0"))

(define label-start-x -.5 )
(define resp-freq-sep .5)

(define p-label-txt-size 14)
(define p-label-num-size 13)
(define line-width 10)

(define (response-line y resp-str freq-str)
  (define freq-num (string->number freq-str))
  (define freq-y (- y resp-freq-sep))
  (list
   (point-label (vector label-start-x y)
               resp-str #:point-size 0 #:size p-label-txt-size)
   (lines (list (vector 0 freq-y) (vector freq-num freq-y))
         #:width line-width #:color "cornflower blue")
   (point-label (vector freq-num freq-y) freq-str
               #:point-size 0 #:size p-label-txt-size)))

(define (regi-responded-lines-end-label x y num str )
  (list
   (point-label (vector x y) num
                #:anchor 'bottom-right #:point-size 0 #:size p-label-num-size)
   (point-label (vector x y) str
                #:anchor 'top-right #:color "black" #:point-size 0 #:size p-label-txt-size)))

(define (regi-responded-lines y num str (clr "light gray") (wdth line-width))
  (list (lines (list (vector 0 y)(vector num y)) #:color clr #:width wdth)
    (regi-responded-lines-end-label num y
                    (number->string num)
                    str)))

(define (plot-q-varied q-data-strs)  ; change to plot-bitmap for cli-script
  (match-define
   (list num-str question responses freq-strs)
   (Q-response-list->data q-data-strs))
  (define f-name (path-add-extension
          (make-q-plot-filename num-str)
          ".png"))
  ;; error check that responses and freq-strs are same length?
  (define resp-ys (range 1 (+ 1 (length freq-strs))))
  (define y-max (+ 2.5 (length responses)))
  (define q-y (- y-max .8))

  (define pict-btmp ; make pict-btmp for cli script
    (parameterize
     ((plot-decorations? #f)
      (plot-width 800)
      (plot-height 400)
      )
     (plot-bitmap
      (list
       (point-label (vector label-start-x q-y)
                   question
                   #:point-size 0 #:size p-label-txt-size)
       (regi-responded-lines (- q-y .7) regsd-num regsd-str)
       (regi-responded-lines (- q-y 1) respd-num respd-str)
       ;; (response-line 1 (first responses) (first freq-strs)) ; ok!
       (map response-line resp-ys responses freq-strs)

       (regi-responded-lines -0.3 regsd-num regsd-str)
       (regi-responded-lines 0 respd-num respd-str)
       )
      #:x-min -1 #:x-max (+ (* .02 regsd-num) regsd-num)
      #:y-min -0.8 #:y-max y-max
      )))
  (send pict-btmp save-file f-name 'png)
  ;; pict-preview ;; for DrR iterative viewing and tweaking
  )

 ;;(plot-q-varied (sixth Q-responses-results-lists))
 ;; (plot-q-varied (seventh Q-responses-results-lists))

 (for-each plot-q-varied Q-responses-results-lists)


For Dr Racket Tweaking

Replace the first few lines of the command line script

#lang racket

;; replace "/path/to/my/directory"
(current-directory "/home/brian/repos/gl/questionnaire-facdev")

(require csv-reading plot)

(define formatted-results "varied-responses-format-ja.txt")

(define f-name-adjust "-ja")

(define text-string (file->string formatted-results))
;; text-string ; ok!


  1. plot images photo album ↩︎

  2. https://gitlab.com/bzmall2/questionnaire-facdev ↩︎