added a substitution for the submission directory
svn: r2247
This commit is contained in:
parent
aacbf0c5a5
commit
0bfecf5fb5
|
@ -772,7 +772,8 @@ Keywords for configuring `check:':
|
||||||
|
|
||||||
* :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 ";;> " or :markup-prefix too. Defaults to a single line:
|
with a ";;> " or :markup-prefix too. Defaults to a single line:
|
||||||
"Maximum points for this assignment: <+100>".
|
"Maximum points for this assignment: <+100>". (Can use
|
||||||
|
"{submission}" for the submission directory.)
|
||||||
|
|
||||||
* :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
|
||||||
|
@ -869,7 +870,7 @@ value from the submission code.
|
||||||
information (see above) and then substitute field names in {braces}
|
information (see above) and then substitute field names in {braces}
|
||||||
by the corresponding value. An error will be signaled if a field
|
by the corresponding value. An error will be signaled if a field
|
||||||
name is missing. Also, "{username}" will always be replaced by the
|
name is missing. Also, "{username}" will always be replaced by the
|
||||||
username.
|
username and "{submission}" by the current submission directory.
|
||||||
|
|
||||||
This is used to process the `:student-line' value in the checker,
|
This is used to process the `:student-line' value in the checker,
|
||||||
but it is provided for additional uses. See the above sample code
|
but it is provided for additional uses. See the above sample code
|
||||||
|
|
|
@ -32,6 +32,18 @@
|
||||||
(map car (get-preference 'extra-fields (lambda () #f) #f
|
(map car (get-preference 'extra-fields (lambda () #f) #f
|
||||||
(build-path server-dir "config.ss"))))
|
(build-path server-dir "config.ss"))))
|
||||||
|
|
||||||
|
(provide submission-dir)
|
||||||
|
(define submission-dir-re
|
||||||
|
(regexp (string-append "[/\\]active[/\\]([^/\\]+)[/\\](?:[^/\\]+)"
|
||||||
|
"[/\\](?:SUCCESS-[0-9]+|ATTEMPT)[/\\]?$")))
|
||||||
|
(define (submission-dir)
|
||||||
|
(let ([m (regexp-match submission-dir-re
|
||||||
|
(path->string (current-directory)))])
|
||||||
|
(if m
|
||||||
|
(cadr m)
|
||||||
|
(error* "internal error: unexpected directory name: ~a"
|
||||||
|
(current-directory)))))
|
||||||
|
|
||||||
(provide user-data)
|
(provide user-data)
|
||||||
(define (user-data user)
|
(define (user-data user)
|
||||||
;; the student always assumed to exist
|
;; the student always assumed to exist
|
||||||
|
@ -40,7 +52,8 @@
|
||||||
|
|
||||||
(provide user-substs)
|
(provide user-substs)
|
||||||
(define (user-substs user str)
|
(define (user-substs user str)
|
||||||
(subst str `(("username" . ,user) ,@(map cons fields (user-data user)))))
|
(subst str `(("username" . ,user) ("submission" . ,submission-dir)
|
||||||
|
,@(map cons fields (user-data user)))))
|
||||||
|
|
||||||
(define (subst str substs)
|
(define (subst str substs)
|
||||||
(if (list? str)
|
(if (list? str)
|
||||||
|
@ -50,7 +63,10 @@
|
||||||
(if m
|
(if m
|
||||||
(subst (string-append
|
(subst (string-append
|
||||||
(substring str 0 (caar m))
|
(substring str 0 (caar m))
|
||||||
(cond [(assoc s substs) => cdr]
|
(cond [(assoc s substs)
|
||||||
|
=> (lambda (x)
|
||||||
|
(let ([s (cdr x)])
|
||||||
|
(if (procedure? s) (s) s)))]
|
||||||
[else (error 'subst "unknown substitution: ~s" s)])
|
[else (error 'subst "unknown substitution: ~s" s)])
|
||||||
(substring str (cdar m)))
|
(substring str (cdar m)))
|
||||||
substs)
|
substs)
|
||||||
|
@ -310,7 +326,7 @@
|
||||||
;; files)
|
;; files)
|
||||||
(let* ([pfx-len (string-length markup-prefix)]
|
(let* ([pfx-len (string-length markup-prefix)]
|
||||||
[line-len (- maxwidth pfx-len)]
|
[line-len (- maxwidth pfx-len)]
|
||||||
[=s (lambda (n) (make-string n #\=))]
|
[=s (lambda (n) (if (<= 0 n) (make-string n #\=) ""))]
|
||||||
[=== (format "~a~a\n" markup-prefix (=s line-len))])
|
[=== (format "~a~a\n" markup-prefix (=s line-len))])
|
||||||
(define (sep name)
|
(define (sep name)
|
||||||
(newline)
|
(newline)
|
||||||
|
@ -470,6 +486,9 @@
|
||||||
(define text-file (format "grading/text.~a" suffix))
|
(define text-file (format "grading/text.~a" suffix))
|
||||||
(define (prefix-line str)
|
(define (prefix-line str)
|
||||||
(printf "~a~a\n" markup-prefix str))
|
(printf "~a~a\n" markup-prefix str))
|
||||||
|
(define generic-substs `(("submission" . ,submission-dir)))
|
||||||
|
(define (prefix-line/substs str)
|
||||||
|
(prefix-line (subst str generic-substs)))
|
||||||
(define (write-text)
|
(define (write-text)
|
||||||
(current-run-status "creating text file")
|
(current-run-status "creating text file")
|
||||||
(with-output-to-file text-file
|
(with-output-to-file text-file
|
||||||
|
@ -478,8 +497,8 @@
|
||||||
(prefix-line
|
(prefix-line
|
||||||
(user-substs user student-line)))
|
(user-substs user student-line)))
|
||||||
users)
|
users)
|
||||||
(for-each prefix-line extra-lines)
|
(for-each prefix-line/substs extra-lines)
|
||||||
(for-each prefix-line
|
(for-each prefix-line/substs
|
||||||
(or (thread-cell-ref added-lines) '()))
|
(or (thread-cell-ref added-lines) '()))
|
||||||
(display submission-text))
|
(display submission-text))
|
||||||
'truncate))
|
'truncate))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user