Skip to content

Commit

Permalink
Reduced the validity of the field trimonsave
Browse files Browse the repository at this point in the history
Each item (item = fields + formats) in surveypro uses a set of fields.
Some of them are (MORE OR LESS) common for each item, some of them are very specific for an item.
For instance: Content is a common field for EACH item. Signed is specific for numeric field ONLY.

The situation at the moment is described in the following table.

```
                   AGE |   AUTOFILL  | BOOLEAN | CHARACTER | CHECKBOX        | DATE | DATETIME | FILEUPLOAD | INTEGER | MULTISELECT     | NUMERIC  | RADIOBUTTON | RATE           | RECURRENCE | SELECT     | SHORTDATE | TEXTAREA  | TIME |    | FIELDSET      | FIELDSETEND | LABEL     | PAGEBREAK |
content          | √   |   √         | √       | √         | √               | √    | √        | √          | √       | √               | √        | √           | √              | √          | √          | √         | √         | √    | 18 | √             | NO          | √         | NO        |
contentformat    | √   |   √         | √       | √         | √               | √    | √        | √          | √       | √               | √        | √           | √              | √          | √          | √         | √         | √    | 18 | NO            | NO          | √         | NO        |

required         | √   |   NO        | √       | √         | √               | √    | √        | √          | √       | √               | √        | √           | √              | √          | √          | √         | √         | √    | 17 | NO            | NO          | NO        | NO        |
indent           | √   |   √         | √       | √         | √               | √    | √        | √          | √       | √               | √        | √           | √              | √          | √          | √         | √         | √    | 18 | NO            | NO          | √         | NO        |
position         | √   |   √         | √       | √         | √               | √    | √        | √          | √       | √               | √        | √           | √              | √          | √          | √         | √         | √    | 18 | NO            | NO          | NO        | NO        |
customnumber     | √   |   √         | √       | √         | √               | √    | √        | √          | √       | √               | √        | √           | √              | √          | √          | √         | √         | √    | 18 | NO            | NO          | √         | NO        |
hideinstructions | √   |   NO        | NO      | √         | √               | √    | √        | NO         | √       | √               | √        | NO          | √              | √          | NO         | √         | √         | √    | 13 | NO            | NO          | NO        | NO        |
variable         | √   |   √         | √       | √         | √               | √    | √        | √          | √       | √               | √        | √           | √              | √          | √          | √         | √         | √    | 18 | NO            | NO          | NO        | NO        |
extranote        | √   |   √         | √       | √         | √               | √    | √        | √          | √       | √               | √        | √           | √              | √          | √          | √         | √         | √    | 18 | NO            | NO          | NO        | NO        |
trimonsave       | NO  |   NO        | NO      | √         | NO              | NO   | NO       | NO         | NO      | NO              | NO       | NO          | NO             | NO         | NO         | NO        | √         | NO   |  2 | NO            | NO          | √         | NO        |
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
defaultoption    | √   |  NO         | √       | NO        | NO              | √    | √        | NO         | √       | NO              | NO       | √           | √              | √          | √          | √         | NO        | √    | 11 | NO            | NO          | √         | NO        |
defaultvalue     | √   |  NO         | √       | √         | √               | √    | √        | NO         | √       | √               | √        | √           | √              | √          | √          | √         | NO        | √    | 15 | NO            | NO          | √         | NO        |
downloadformat   | NO  |  NO         | √       | NO        | NO              | √    | √        | NO         | NO      | √               | NO       | √           | √              | √          | √          | √         | NO        | √    | 10 | NO            | NO          | √         | NO        |
noanswerdefault  | NO  |  NO         | NO      | NO        | √               | NO   | NO       | NO         | NO      | √               | NO       | NO          | NO             | NO         | NO         | NO        | NO        | NO   |  2 | NO            | NO          | √         | NO        |
lowerbound       | √   |  NO         | NO      | NO        | NO              | √    | √        | NO         | √       | NO              | √        | NO          | NO             | √          | NO         | √         | NO        | √    |  8 | NO            | NO          | √         | NO        |
upperbound       | √   |  NO         | NO      | NO        | NO              | √    | √        | NO         | √       | NO              | √        | NO          | NO             | √          | NO         | √         | NO        | √    |  8 | NO            | NO          | √         | NO        |
options          | NO  |  NO         | NO      | NO        | √               | NO   | NO       | NO         | NO      | √               | NO       | √           | √              | NO         | √          | NO        | NO        | NO   |  5 | NO            | NO          | √         | NO        |
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––--–––––––––––––––––––––––––––––––––––––
                       | hiddenfield |  style  | pattern   | labelother      |      | step     | maxfiles   |         | heightinrows    | signed   | labelother  | rates          |            | labelother |           | useeditor | step |    | defaultstatus |             | fullwidth |
                       | element01   |         | minlength | downloadformat  |                 | maxbytes   |         | minimumrequired | decimals | adjustment  | style          |                                     | arearows  |                                         | leftlabel |
                       | element02   |         | maxlength | minimumrequired |                 | filetypes  |         | maximumrequired |                        | differentrates |                                     | areacols  |
                       | element03   |                     | maximumrequired |                                                                                                                                          | minlength |
                       | element04   |                     | adjustment      |                                                                                                                                          | maxlength |
                       | element05   |
```
The three sections of this table are, in the order, for:
- fields that are more or less FOR EACH ITEM
- fields that are specific but very popular among items
- fields that are specific for a single field only (more or less)

Between the first set of columns (referring to fields) and the second set of columns (referring to formats) I added the number of fields having the specific property (specified at the beginning of the row).
As you can see the property "trimonsave" has no title at all to be in the first part of the table. (Only two fields have the property "trimonsave")
This is the reason justifying this PR.
  • Loading branch information
kordan committed Mar 7, 2024
1 parent 3c65542 commit f5414dd
Show file tree
Hide file tree
Showing 49 changed files with 163 additions and 124 deletions.
12 changes: 1 addition & 11 deletions classes/itembase.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ class itembase {
'content' => true,
'customnumber' => true,
'position' => true,
'trimonsave' => true,
'extranote' => true,
'hideinstructions' => true,
'required' => true,
Expand Down Expand Up @@ -285,7 +284,7 @@ protected function get_common_settings($record) {
// Plugin and type are already onboard.

// Checkboxes content.
$checkboxessettings = ['hidden', 'insearchform', 'reserved', 'hideinstructions', 'required', 'trimonsave'];
$checkboxessettings = ['hidden', 'insearchform', 'reserved', 'hideinstructions', 'required'];
foreach ($checkboxessettings as $checkboxessetting) {
if ($this->insetupform[$checkboxessetting]) {
$record->{$checkboxessetting} = isset($record->{$checkboxessetting}) ? 1 : 0;
Expand Down Expand Up @@ -1520,15 +1519,6 @@ public static function get_pdf_template() {
return SURVEYPRO_3COLUMNSTEMPLATE;
}

/**
* Was the user input marked as "to trim"?
*
* @return if the calling plugin requires a user input trim
*/
public function get_trimonsave() {
return false;
}

/**
* Get itemeditingfeedback.
*
Expand Down
8 changes: 0 additions & 8 deletions classes/local/form/item_setupbaseform.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,6 @@ public function definition() {
$mform->setType($fieldname, PARAM_TEXT);
}

// Itembase: trimonsave.
$fieldname = 'trimonsave';
if ($item->get_insetupform($fieldname)) {
$mform->addElement('checkbox', $fieldname, get_string($fieldname, 'mod_surveypro'));
$mform->addHelpButton($fieldname, $fieldname, 'surveypro');
$mform->setType($fieldname, PARAM_INT);
}

// Itembase: extranote.
$fieldname = 'extranote';
if ($item->get_insetupform($fieldname)) {
Expand Down
3 changes: 2 additions & 1 deletion classes/local/form/userform.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ public function validation($data, $files) {
}

if ($itemisenabled) {
if ($item->get_trimonsave()) {
$propertyexists = property_exists('surveypro'.$type.'_'.$plugin.'\item', 'trimonsave');
if ($propertyexists && $item->get_trimonsave()) {
if (trim($content) != $content) {
$warnings[$elementname] = get_string('uerr_willbetrimmed', 'mod_surveypro');
}
Expand Down
5 changes: 2 additions & 3 deletions field/age/classes/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function __construct($cm, $surveypro, $itemid, $getparentcontent) {
// No properties here.

// List of fields I do not want to have in the item definition form.
$this->insetupform['trimonsave'] = false;
// Empty list.

if (!empty($itemid)) {
$this->item_load($itemid, $getparentcontent);
Expand Down Expand Up @@ -343,7 +343,7 @@ public function item_custom_fields_to_db($record) {
// Nothing to do: no need to overwrite variables.

// 3. Set values corresponding to checkboxes.
// Take care: 'required', 'trimonsave', 'hideinstructions' were already considered in get_common_settings.
// Take care: 'required', 'hideinstructions' were already considered in get_common_settings.
// Nothing to do: no checkboxes in this plugin item form.

// 4. Other.
Expand Down Expand Up @@ -411,7 +411,6 @@ public static function get_plugin_schema() {
<xs:element name="hideinstructions" type="xs:int"/>
<xs:element name="variable" type="xs:string"/>
<xs:element name="extranote" type="xs:string" minOccurs="0"/>
<!-- <xs:element name="trimonsave" type="xs:int"/> -->
<xs:element name="defaultoption" type="xs:int"/>
<xs:element name="defaultvalue" type="unixtime" minOccurs="0"/>
Expand Down
4 changes: 1 addition & 3 deletions field/autofill/classes/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ public function __construct($cm, $surveypro, $itemid, $getparentcontent) {
// No properties here.

// List of fields I do not want to have in the item definition form.
$this->insetupform['trimonsave'] = false;
$this->insetupform['required'] = false;
$this->insetupform['hideinstructions'] = false;
$this->insetupform['parentid'] = false;
Expand Down Expand Up @@ -302,7 +301,7 @@ public function item_custom_fields_to_db($record) {
$record->hideinstructions = 1;

// 3. Set values corresponding to checkboxes.
// Take care: 'required', 'trimonsave', 'hideinstructions' were already considered in get_common_settings.
// Take care: 'required', 'hideinstructions' were already considered in get_common_settings.
$checkboxes = ['hiddenfield'];
foreach ($checkboxes as $checkbox) {
$record->{$checkbox} = (isset($record->{$checkbox})) ? 1 : 0;
Expand Down Expand Up @@ -385,7 +384,6 @@ public static function get_plugin_schema() {
<!-- <xs:element name="hideinstructions" type="xs:int"/> -->
<xs:element name="variable" type="xs:string"/>
<xs:element name="extranote" type="xs:string" minOccurs="0"/>
<!-- <xs:element name="trimonsave" type="xs:int"/> -->
<xs:element name="hiddenfield" type="xs:int"/>
<xs:element name="element01" type="xs:string" minOccurs="0"/>
Expand Down
4 changes: 1 addition & 3 deletions field/boolean/classes/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ public function __construct($cm, $surveypro, $itemid, $getparentcontent) {
// No properties here.

// List of fields I do not want to have in the item definition form.
$this->insetupform['trimonsave'] = false;
$this->insetupform['hideinstructions'] = false;

if (!empty($itemid)) {
Expand Down Expand Up @@ -225,7 +224,7 @@ public function item_custom_fields_to_db($record) {
$record->hideinstructions = 1;

// 3. Set values corresponding to checkboxes.
// Take care: 'required', 'trimonsave', 'hideinstructions' were already considered in get_common_settings.
// Take care: 'required', 'hideinstructions' were already considered in get_common_settings.
// Nothing to do: no checkboxes in this plugin item form.

// 4. Other.
Expand Down Expand Up @@ -324,7 +323,6 @@ public static function get_plugin_schema() {
<!-- <xs:element name="hideinstructions" type="xs:int"/> -->
<xs:element name="variable" type="xs:string"/>
<xs:element name="extranote" type="xs:string" minOccurs="0"/>
<!-- <xs:element name="trimonsave" type="xs:int"/> -->
<xs:element name="defaultoption" type="xs:int"/>
<xs:element name="defaultvalue" type="xs:int" minOccurs="0"/>
Expand Down
9 changes: 6 additions & 3 deletions field/character/classes/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,11 @@ public function item_custom_fields_to_db($record) {
}

// 3. Set values corresponding to checkboxes.
// Take care: 'required', 'trimonsave', 'hideinstructions' were already considered in get_common_settings.
// Nothing to do: no checkboxes in this plugin item form.
// Take care: 'required', 'hideinstructions' were already considered in get_common_settings.
$checkboxes = ['trimonsave'];
foreach ($checkboxes as $checkbox) {
$record->{$checkbox} = (isset($record->{$checkbox})) ? 1 : 0;
}

// 4. Other.
}
Expand Down Expand Up @@ -360,9 +363,9 @@ public static function get_plugin_schema() {
<xs:element name="hideinstructions" type="xs:int"/>
<xs:element name="variable" type="xs:string"/>
<xs:element name="extranote" type="xs:string" minOccurs="0"/>
<xs:element name="trimonsave" type="xs:int"/>
<xs:element name="defaultvalue" type="xs:string" minOccurs="0"/>
<xs:element name="trimonsave" type="xs:int"/>
<xs:element name="pattern" type="xs:string"/>
<xs:element name="minlength" type="xs:int" minOccurs="0"/>
<xs:element name="maxlength" type="xs:int" minOccurs="0"/>
Expand Down
6 changes: 6 additions & 0 deletions field/character/classes/itemsetupform.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public function definition() {
$mform->addHelpButton($fieldname, $fieldname, 'surveyprofield_character');
$mform->setType($fieldname, PARAM_RAW);

// Item: trimonsave.
$fieldname = 'trimonsave';
$mform->addElement('checkbox', $fieldname, get_string($fieldname, 'surveyprofield_character'));
$mform->addHelpButton($fieldname, $fieldname, 'surveyprofield_character');
$mform->setType($fieldname, PARAM_INT);

// Here I open a new fieldset.
$fieldname = 'validation';
$mform->addElement('header', $fieldname, get_string($fieldname, 'mod_surveypro'));
Expand Down
2 changes: 1 addition & 1 deletion field/character/db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
<FIELD NAME="hideinstructions" TYPE="int" LENGTH="4" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="variable" TYPE="char" LENGTH="64" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="extranote" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="trimonsave" TYPE="int" LENGTH="4" NOTNULL="false" SEQUENCE="false"/>
<!-- end of fields belonging to itembaseform.php -->

<!-- begin of fields belonging to itemsetupform.php of this specific plugin -->
<FIELD NAME="defaultvalue" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="trimonsave" TYPE="int" LENGTH="4" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="pattern" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="minlength" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="maxlength" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
Expand Down
33 changes: 33 additions & 0 deletions field/character/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,38 @@ function xmldb_surveyprofield_character_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2016062401, 'surveyprofield', 'character');
}

if ($oldversion < 2024020700) {
// Reorder the field if the table.

// Define field nexttrimonsave to be added to surveyprofield_character.
$table = new xmldb_table('surveyprofield_character');
$oldfield = new xmldb_field('trimonsave');
$newfield = new xmldb_field('nexttrimonsave', XMLDB_TYPE_INTEGER, '4', null, null, null, null, 'defaultvalue');

// Step 1.
// Conditionally launch add field nexttrimonsave.
if (!$dbman->field_exists($table, $newfield)) {
$dbman->add_field($table, $newfield);
}

// Step 2.
// Copy whatever you find in old trimonsave field to new nexttrimonsave field.
$sql = 'UPDATE {surveyprofield_character} SET nexttrimonsave = trimonsave WHERE id = id';
$DB->execute($sql);

// Step 3.
// Conditionally launch drop old field trimonsave.
if ($dbman->field_exists($table, $oldfield)) {
$dbman->drop_field($table, $oldfield);
}

// Step 4.
// Launch rename field nexttrimonsave to trimonsave.
$dbman->rename_field($table, $newfield, 'trimonsave');

// Character savepoint reached.
upgrade_plugin_savepoint(true, 2024020700, 'surveyprofield', 'character');
}

return true;
}
8 changes: 5 additions & 3 deletions field/character/lang/en/surveyprofield_character.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

$string['custompattern'] = 'custom pattern';
$string['regex'] = 'regular expression';
$string['defaultvalue_help'] = 'This is the value the remote user will find answered by default';
$string['defaultvalue'] = 'Default';
$string['free'] = 'free pattern';
Expand All @@ -48,6 +47,8 @@
$string['pattern_help'] = 'If the answer is supposed to fit a specific pattern, define it here using <ul><li>"A" for upper case characters;</li><li>"a" for lower case characters;</li><li>"0" for numbers;</li><li>"*" for to include upper case, lower case, numbers or any other character like, for instance: ,_%."$!\' or spaces.</li></ul>';
$string['pattern'] = 'Text pattern';
$string['pluginname'] = 'Short text';
$string['privacy:metadata'] = 'The "Character" field plugin does not store any personal data.';
$string['regex'] = 'regular expression';
$string['restrictions_custom'] = 'Text is supposed to match the following pattern: "{$a}"';
$string['restrictions_email'] = 'Email is expected here';
$string['restrictions_exact'] = 'Text is supposed to be exactly {$a} characters long';
Expand All @@ -56,13 +57,14 @@
$string['restrictions_minmax'] = 'Text length is supposed to range between {$a->minlength} and {$a->maxlength} characters';
$string['restrictions_regex'] = 'Text is supposed to match the following regular expression: "{$a}"';
$string['restrictions_url'] = 'URL is expected here';
$string['trimonsave_help'] = 'Delete trailing spaces at the beginning and at the end of the user input.';
$string['trimonsave'] = 'Clean answer at save time';
$string['uerr_invalidemail'] = 'Text is not a valid email';
$string['uerr_invalidurl'] = 'Text is not a valid URL';
$string['uerr_invalidregex'] = 'Regular expression \'{$a}\' is not valid.';
$string['uerr_invalidurl'] = 'Text is not a valid URL';
$string['uerr_nopatternmatch'] = 'Text does not match the required pattern';
$string['uerr_noregexmatch'] = 'Text does not match the required regular expression';
$string['uerr_texttoolong'] = 'Text is too long';
$string['uerr_texttooshort'] = 'Text is too short';
$string['url'] = 'web page URL';
$string['userfriendlypluginname'] = 'Text (short)';
$string['privacy:metadata'] = 'The "Character" field plugin does not store any personal data.';
12 changes: 7 additions & 5 deletions field/character/lang/es_mx/surveyprofield_character.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
defined('MOODLE_INTERNAL') || die();

$string['custompattern'] = 'personalizado';
$string['defaultvalue'] = 'Valor por defecto';
$string['defaultvalue_help'] = 'Este es el valor que el usuario remoto encontrará contestado por defecto';
$string['defaultvalue'] = 'Valor por defecto';
$string['free'] = 'patrón libre';
$string['ierr_defaultbadlength'] = 'El valor por defecto no es de {$a} caracteres de longitud porque está declarado implícitamente en el patrón';
$string['ierr_defaultisnotemail'] = 'El valor por defecto no coincide con el patrón del Email';
Expand All @@ -39,15 +39,15 @@
$string['ierr_patternisempty'] = 'falta el patrón';
$string['ierr_toolongdefault'] = 'El valor por defecto debe de ser menor o igual a la longitud máxima permitida';
$string['ierr_tooshortdefault'] = 'El valor por defecto debe de ser más largo o igual a la longitud mínima permitida';
$string['length'] = 'Ancho del campo en caracteres';
$string['length_help'] = 'El ancho del campo en caracteres';
$string['length'] = 'Ancho del campo en caracteres';
$string['mail'] = 'dirección Email';
$string['maxlength'] = 'Longitud máxima (en caracteres)';
$string['maxlength_help'] = 'El número máximo de caracteres permitidos para la contestación a esta pregunta';
$string['minlength'] = 'Longitud mínima (en caracteres)';
$string['maxlength'] = 'Longitud máxima (en caracteres)';
$string['minlength_help'] = 'El número mínimo de caracteres permitidos para la contestación a esta pregunta';
$string['pattern'] = 'Patrón de texto';
$string['minlength'] = 'Longitud mínima (en caracteres)';
$string['pattern_help'] = 'Si se supone que la contestación ajuste a un patrón específico, defínala aquí usando <ul><li>"A" para caracteres en MAYÚSCULAS; </li><li>"a" para caracteres en minúsculas; </li><li>"0" para números; </li><li>"*" para incluir MAYÚSCULAS, minúsculas, números y algun otro caracter como por ejemplo: ,_%."$!\' o espacios.</li></ul>';
$string['pattern'] = 'Patrón de texto';
$string['pluginname'] = 'Texto corto';
$string['restrictions_custom'] = 'El texto se supone que coincide con el siguiente patrón: "{$a}"';
$string['restrictions_email'] = 'Aquí se espera un Email';
Expand All @@ -56,6 +56,8 @@
$string['restrictions_min'] = 'La respuesta se supone que es más larga o igual a {$a} caracteres';
$string['restrictions_minmax'] = 'El rango de la longitud del texto se supone que esté entre {$a->minlength} y {$a->maxlength} caracteres';
$string['restrictions_url'] = 'Aquí se espera una URL';
$string['trimonsave_help'] = 'Eliminar espacios sobrantes al principio y final de la entrada del usuario.';
$string['trimonsave'] = 'Contestación limpia al momento de guardar';
$string['uerr_invalidemail'] = 'El texto no es un Email válido';
$string['uerr_invalidurl'] = 'El texto no es una URL válida';
$string['uerr_nopatternmatch'] = 'El texto no coincide con el patrón requerido';
Expand Down
8 changes: 4 additions & 4 deletions field/character/tests/behat/trim.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Feature: Test the use of character trim
And I set the following fields to these values:
| Content | This is a standard text |
| Required | 1 |
| Clean answer at save time | 0 |
| Additional note | This will not be trimmed |
| Clean answer at save time | 0 |
| pattern | free pattern |
| Minimum length (in characters) | 20 |
| Maximum length (in characters) | 30 |
Expand All @@ -45,8 +45,8 @@ Feature: Test the use of character trim
And I set the following fields to these values:
| Content | Text to trim |
| Required | 1 |
| Clean answer at save time | 1 |
| Additional note | This will be trimmed |
| Clean answer at save time | 1 |
| pattern | free pattern |
| Minimum length (in characters) | 20 |
| Maximum length (in characters) | 30 |
Expand All @@ -64,7 +64,7 @@ Feature: Test the use of character trim

Then I should see "Text is too short"
And I set the field "This is a standard text" to ""
And I set the field "Text to trim" to " text correctly stretched "
And I set the field "Text to trim" to " text correctly trimmed "
And I press "Submit"

Then I should see "Required"
Expand All @@ -75,4 +75,4 @@ Feature: Test the use of character trim
And I press "Continue to responses list"
And I follow "view_submission_row_1"
Then the field "id_surveypro_field_character_1" matches value " false long text "
Then the field "id_surveypro_field_character_2" matches value "text correctly stretched"
Then the field "id_surveypro_field_character_2" matches value "text correctly trimmed"
2 changes: 1 addition & 1 deletion field/character/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2017112201;
$plugin->version = 2024020700;
$plugin->release = '1.0';
$plugin->requires = 2015111600; // Requires this Moodle version.
$plugin->component = 'surveyprofield_character'; // Full name of the plugin (used for diagnostics).
5 changes: 2 additions & 3 deletions field/checkbox/classes/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function __construct($cm, $surveypro, $itemid, $getparentcontent) {
// No properties here.

// List of fields I do not want to have in the item definition form.
$this->insetupform['trimonsave'] = false;
// Empty list.

if (!empty($itemid)) {
$this->item_load($itemid, $getparentcontent);
Expand Down Expand Up @@ -261,7 +261,7 @@ public function item_custom_fields_to_db($record) {
// Nothing to do: no need to overwrite variables.

// 3. Set values corresponding to checkboxes.
// Take care: 'required', 'trimonsave', 'hideinstructions' were already considered in get_common_settings.
// Take care: 'required', 'hideinstructions' were already considered in get_common_settings.
$checkboxes = ['noanswerdefault'];
foreach ($checkboxes as $checkbox) {
$record->{$checkbox} = (isset($record->{$checkbox})) ? 1 : 0;
Expand Down Expand Up @@ -389,7 +389,6 @@ public static function get_plugin_schema() {
<xs:element name="hideinstructions" type="xs:int"/>
<xs:element name="variable" type="xs:string"/>
<xs:element name="extranote" type="xs:string" minOccurs="0"/>
<!-- <xs:element name="trimonsave" type="xs:int"/> -->
<xs:element name="options" type="xs:string"/>
<xs:element name="labelother" type="xs:string" minOccurs="0"/>
Expand Down
Loading

0 comments on commit f5414dd

Please sign in to comment.