changing the output file prefix changes some other defaults

svn: r1867
This commit is contained in:
Eli Barzilay 2006-01-19 09:54:00 +00:00
parent 6108f2dafd
commit 1f7cffecae
2 changed files with 49 additions and 13 deletions

View File

@ -717,9 +717,11 @@ Keywords for configuring `check:':
null -- no teachpacks. null -- no teachpacks.
* :create-text? -- if true, then a textual version of the submission * :create-text? -- if true, then a textual version of the submission
is saved as `text.scm' in a `grading' subdirectory. This is is saved as "text.scm" in a "grading" subdirectory (or any suffix
intended for printouts and grading, and is in a subdirectory so that is specified by :output below, for example "hw.java" is
students will not see it on the status web server. Defaults to #t. converted into a textual "grading/text.java"). This is intended for
printouts and grading, and is in a subdirectory so students will not
see it on the status web server. Defaults to #t.
* :textualize? -- if true, then all submissions are converted to text, * :textualize? -- if true, then all submissions are converted to text,
trying to convert objects like comment boxes and test cases to some trying to convert objects like comment boxes and test cases to some
@ -731,7 +733,18 @@ Keywords for configuring `check:':
to 79. This feature can be disabled if set to #f. to 79. This feature can be disabled if set to #f.
* :output -- the name of the original handin file (unrelated to the * :output -- the name of the original handin file (unrelated to the
text-converted files). Defaults to "hw.scm". text-converted files). Defaults to "hw.scm". (The suffix changes
the defaults of the following two entries.)
* :markup-prefix -- used as the prefix for :student-lines and
:extra-lines below. The default is ";;> " or "//> ", depending on
the suffix of :output above. (Note: if you change this, make sure
to change :prefix-re too.)
* :prefix-re -- used to identify lines with markup (";>" or "//>"
etc), so students cannot fool the system by writing marked-up code.
The default is ";>" or "//>", depending on the suffix of :output
above.
* :student-line -- when a submission is converted to text, it begins * :student-line -- when a submission is converted to text, it begins
with lines describing the students that have submitted it; this is with lines describing the students that have submitted it; this is
@ -739,11 +752,12 @@ Keywords for configuring `check:':
holes that that `user-substs' (see below) fills out. The default is holes that that `user-substs' (see below) fills out. The default is
"Student: {username} ({Full Name} <{Email}>)", which requires a "Student: {username} ({Full Name} <{Email}>)", which requires a
"Full Name" and "Email" entries in the server's extra-fields "Full Name" and "Email" entries in the server's extra-fields
configuration. These lines are always prefixed with ";;> ". configuration. These lines are prefixed with ";;> " or the prefix
specified by :makup-prefix above.
* :extra-lines -- a list of lines to add after the student lines, all * :extra-lines -- a list of lines to add after the student lines, all
with a ";;> " prefix too. Defaults to a single line: "Maximum with a ";;> " or :markup-prefix too. Defaults to a single line:
points for this assignment: <+100>". "Maximum points for this assignment: <+100>".
* :user-error-message -- a string that is used to report an error that * :user-error-message -- a string that is used to report an error that
occurred during evaluation of the submitted code (not during occurred during evaluation of the submitted code (not during

View File

@ -247,6 +247,8 @@
[create-text?* (get ':create-text? #'#t)] [create-text?* (get ':create-text? #'#t)]
[textualize?* (get ':textualize? #'#f)] [textualize?* (get ':textualize? #'#f)]
[maxwidth* (get ':maxwidth #'79)] [maxwidth* (get ':maxwidth #'79)]
[markup-prefix* (get ':markup-prefix #'#f)]
[prefix-re* (get ':prefix-re #'#f)]
[student-line* [student-line*
(get ':student-line (get ':student-line
#'"Student: {username} ({Full Name} <{Email}>)")] #'"Student: {username} ({Full Name} <{Email}>)")]
@ -287,6 +289,8 @@
[create-text? create-text?*] [create-text? create-text?*]
[textualize? textualize?*] [textualize? textualize?*]
[maxwidth maxwidth*] [maxwidth maxwidth*]
[markup-prefix markup-prefix*]
[prefix-re prefix-re*]
[student-line student-line*] [student-line student-line*]
[extra-lines extra-lines*] [extra-lines extra-lines*]
[value-printer value-printer*] [value-printer value-printer*]
@ -295,6 +299,20 @@
[user-error-message user-error-message*] [user-error-message user-error-message*]
[execute-counts #f]) [execute-counts #f])
;; ======================================== ;; ========================================
;; set defaults that depend on file name
(define suffix
(let ([sfx (string->symbol
(string-downcase
(regexp-replace #rx"^.*[.]" output-file "")))])
(case sfx
[(java c cc c++)
(unless markup-prefix (set! markup-prefix "//> "))
(unless prefix-re (set! prefix-re #rx"//>"))]
[else
(unless markup-prefix (set! markup-prefix ";;> "))
(unless prefix-re (set! prefix-re #rx";>"))])
sfx))
;; ========================================
;; verify submitting users ;; verify submitting users
(define (pre users submission) (define (pre users submission)
(current-run-status "checking submission username(s)") (current-run-status "checking submission username(s)")
@ -316,17 +334,19 @@
;; ======================================== ;; ========================================
;; convert to text, evaluate, check ;; convert to text, evaluate, check
(define (check users submission) (define (check users submission)
(define text-file "grading/text.scm") (define text-file (format "grading/text.~a" suffix))
(define (prefix-line str)
(printf "~a~a\n" markup-prefix str))
(define (write-text) (define (write-text)
(with-output-to-file text-file (with-output-to-file text-file
(lambda () (lambda ()
(define added (or (thread-cell-ref added-lines) '())) (define added (or (thread-cell-ref added-lines) '()))
(for-each (for-each
(lambda (user) (lambda (user)
(printf ";;> ~a\n" (user-substs user student-line))) (prefix-line (user-substs user student-line)))
users) users)
(for-each (lambda (l) (printf ";;> ~a\n" l)) extra-lines) (for-each prefix-line extra-lines)
(for-each (lambda (l) (printf ";;> ~a\n" l)) added) (for-each prefix-line added)
(display submission-text)) (display submission-text))
'truncate)) 'truncate))
(define submission-text (define submission-text
@ -334,8 +354,10 @@
(submission->string submission maxwidth textualize?))) (submission->string submission maxwidth textualize?)))
(when create-text? (when create-text?
(make-directory "grading") (make-directory "grading")
(when (regexp-match #rx";>" submission-text) (when (regexp-match prefix-re submission-text)
(error* "You cannot use \";>\" in your code!")) (error* "You cannot use \"~a\" in your code!"
(if (regexp? prefix-re)
(object-name prefix-re) prefix-re)))
(write-text)) (write-text))
(when value-printer (current-value-printer value-printer)) (when value-printer (current-value-printer value-printer))
(when coverage? (coverage-enabled #t)) (when coverage? (coverage-enabled #t))