From 5b8836b5bef1a2e1187c6d1c707d629f1c3a5bec Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Mon, 29 Aug 2016 15:54:48 +0200 Subject: [PATCH 1/2] Making select beeing able to be optional --- h5p.classes.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 64c2ab5..a367184 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2852,6 +2852,7 @@ class H5PContentValidator { * @param $semantics */ public function validateSelect(&$select, $semantics) { + $optional = isset($semantics->optional) && $semantics->optional; $strict = FALSE; if (isset($semantics->options) && !empty($semantics->options)) { // We have a strict set of options to choose from. @@ -2871,7 +2872,7 @@ class H5PContentValidator { } foreach ($select as $key => &$value) { - if ($strict && !isset($options[$value])) { + if ($strict && !$optional && !isset($options[$value])) { $this->h5pF->setErrorMessage($this->h5pF->t('Invalid selected option in multi-select.')); unset($select[$key]); } @@ -2887,7 +2888,7 @@ class H5PContentValidator { $select = $select[0]; } - if ($strict && !isset($options[$select])) { + if ($strict && !$optional && !isset($options[$select])) { $this->h5pF->setErrorMessage($this->h5pF->t('Invalid selected option in select.')); $select = $semantics->options[0]->value; } From 5f38e2b7f81039eeede9758691bce80111b96571 Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Wed, 21 Sep 2016 13:22:35 +0200 Subject: [PATCH 2/2] Bumped core because of bugfix for optional selects [HFJ-2183] --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index a367184..0b2d7f8 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1665,7 +1665,7 @@ class H5PCore { public static $coreApi = array( 'majorVersion' => 1, - 'minorVersion' => 8 + 'minorVersion' => 9 ); public static $styles = array( 'styles/h5p.css',