diff --git a/handin-server/checker.rkt b/handin-server/checker.rkt index a549c56..ae739ea 100644 --- a/handin-server/checker.rkt +++ b/handin-server/checker.rkt @@ -327,7 +327,9 @@ ;; for adding lines in the checker (define added-lines (make-thread-cell #f)) -(provide add-header-line!) +(provide add-header-line! line:empty line:unsubst) +(struct line:empty () #:prefab) +(struct line:unsubst (str) #:prefab) (define (add-header-line! line) (let ([new (list line)] [cur (thread-cell-ref added-lines)]) (if cur @@ -482,6 +484,13 @@ (define generic-substs `(("submission" . ,submission-dir))) (define (prefix-line/substs str) (prefix-line (subst str generic-substs))) + (define (prefix-line/substs* str) + (if (line:empty? str) + (newline) + (prefix-line + (cond [(string? str) (subst str generic-substs)] + [(line:unsubst? str) (line:unsubst-str str)] + [else (error* "bad value in prefix lines: ~e" str)])))) (define (write-text) (set-run-status "creating text file") (with-output-to-file text-file #:exists 'truncate @@ -489,7 +498,7 @@ (for ([user (in-list users)]) (prefix-line (user-substs user student-line))) (for-each prefix-line/substs extra-lines) - (for-each prefix-line/substs + (for-each prefix-line/substs* (cond [(thread-cell-ref added-lines) => unbox] [else '()])) diff --git a/handin-server/scribblings/checker.scrbl b/handin-server/scribblings/checker.scrbl index f379f37..60ad1bf 100644 --- a/handin-server/scribblings/checker.scrbl +++ b/handin-server/scribblings/checker.scrbl @@ -205,7 +205,7 @@ Keywords for configuring @racket[check:]: @racketblock[ (lambda (msg) (add-header-line! "Erroneous submission!") - (add-header-line! (format " --> ~a" msg)) + (add-header-line! (line:unsubst (format " --> ~a" msg))) (message (string-append "You have an error in your program -- please hit" " \"Run\" and debug your code.\n" @@ -332,12 +332,21 @@ code.} submission directory, then the system will not allow ``@tt{foo}'' to submit with ``@tt{bar}''.)} -@defproc[(add-header-line! [line string?]) void?]{ +@defproc[(add-header-line! [line (or/c string? line:empty? line:unsubst?)]) void?]{ During the checker operation, can be used to add header lines to the text version of the submitted file (in addition to the @racket[:extra-lines] setting). It will not have an effect if @racket[:create-text?] is false.} +@defproc[(line:empty) line:empty?]{ + Helper for @racket[add-header-line!]: creates a value that results in an + added ampty line (not prefixed).} + +@defproc[(line:unsubst [str string?]) line:unsubst?]{ + Helper for @racket[add-header-line!]: creates a value that results in a + prefixed line with the given text which is not subtituted via [user-substs]. + Use this to avoid erroneous values from user strings (like error messages).} + @defproc[(procedure/arity? [proc procedure?] [arity number?]) boolean?]{ Returns @racket[#t] if @racket[proc] is a procedure that accepts