Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions handin-server/checker.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -482,14 +484,21 @@
(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
(lambda ()
(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 '()]))
Expand Down
13 changes: 11 additions & 2 deletions handin-server/scribblings/checker.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down