Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Allow float line nums in exam tool LONG*_INPUTS #430

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions exam-write/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,15 @@ For short / long answer questions, you must provide exactly one input statement
The `type` can be `SHORT_ANSWER`, `SHORT_CODE_ANSWER`, `LONG_ANSWER`, or `LONG_CODE_ANSWER`. `CODE`
means that the font will be monospaced and tab will work to indent text typed in a `LONG_CODE_ANSWER`.
For short answer questions, the `content` can optionally be a Javascript regular expression that matches valid
inputs, though invalid inputs can still be saved by the user. For long answer questions, the `content`
can optionally be an integer representing the number of lines provided in the input field before the user
has to start scrolling. This also affects the height of the box in the generated PDF in a similar way.
inputs, though invalid inputs can still be saved by the user.

For long answer questions, the `content` can optionally be a number representing the number of lines provided in the input field before the user
has to start scrolling. This also affects the height of the box in the generated PDF in a similar way. (Floating point values are no recommended, but are supported.)

```
# INPUT LONG_ANSWER 3
# INPUT LONG_CODE_ANSWER 4
```

## Solution and Note Syntax

Expand Down
4 changes: 2 additions & 2 deletions examtool/examtool/api/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ def parse_input_lines(lines):
elif directive == "SHORT_CODE_ANSWER":
return "short_code_answer", rest.strip(), None
try:
num_lines = int(rest or "10")
num_lines = float(rest or "10")
except TypeError:
raise SyntaxError("Expected integer as option for {}".format(directive))
raise SyntaxError("Expected number as option for {}".format(directive))
if directive == "LONG_ANSWER":
return "long_answer", num_lines, None
elif directive == "LONG_CODE_ANSWER":
Expand Down