Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added multiline attribute to string input element #9438

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
099cf70
Added multiline attribute to string input function
eliotwrobson Feb 19, 2024
beb6bd2
Updated example question
eliotwrobson Feb 19, 2024
f17253a
Comments
eliotwrobson Feb 19, 2024
d4be415
Merge branch 'master' into string_textinput
eliotwrobson Feb 21, 2024
6a4aab3
trying something
eliotwrobson Feb 21, 2024
ebc8929
Merge branch 'string_textinput' of https://github.com/eliotwrobson/Pr…
eliotwrobson Feb 21, 2024
6136e8e
Revised example question
eliotwrobson Feb 21, 2024
0eef7c6
Updated newline example
eliotwrobson Feb 22, 2024
bea95e4
Updated panel display
eliotwrobson Feb 22, 2024
6def210
Merge branch 'master' into string_textinput
eliotwrobson Feb 22, 2024
6d09f46
Merge branch 'master' into string_textinput
eliotwrobson Apr 2, 2024
6fbfa86
Initial changes
eliotwrobson Apr 2, 2024
30b25bd
default changes
eliotwrobson Apr 2, 2024
561a2cd
Update docs/elements.md
eliotwrobson Apr 2, 2024
5727541
Python changes
eliotwrobson Apr 2, 2024
19e04f6
Question changes
eliotwrobson Apr 2, 2024
c72d8a0
stuff
eliotwrobson Apr 2, 2024
cb9f1cd
format
eliotwrobson Apr 2, 2024
1ac994a
Merge branch 'master' into string_textinput
eliotwrobson Apr 3, 2024
d1d1992
Added escape unicode option
eliotwrobson Apr 6, 2024
ab75b7b
Merge branch 'master' into string_textinput
eliotwrobson Apr 6, 2024
a28fd22
types
eliotwrobson Apr 6, 2024
7318784
Added multiline transform
eliotwrobson Apr 9, 2024
1e734b6
Initial change, still seeing some things not printing but a good star…
eliotwrobson Apr 12, 2024
15490d1
Logic + display for new behavior
eliotwrobson Apr 13, 2024
8a9c2ee
format
eliotwrobson Apr 13, 2024
c5e2d64
Update docs/elements.md
eliotwrobson Apr 13, 2024
0402f66
removed attribute
eliotwrobson Apr 13, 2024
6e4e57b
Merge branch 'string_textinput' of https://github.com/eliotwrobson/Pr…
eliotwrobson Apr 13, 2024
9032c6d
Updated docs about newline behavior
eliotwrobson Apr 13, 2024
55a1a49
Updated example question and other behavior
eliotwrobson Apr 13, 2024
6daf5f1
Format
eliotwrobson Apr 13, 2024
bee5f79
Merge branch 'master' into string_textinput
eliotwrobson Apr 13, 2024
6bb8fe8
Removed line break
eliotwrobson Apr 13, 2024
a60af8e
Merge branch 'string_textinput' of https://github.com/eliotwrobson/Pr…
eliotwrobson Apr 13, 2024
46cdfeb
Merge branch 'master' into string_textinput
eliotwrobson Apr 22, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,35 @@
<span class="input-group-text" id="pl-string-input-{{uuid}}-label">{{{label}}}</span>
</span>
{{/label}}
{{^multiline}}
<input
{{/multiline}}
{{#multiline}}
<textarea
wrap="soft"
{{/multiline}}
name="{{name}}"
type="text"
inputmode="text"
class="form-control pl-string-input-input"
size="{{size}}"
{{^multiline}}
size="{{size}}"
{{#raw_submitted_answer}}value="{{raw_submitted_answer}}"{{/raw_submitted_answer}}
{{/multiline}}
{{#multiline}}
cols="{{size}}"
rows="1"
eliotwrobson marked this conversation as resolved.
Show resolved Hide resolved
{{/multiline}}
autocomplete="off"
{{^editable}}disabled{{/editable}}
{{#raw_submitted_answer}}value="{{raw_submitted_answer}}"{{/raw_submitted_answer}}
aria-describedby="pl-symbolic-input-{{uuid}}-label pl-symbolic-input-{{uuid}}-suffix"
placeholder="{{placeholder}}"
/>
{{^multiline}}
>
{{/multiline}}
{{#multiline}}
>{{#raw_submitted_answer}}{{raw_submitted_answer}}{{/raw_submitted_answer}}</textarea>
jonatanschroeder marked this conversation as resolved.
Show resolved Hide resolved
{{/multiline}}
<span class="input-group-append">
{{#suffix}}<span class="input-group-text" id="pl-symbolic-input-{{uuid}}-suffix">{{suffix}}</span>{{/suffix}}

Expand Down
3 changes: 3 additions & 0 deletions apps/prairielearn/elements/pl-string-input/pl-string-input.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class DisplayType(Enum):
SHOW_HELP_TEXT_DEFAULT = True
SHOW_SCORE_DEFAULT = True
NORMALIZE_TO_ASCII_DEFAULT = False
MULTILINE_DEFAULT = False

STRING_INPUT_MUSTACHE_TEMPLATE_NAME = "pl-string-input.mustache"

Expand All @@ -49,6 +50,7 @@ def prepare(element_html: str, data: pl.QuestionData) -> None:
"show-help-text",
"normalize-to-ascii",
"show-score",
"multiline",
]
pl.check_attribs(element, required_attribs, optional_attribs)

Expand Down Expand Up @@ -130,6 +132,7 @@ def render(element_html: str, data: pl.QuestionData) -> str:
display.value: True,
"raw_submitted_answer": raw_submitted_answer,
"parse_error": parse_error,
"multiline": pl.get_boolean_attrib(element, "multiline", MULTILINE_DEFAULT),
}

if show_score and score is not None:
Expand Down
3 changes: 2 additions & 1 deletion docs/elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -998,8 +998,9 @@ def generate(data):
| `ignore-case` | boolean | false | Whether or not to enforce case sensitivity (e.g. "hello" != "HELLO"). |
| `normalize-to-ascii` | boolean | false | Whether non-English characters (accents, non-latin alphabets, fancy quotes) should be normalized to equivalent English characters before submitting the file for grading. |
| `placeholder` | text | None | Hint displayed inside the input box describing the expected type of input. |
| `size` | integer | 35 | Size of the input box. |
| `size` | integer | 35 | Width of the input box. |
| `show-help-text` | boolean | true | Show the question mark at the end of the input displaying required input parameters. |
| `multiline` | boolean | false | Whether or not to use a multiline input for this element. |
jonatanschroeder marked this conversation as resolved.
Show resolved Hide resolved

#### Example implementations

Expand Down
Loading