The DrRacket editor lets you put non-plain-text elements in your code. Look at this funny program. It contains fractions, comment boxes, and a smiley face.
Racket files with non-plain-text elements are save in WXME format. Here's some information about WXME:
RST does not accept WXME files. So if a student puts an improper fraction in his program, he will get zero on the auto-test.
Attached below is a script that will convert non-plain-text files to plain-text files. RST can then process the plain-text files.
To use this script, run it from the terminal. It accepts one argument: the file to convert. The output is printed to the screen.
racket wxme_converter.rkt file_to_convert.rkt
You can save the output to a file:
racket wxme_converter.rkt file_to_convert.rkt > plaintext.rkt
If you use this script on the above program, the output will be:
;; The first three lines of this file were inserted by DrRacket. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-abbr-reader.ss" "lang")((modname test-file) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ;; Numbers that are actually pictures. ;; They are all converted to improper fractions. 95/2 5/3 5/3 5/3 "Image removed by tutor." ;; f(x) = x + 5 + pi ;; Numbers are converted to improper fractions, ;; so definition of f is unchanged! (define (f x) (+ x 5/3 5/3 5/3 #i3.141592653589793)) (define (g x) (+ x 0.111111111111111111111111)) (define cardsuits " ♦ ♠ ♣ ♥ ") (define contract-arrow "→") (define examples-arrow "⇒") (string-length "Oops too many brackets"))) ;; Hello world! This is my pretty comment ;; box. Here are the instructors with no space between pictures ;; (identity "end of file")
Fractions, repeating decimals, and comment boxes are converted properly. Pictures are replaced with the string "Image removed by tutor."
If this script consumes a file that's already plain-text, it will just echo back the contents of the file.
I | Attachment | History | Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|---|
![]() |
test-file.rkt | r1 | manage | 44.0 K | 2011-12-23 - 13:35 | YiLee | The silly, demo program. |
![]() |
wxme_converter.rkt | r1 | manage | 2.2 K | 2011-12-23 - 13:42 | YiLee | This program converts WXME to plain-text. |