Commit 6f2f9f8f authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic

Bug 1813987: saving accessibility option in view

- the accessibility value was not being saved
when creating a new page
- force 12 columns width for blocks when displaying
a page with accessible layout

behatnotneeded

Change-Id: Ide27bac7e471935e9625ce5caa821dca533ae672
parent 0e7ce5c1
......@@ -1438,7 +1438,7 @@ function xmldb_core_upgrade($oldversion=0) {
if ($oldversion < 2019080802) {
log_debug('Adding accessible column to view table');
$table = new XMLDBTable('view');
$field = new XMLDBField('accessible');
$field = new XMLDBField('accessibleview');
if (!field_exists($table, $field)) {
$field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
add_field($table, $field);
......
......@@ -65,7 +65,7 @@ class View {
private $instructionscollapsed=0;
private $newlayout = 1;
private $grid;
private $accessible = 0;
private $accessibleview = 0;
const UNSUBMITTED = 0;
const SUBMITTED = 1;
......@@ -1812,7 +1812,7 @@ class View {
$smarty = smarty_core();
$smarty->assign('blocktypes', $blocktypes);
$smarty->assign('javascript', $javascript);
$smarty->assign('accessible', $this->get('accessible'));
$smarty->assign('accessible', $this->get('accessibleview'));
return $smarty->fetch('view/blocktypelist.tpl');
}
......
......@@ -153,7 +153,7 @@ $javascript = array('views', 'tinymce', 'paginator', 'js/jquery/jquery-ui/js/jqu
'js/gridstack/gridstack.jQueryUI.js',
'js/gridlayout.js',
);
if ($view->get('accessible')) {
if ($view->get('accessibleview')) {
$javascript[] = 'js/dragondrop/dragon-drop.js';
$javascript[] = 'js/accessibilityreorder.js';
}
......@@ -206,7 +206,7 @@ if (!$view->uses_new_layout()) {
$blocks = $view->get_blocks(true);
$blocksencode = json_encode($blocks);
if ( $view->get('accessible')) {
if ( $view->get('accessibleview')) {
$mincolumns = '12';
$reorder = ' accessibilityReorder();';
}
......@@ -277,12 +277,12 @@ $placeholderblock = PluginBlockType::get_blocktypes_for_category('shortcut', $vi
$placeholderbutton = '';
if ($placeholderblock) {
// it's active so make the button with different display title
$placeholderblock[0]['title'] = $view->get('accessible') ? get_string('addnewblockaccessibility', 'view') : get_string('addnewblock', 'view');
$placeholderblock[0]['title'] = $view->get('accessibleview') ? get_string('addnewblockaccessibility', 'view') : get_string('addnewblock', 'view');
$placeholderblock[0]['cssicon'] = 'plus';
$smarty = smarty_core();
$smarty->assign('blocktypes', $placeholderblock);
$smarty->assign('javascript', false);
$smarty->assign('accessible', $view->get('accessible'));
$smarty->assign('accessible', $view->get('accessibleview'));
$placeholderbutton = $smarty->fetch('view/blocktypelist.tpl');
}
$strings = array(
......@@ -292,7 +292,7 @@ $strings = array(
),
);
if ($view->get('accessible')) {
if ($view->get('accessibleview')) {
$strings['view'][] = 'itemgrabbed';
$strings['view'][] = 'itemdropped';
$strings['view'][] = 'itemreorder';
......@@ -369,5 +369,5 @@ $smarty->assign('instructionscollapsed', $view->get('instructionscollapsed'));
$returnto = $view->get_return_to_url_and_title();
$smarty->assign('url', $returnto['url']);
$smarty->assign('title', $returnto['title']);
$smarty->assign('accessible', $view->get('accessible'));
$smarty->assign('accessible', $view->get('accessibleview'));
$smarty->display('view/blocks.tpl');
......@@ -291,7 +291,7 @@ function get_basic_elements() {
);
}
$viewhasblocks = count_records('block_instance', 'view', $view->get('id'));
$accessibleviewdisabled = $viewhasblocks && !$view->get('accessible');
$accessibleviewdisabled = $viewhasblocks && !$view->get('accessibleview');
if (!($group || $institution) && $USER->get_account_preference('accessibilityprofile')) {
$elements['accessibleview'] = array(
'type' => 'switchbox',
......@@ -839,7 +839,7 @@ function set_view_title_and_description(Pieform $form, $values) {
$view->set('anonymise', (int)$values['anonymise']);
}
if (isset($values['accessibleview'])) {
$view->set('accessible', (int)$values['accessibleview']);
$view->set('accessibleview', (int)$values['accessibleview']);
}
}
......
......@@ -362,6 +362,11 @@ if (!$USER->has_peer_role_only($view) || $view->has_peer_assessement_block()
$blockresizeonload = "true";
}
$mincolumns = 'null';
if ( $view->get('accessibleview')) {
$mincolumns = '12';
}
$blocks = $view->get_blocks();
$blocks = json_encode($blocks);
$blocksjs = <<<EOF
......@@ -370,6 +375,7 @@ $(function () {
verticalMargin: 10,
disableDrag : true,
disableResize: true,
minCellColumns: {$mincolumns},
};
var grid = $('.grid-stack');
grid.gridstack(options);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment