Wxme Converter

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.

badcode.jpg

Racket files with non-plain-text elements are saved 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.

wxme_converter.rkt, attached below, is a script that will convert WXME 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. This saves the output in plaintext.rkt. Warning: this will overwrite the file plaintext.rkt if it already exists.

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."    #|  #|  #| box in a box in a box |#  |#  |# 

;; 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 "⇒")

;; #|  A comment box that's commented out? "Image removed by tutor." |#  insane!

(string-length "\"\"")
42 #| Hello world! This is my pretty comment
box. The sum of 4 and 4 is given by: |# (+ 4 4)
(string-append "4 + 4" " = " "8")

(identity "end of file")


Fractions and repeating decimals are converted properly. Pictures are replaced with the string "Image removed by tutor." Comment boxes are replaced with #| ... |# comment blocks (see http://docs.racket-lang.org/reference/reader.html?q=comment%20block#%28part._parse-comment%29)

If this script is given a file that's already in plain-text, it will just print that file.

Finding students who submit WXME files

WXME files have a very distinct header:

#reader(lib"read.ss""wxme")WXME0108 ## 
#|
   This file uses the GRacket editor format.
   Open this file in DrRacket version 5.1.2 or later to read it.

   Most likely, it was created by saving a program in DrRacket,
   and it probably contains a program with non-text elements
   (such as images or comment boxes).

            http://racket-lang.org/
|#

You can use grep to easily find all the students who submit WXME files. Using CS115 assignment 04 as an example:

cd /u/cs115/handin/a04_autotest/
grep "This file uses" */*

The grep command will list all the students who submitted WXME files.

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatrkt test-file.rkt r2 r1 manage 53.3 K 2011-12-23 - 15:57 YiLee The silly, demo program.
Unknown file formatrkt wxme_converter.rkt r2 r1 manage 1.9 K 2011-12-23 - 15:57 YiLee This program converts WXME to plain-text.
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2014-03-17 - YiLee
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback