handin: how to forbid the use of a certain function

49 views
Skip to first unread message

Wayne Harris

unread,
Sep 21, 2019, 12:17:30 PM9/21/19
to racket users
I haven't figured out how to forbid the use of length in submitted code.  I'm a little lost with

  :language
  :with-submission-bindings

I did understand

  :requires

so I'm able to let submissions use extra libraries, but I'd like to forbid, say, length in '(special beginner) too. 

Thanks!

Wayne Harris

unread,
Sep 25, 2019, 8:46:31 PM9/25/19
to racket users
I think my message below neither asked any question nor did it contain the adequate politeness which I so much think every e-mail should have.  Looking at it in retrospective, it seems wild that *I* did let a message like that go by.  Do believe me that I'm not saying this because I need help, but because I really consider a privilege to have access to a mail list of what I consider outstanding researchers.  (And I'd set myself to the highest standards even if it were not.)  (Yes, I'm still looking for a way to forbid the use of certain functions in code submissions of the handin-server.  I'm not in a hurry.  My objective is to prepare my tools now.  When the time comes, I'll be ready.)  Thank you and do please forgive me if my words lacked the proper adequacy.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Matthew Flatt

unread,
Sep 26, 2019, 8:56:51 AM9/26/19
to Wayne Harris, racket users
At Thu, 26 Sep 2019 00:46:23 +0000, "'Wayne Harris' via Racket Users" wrote:
> I think my message below neither asked any question nor did it contain the
> adequate politeness which I so much think every e-mail should have.

I don't see any problem with your message. It's more that the handin
server doesn't get a lot of love. I know the little part that I use,
and not much else...

> > I haven't figured out how to forbid the use of length in submitted code.
> I'm a little lost with
> >
> > :language
> > :with-submission-bindings
> >
> > I did understand
> >
> > :requires
> >
> > so I'm able to let submissions use extra libraries, but I'd like to forbid,
> say, length in '(special beginner) too.

There doesn't seem to be a simple way of disallowing the use of
`length`. Since `submission` is bound to the whole submission content,
you could have `pre:` action that reads and searches for the symbol
'length:

#lang s-exp handin-server/checker
(require racket/gui/base)

(check: :language '(special beginner))

(pre:
(define (mentions-length? r)
(cond
[(eq? r 'length) #t]
[(pair? r) (or (mentions-length? (car r))
(mentions-length? (cdr r)))]
[else #f]))
(define-values (defns interactions) (unpack-submission submission))
(define p (open-input-text-editor defns))
(parameterize ([read-accept-reader #t])
(let loop ()
(define r (read p))
(unless (eof-object? r)
(when (mentions-length? r)
(error "length not allowed"))
(loop)))))

A more precise approach would be to expand the program and check
whether there's any identifier bound to `length` that was part of the
original program (as opposed to introduced by a macro), but that's
probably more than you need. Or, of course, you could have a language
that's like Beginner without `length`, but that's probably too much
trouble for your students to set up.

Wayne Harris

unread,
Sep 27, 2019, 8:55:19 PM9/27/19
to Matthew Flatt, racket users
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, September 26, 2019 9:56 AM, Matthew Flatt <mfl...@cs.utah.edu> wrote:

> At Thu, 26 Sep 2019 00:46:23 +0000, "'Wayne Harris' via Racket Users" wrote:
>
> > I think my message below neither asked any question nor did it contain the
> > adequate politeness which I so much think every e-mail should have.
>
> I don't see any problem with your message. It's more that the handin
> server doesn't get a lot of love. I know the little part that I use,
> and not much else...

I guess there wasn't technically, but it did lack the care that is usual of me, so I didn't really like it and wanted to express that. Thanks for your attention.
(I think ``my editor'' couldn't help but destroy your indentation. I wonder if there anything I could do. Sorry about that.)

I think you're scanning the user code and looking for any mention of length. That is nice! I can use that for many other things. Thanks!

> A more precise approach would be to expand the program and check
> whether there's any identifier bound to `length` that was part of the
> original program (as opposed to introduced by a macro), but that's
> probably more than you need.

I'm not sure I get this idea, but let me take one thing at a time. Let me study and investigate the first approach which seems to suffice for now. Thanks!

> Or, of course, you could have a language
> that's like Beginner without `length`, but that's probably too much
> trouble for your students to set up.

I suppose it would --- if they'd submit from home, say.
Reply all
Reply to author
Forward
0 new messages