Skip to content

Commit

Permalink
add orientation parsons block option
Browse files Browse the repository at this point in the history
  • Loading branch information
smmercuri committed Nov 13, 2023
1 parent 5a52a53 commit 8a555d8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions stack/cas/castext2/blocks/parsons.block.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public function compile($format, $options): ? MP_Node {
if (isset($xpars['overridejs'])) {
unset($xpars['overridejs']);
}
if (isset($xpars['orientation'])) {
unset($xpars['orientation']);
}

// Set default width and height here, we want to push forward to overwrite the iframe defaults
// if they are not provided in the block parameters
Expand Down Expand Up @@ -118,11 +121,14 @@ public function compile($format, $options): ? MP_Node {
}
}

// Add container divs for the proof lists to be accessed by sortable.
// Add correctly oriented container divs for the proof lists to be accessed by sortable.
$orientation = isset($this->params['orientation']) ? $this->params['orientation'] : 'horizontal';
$outer = $orientation === 'horizontal' ? 'row' : 'col';
$inner = $orientation === 'horizontal' ? 'col' : 'row';
$r->items[] = new MP_String('<div class="container" style="' . $astyle . '">
<div class="row">
<ul class="list-group col" id="usedList"></ul>
<ul class="list-group col" id="availableList"></ul>
<div class="' . $outer . '">
<ul class="list-group ' . $inner . '" id="usedList"></ul>
<ul class="list-group ' . $inner . '" id="availableList"></ul>
</div>
</div>');

Expand Down Expand Up @@ -284,11 +290,11 @@ public function validate (
$valids = null;
foreach ($this->params as $key => $value) {
if ($key !== 'width' && $key !== 'height' && $key !== 'aspect-ratio' &&
$key !== 'version' && $key !== 'overridecss' && $key !== 'input') {
$key !== 'version' && $key !== 'overridecss' && $key !== 'input' && $key !== 'orientation') {
$err[] = "Unknown parameter '$key' for Parson's block.";
$valid = false;
if ($valids === null) {
$valids = ['width', 'height', 'aspect-ratio', 'version', 'overridecss', 'overridejs', 'input'];
$valids = ['width', 'height', 'aspect-ratio', 'version', 'overridecss', 'overridejs', 'input', 'orientation'];
$err[] = stack_string('stackBlock_parsons_param', [
'param' => implode(', ', $valids)]);
}
Expand Down

0 comments on commit 8a555d8

Please sign in to comment.