Skip to content

#lang student langs do not work with handin #59

@jestarray

Description

@jestarray
  (check: :language  '(module htdp-bsl)
          :create-text? #t
          ...)

raises this error:

submit error: Error in your code --
make-module-evaluator: module code used `lang/htdp-beginner' for a language, expecting `htdp/bsl'

But changing it to '(module lang/htdp-beginner) rasies this error:

submit error: Error in your code --
make-evaluator: disallowed reader module path: (submod htdp/bsl reader)

Sam mentioned in discord not to expect handin to match development of racket #langs but I'm leaving this issue here for future reference.

edit(hacky fix):

try to get "#lang htdp/*sl languages working:

The #lang htdp/*sl languages have a lot of improvements over the menu based ones, however handin source code needs to adjust for it.
The problem is that call-with-evaluator/submission with #lang will have a sort of "double #lang".
make-evaluator* in line handin-server/utils.rkt calls:

Detect when submissions are using #lang before the call to call-with-evaluator/submission(in handin-server/utils.rkt:206) pass in the length of the #lang htdp/bsl(14 in this case) so call-with-evaluator/submission can call (open-input-text-editor defs <SKIP-FIRST-N-CHARS>)
The problem with this is that call-with-evaluator/submission recieves the lang argument from the given graderX_checker.rkt instead of parsing the file and geting the language line itself
We can just handle the most popular #lang lengths. #lang htdp/*sl will always be 14 in length

; utils.rkt
; the fix is to patch over this function
(define (call-with-evaluator/submission lang requires str
                                        #:allowed-requires [allowed-requires #f]
                                        go)
  (let-values ([(defs interacts) (unpack-submission str)])
    (define maybe#lang (read-bytes 16 (open-input-text-editor defs)))
    (define has-hash-lang? (regexp-match #rx#"#lang " maybe#lang))
    ; skip over the read of the #lang line
    ; for this to work, it requires the checker/graders pass are like this: (:check :language 'lang/htdp-intermediate)
    (define skip-lang-line (if has-hash-lang? (bytes-length (car (regexp-match #rx"^[^ ]* [^ ]*" maybe#lang))) 0))
    (call-with-evaluator lang requires (open-input-text-editor defs skip-lang-line)
                         #:allowed-requires allowed-requires
                         go)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions