[racket] handin-server and image? conflict with 2htdp/image and lang/htdp-beginner

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Feb 12 10:54:46 EST 2015

One solution is to create a module that exports only the things you
want, so that you can provide a module path that effectively implements
a more general `require` spec. Then, to avoid path problems, it will be
easiest to install that module as a package.


Specifically, create a directory and file

 bsl-plus-image/main.rkt

with the "main.rkt" content

 #lang racket/base
 (require 2htdp/image
          (except-in lang/htdp-beginner image? image=?))
 (provide (all-from-out 2htdp/image
                        lang/htdp-beginner))

Then, install the "bsl-plus-image" directory as a package for the
Racket installation that runs the handin server. You can do that with
the command line

 raco pkg install -i path/to/basl-plus-image

or you can leave out the `-i` if running `raco` as the same user as the
handin server process. You can also use the DrRacket "Install
Package..." menu item if that turns out to be more convenient, but keep
in mind that this is on the handin server side, not clients.

After installing the directory as a package, you can use

  (check: :language 'racket
          :requires '(bsl-plus-image                              
                      test-engine/racket-tests)
          ....)

Longer term, I think that the `racket/sandbox` as used by `check:`
should allow require specs, instead of just module paths.

At Tue, 10 Feb 2015 23:42:51 -0500, Suzanne Menzel wrote:
> Hello,
> 
> I’m having trouble getting the handin server to accept a BSL file that uses 
> the image library and also includes template definitions. I can make it work 
> separately. That is, I can accept BSL image program files as long as they 
> don’t have any templates and I can accept BSL programs with templates as long 
> as they don’t use images.
> 
> The problem is that when I go to require both 2htdp/image and 
> lang/htdp-beginner in the checker, there is a conflict with the image? 
> procedure being defined in both modules. Trying to use (except-in 2htdp/image 
> image?) inside the requires list doesn’t work.
> 
> What do I need to do to write a checker that will accept the student file 
> shown below?
> 
> My broken checker is included below. (The student file will also have 
> check-expects, which explains the presence of test-engine/racket-tests.)
> 
> Suzanne
> 
> ––––––-––––––-––––––-––––––-––––––-
> 
> ;; broken checker!
> #lang s-exp handin-server/checker
> (require handin-server/grading-utils)
> (pre: (check-deadline))
> (check: :language 'racket
>         :requires '(2htdp/image              ;;; (except-in 2htdp/image 
> image?)                                                            
>                     test-engine/racket-tests
>                     lang/htdp-beginner)
>         :create-text? #t
>         :textualize? #f
> )
> (post: #f)
> 
> 
> ;; Student file to be submitted
> (require 2htdp/image)
> ;; template:
> (define (process-strings strings)
>   (cond
>     [(empty? strings) ...]
>     [else (... (first strings) ...
> 	       (process-strings (rest strings)))]))
> ;; function based on template:
> (define (make-color-chart colors)
>   (cond
>     [(empty? colors) empty-image]
>     [else (beside
>            (rectangle 30 100 "solid" (first colors))
>            (make-color-chart (rest colors)))]))
> (check-expect (image-width (make-color-chart empty)) 0)
> 
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users


Posted on the users mailing list.