options.rkt

There are two different kinds of options.rkt files. The one directly under the in directory contains the global options for the entire assignment. It will have the following form.

(language scheme/LANGCHOICE) 
(timeout 60) 
(memory 256)  
(value 1)        

LANGCHOICE is the language level allowed. This will be set depending on the assignment specifications. The possible options are beginner, beginner-abbr, intermediate, or intermediate-lambda.

The next line contains the time limit in seconds that the students are allowed for each test; it can be omitted, defaulting to 60. Please note that this means that each individual test has this time limit, not all tests for one question.

The memory line has the allowed memory per test in MB; it can be omitted, defaulting to 1024 (one gigabyte). If the default is not working then you may need to add this line to increase the memory limit, or instructors may want a more restrictive memory limit.

The upload size limit for student submissions is 25MB as of Fall 2020. If students need to upload larger files, contact CSCF.

Lastly, the value line should not need to be changed.

The second type of options files are the ones under each question. These files have specifications for each individual question. The general form is below.

(desc "string describing the test") 
(modules "lib1.rkt" "lib2.rkt" "disallowed.rkt") 
(loadcode "filename.rkt")         

The desc in the first line stands for description, and contains a string. There should be a convention to follow throughout the term. For example, you may want to use something like "Checking 2b".

The modules line contains all of the libraries that need to be included. Each of these arguments will be converted into a (require "libX.rkt") placed at the top of the student's file in the same order, and makes sure the file gets copied to the temp folder where the testing takes place. The files listed here are strings with spaces between each other. Also note that a file must be located in the provided directory if you want to include it as a standard module; alternatively, if it does not exist in the provided directory, the student's version in the handin folder will be used. If the students are given a library as part of the assignment, that library also needs to be included in the modules list. The disallowed.rkt file should be last, because it usually disallows the function require, which gets called when any subsequent modules are provided into the student's file. There are no filename requirements to follow, but we try to use names like "disallowed-except-reverse.rkt" and "provided-3b.rkt" for consistency.

The loadcode specifies the file name that the students solution is expected to be in. There should only be one file; put other relevant student files in the (modules ...) line.

It is possible to specify modules in the global options. This follows the same rules as adding modules to a local options file, therefore the file must be in provided. The line for modules must be added to the file, so a global options file could look like the following.

(language scheme/beginner-abbr) 
(timeout 60)
(memory 256)
(value 1)
(modules "filename1.rkt" "filename2.rkt" "filename3.rkt") 

It is also possible to specify any lines from the global options in the options for a single question. For example, you may want every question to use a 60 second time limit and beginning student, but allow 3b to have only 30 seconds and beginning student with list abbreviations. In this case the options.rkt under 3b may look like the following.

(desc "Checking 3b") 
(modules "disallowed.rkt") 
(loadcode "anagram.rkt") 
(language scheme/beginner-abbr) 
(timeout 30) 

There are some extra options you can use to set up options.rkt. You can refer to this page BitterSuiteScheme for more information.

instructor-script option

The instructor-script option lets you run a script before RST runs the student's Racket file. The script can fail the test case before the student's file is run. It can also be used to set a custom pass message.

An example of using it: add (instructor-script "myscript.sh") to your options.rkt file. When RST checks a test case, it'll run myscript.sh as csNNN account. The script is assumed to be in your test.0 or test.pt folder, but if your script is saved elsewhere, you can enter the full path instead of just the script's name.

  • If myscript.sh exits with code 0, then RST will run the student's Racket file and check the test.rkt file as usual. The pass message will be whatever myscript.sh prints out (both stdout and stderr are captured).
  • If myscript.sh exits with code other than 0, then the test case fails. The failure message will be whatever myscript.sh prints out. The student's file is not run.
In this example, the script is a Bash script but you can use any language, such as Python. Set the language using #! at the top of your script. Data about the submission is given to your script using environment variables.

For example, the following instructor-script will check if the file a01q1.rkt was submitted and that it contains the word Hello:

#!/bin/bash
# If you want to use Python, you can change the above to: #!/usr/bin/env python3

# This Bash script checks if the student's file contains the word Hello.

# Check if student submitted the (loadcode ...) file
if [ ! -e "${submitdir}/${studentfile}" ]; then
    # Student did not submit file. Let RST try and
    # run the file, which will fail and display a
    # message to students.
    exit 0
fi

# File exists, so check if it contains Hello
if grep -q Hello "${submitdir}/${studentfile}"; then
    # Contains hello, so pass
    echo "Congrats! You pass the test! :)"
    exit 0
fi

# File exists but doesn't contain Hello.
# Print feedback to student and fail by exiting with
# non-zero code.
echo "Your code doesn't contain Hello"
echo "Please add it somewhere and re-submit"
exit 1
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2021-12-21 - XiyuChen
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback