Skip to content

Commit 9342bee

Browse files
committed
iss1748 - Keep blank lines in content
1 parent 97dff10 commit 9342bee

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

stack/input/ascii/ascii.class.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,30 @@ protected function validate_contents($contents, $basesecurity, $localoptions) {
9292
return parent::validate_contents($contents, $basesecurity, $localoptions);
9393
}
9494

95-
/**
95+
/**
96+
* Transforms the student's response input into an array.
97+
* Most return the same as went in.
98+
*
99+
* @param array|string $in
100+
* @return string
101+
*/
102+
protected function response_to_contents($response) {
103+
$contents = [];
104+
if (array_key_exists($this->name, $response)) {
105+
$sans = $response[$this->name];
106+
if (trim($sans) == '' && $this->get_extra_option('allowempty')) {
107+
return ['EMPTYANSWER'];
108+
}
109+
$rowsin = explode("\n", $sans);
110+
foreach ($rowsin as $key => $row) {
111+
$cleanrow = trim($row);
112+
$contents[] = $cleanrow;
113+
}
114+
}
115+
return $contents;
116+
}
117+
118+
/**
96119
* This function constructs the display variable for validation.
97120
*
98121
* @param stack_casstring $answer, the complete answer.

0 commit comments

Comments
 (0)