Commit 5cedce1f authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1790543: Display portfolio instructions

1) Add an 'instructions' field to view table via install / update.

2) Add 'Instructions' textarea / wysiwyg field to view settings page and
have it save to the database

3) Move generic "This area shows a preview of what your page looks like.
Changes are saved automatically. Drag blocks onto the page to add them.
You can then also drag them around the page to change their position."
text in edit page to the help icon and in it's place have an expandable
area to display the saved 'instructions' message.

4) On view display page have an expandable area to display the saved
'instructions' message

5) in view edit mode, collapsing/uncollapsing the Instruction section
is remebered automatically for next time the view is edited

behatnotneeded

Change-Id: Ia56323b9b734b8ebe9498c54dce5a3b934d1fd29
parent a3292f76
......@@ -39,6 +39,12 @@ if ($viewid && $fileid) {
$artefactok = EmbeddedImage::can_see_embedded_image($fileid, 'description', $resourceid);
}
// Check if the artefact is embedded in the page instructions
$resourceid = param_integer('instructions', null);
if ($resourceid && $file instanceof ArtefactTypeImage) {
$artefactok = EmbeddedImage::can_see_embedded_image($fileid, 'instructions', $resourceid);
}
if (!$artefactok && artefact_in_view($file, $viewid)) {
$artefactok = true;
}
......
......@@ -1383,6 +1383,15 @@
* changes the intructions so they are for ajax
*/
$('#blocksinstruction').html(strings['blocksinstructionajaxlive']);
$('#viewinstructions-dropdown').on('hide.bs.collapse show.bs.collapse', function(event) {
var pd = {
'viewid': $('#viewid').val(),
'action': event.type
};
sendjsonrequest(config['wwwroot'] + 'view/instructions.json.php',
pd, 'POST', function() {}
);
});
});
}( window.ViewManager = window.ViewManager || {}, jQuery ));
......
<!-- @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later -->
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Edit page</h3>
<p>This area shows a preview of what your page looks like. Changes are saved automatically. Drag blocks onto the page to add them. You can then also drag them around the page to change their position.</p>
<p>Designing your page layout enables you to personalise the way in which your resources and information can be displayed. For example if you wish to display only one of your journal entries, click on the "Journals" tab, then drag the "Journal entry" block into your page area.</p>
<p>As you build up the content in your page, you can check on how it will look by clicking on "Display page". Click the "Edit" button to continue editing.</p>
......@@ -514,4 +514,6 @@ $string['addcontent'] = 'Add Content';
$string['theme'] = 'Theme';
$string['lockblocks'] = "Lock blocks";
$string['lockblocksdescription'] = "You can lock the blocks on the page and prevent that they are removed when people copy the page.";
\ No newline at end of file
$string['lockblocksdescription'] = "You can lock the blocks on the page and prevent that they are removed when people copy the page.";
$string['instructions'] = 'Instructions';
$string['advanced'] = 'Advanced';
......@@ -788,6 +788,8 @@
<FIELD NAME="urlid" TYPE="char" LENGTH="100" NOTNULL="false" />
<FIELD NAME="anonymise" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="lockblocks" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="instructions" TYPE="text" NOTNULL="false" />
<FIELD NAME="instructionscollapsed" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
......
......@@ -1075,5 +1075,17 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
if ($oldversion < 2018090400) {
log_debug('Add instuctions column in view table');
$table = new XMLDBTable('view');
$field = new XMLDBField('instructions');
$field->setAttributes(XMLDB_TYPE_TEXT);
add_field($table, $field);
$field = new XMLDBField('instructionscollapsed');
$field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
add_field($table, $field);
}
return $status;
}
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/wiki/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2018081700;
$config->version = 2018090400;
$config->series = '18.10';
$config->release = '18.10dev';
$config->minupgradefrom = 2017031605;
......
......@@ -63,6 +63,8 @@ class View {
private $skin;
private $anonymise = 0;
private $lockblocks = 0;
private $instructions;
private $instructionscollapsed=0;
const UNSUBMITTED = 0;
const SUBMITTED = 1;
......@@ -1008,6 +1010,7 @@ class View {
}
require_once('embeddedimage.php');
EmbeddedImage::delete_embedded_images('description', $this->id);
EmbeddedImage::delete_embedded_images('instructions', $this->id);
$this->deleted = true;
db_commit();
}
......@@ -3230,6 +3233,7 @@ class View {
'tags' => $this->get('tags'),
'numrows' => $this->get('numrows'),
'ownerformat' => $this->get('ownerformat'),
'instructions' => $this->get('instructions'),
);
// Export view content
......@@ -3266,9 +3270,9 @@ class View {
if (!$aids = get_column_sql("
SELECT fileid
FROM {artefact_file_embedded}
WHERE resourcetype = ?
WHERE resourcetype IN (?,?)
AND resourceid IN (" . join(',', array_map('intval', $viewids)) . ')'
, array('description'))) {
, array('description', 'instructions'))) {
return array();
}
return $aids;
......@@ -3294,6 +3298,7 @@ class View {
'tags' => $config['tags'],
'numrows' => $config['numrows'],
'ownerformat' => $config['ownerformat'],
'instructions' => $config['instructions'],
);
if (isset($config['owner'])) {
$viewdata['owner'] = $config['owner'];
......
......@@ -624,6 +624,12 @@ div.toolbarhtml {
}
}
.view-instructions.with-toolbar {
margin-right: 20px;
#viewinstructions,
.peerinstructions {
&.with-toolbar {
margin-right: 20px;
}
div.fieldset-body {
background-color: $gray-lighter !important;
}
}
{include file="header.tpl"}
{include file="view/editviewtabs.tpl" selected='content' issiteview=$issiteview}
<div id="blocksinstruction" class="lead view-description">
{if $instructions}
<div id="viewinstructions" class="last form-group collapsible-group small-group">
<fieldset class="pieform-fieldset collapsible collapsible-small">
<legend>
<h4>
<a href="#viewinstructions-dropdown" data-toggle="collapse" aria-expanded="false" aria-controls="viewinstructions-dropdown" class="{if $instructionscollapsed}collapsed{/if}">
{str tag='instructions' section='view'}
<span class="icon icon-chevron-down collapse-indicator right pull-right"></span>
</a>
</h4>
</legend>
<div class="fieldset-body collapse viewinstructions {if !$instructionscollapsed} in {/if}" id="viewinstructions-dropdown">
{$instructions|clean_html|safe}
</div>
</fieldset>
</div>
{else}
<div id="blocksinstruction" class="lead view-description">
{str tag='blocksintructionnoajax' section='view'}
</div>
</div>
{/if}
<div class="row view-container" selected='content' data-target="col-collapse">
......
......@@ -150,6 +150,24 @@
{$viewdescription|clean_html|safe}
</div>
{if $viewinstructions}
<div id="viewinstructions" class="pageinstructions view-instructions last form-group collapsible-group small-group {if $toolbarhtml}with-toolbar{/if}">
<fieldset class="pieform-fieldset collapsible collapsible-small">
<legend>
<h4>
<a href="#viewinstructions-dropdown" data-toggle="collapse" aria-expanded="false" aria-controls="viewinstructions-dropdown" class="collapsed">
{str tag='instructions' section='view'}
<span class="icon icon-chevron-down collapse-indicator right pull-right"></span>
</a>
</h4>
</legend>
<div class="viewinstructions fieldset-body collapse" id="viewinstructions-dropdown">
{$viewinstructions|clean_html|safe}
</div>
</fieldset>
</div>
{/if}
<div id="view" class="view-container">
<div id="bottom-pane">
<div id="column-container" class="user-page-content">
......
......@@ -291,4 +291,6 @@ $smarty->assign('issiteview', isset($institution) && ($institution == 'mahara'))
$smarty->assign('issitetemplate', $view->is_site_template());
$smarty->assign('PAGEHEADING', $state);
$smarty->assign('instructions', $view->get('instructions'));
$smarty->assign('instructionscollapsed', $view->get('instructionscollapsed'));
$smarty->display('view/blocks.tpl');
......@@ -123,7 +123,7 @@ $smarty->assign('issitetemplate', $issitetemplate);
$smarty->assign('PAGEHEADING', $state);
$smarty->display('view/editlayout.tpl');
function create_settings_pieform(){
function create_settings_pieform() {
global $view, $pieformname, $issiteview, $issitetemplate,
$canedittitle, $canuseskins;
$inlinejavascript = '';
......@@ -131,6 +131,7 @@ function create_settings_pieform(){
//get elements for each section of the form
if ($canedittitle) {
$basicelements = get_basic_elements();
$advancedelements = get_advanced_elements();
}
list($layoutelements, $hiddenlayoutelements, $inlinejs) = get_layout_elements();
......@@ -157,6 +158,13 @@ function create_settings_pieform(){
'legend' => get_string('basics', 'view'),
'elements' => $basicelements
);
$formelements['advanced'] = array(
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
'legend' => get_string('advanced', 'view'),
'elements' => $advancedelements
);
}
$formelements['layout'] = array(
......@@ -259,15 +267,6 @@ function get_basic_elements() {
'defaultvalue' => $view->get('title'),
'rules' => array( 'required' => true ),
),
'urlid' => array(
'type' => 'text',
'title' => get_string('viewurl', 'view'),
'prehtml' => '<span class="description">' . (isset($cleanurlbase) ? $cleanurlbase : '') . '</span> ',
'description' => get_string('viewurldescription', 'view') . ' ' . get_string('cleanurlallowedcharacters'),
'defaultvalue' => $view->get('urlid'),
'rules' => array('maxlength' => 100, 'regex' => get_config('cleanurlvalidate')),
'ignore' => !$urlallowed,
),
'description' => array(
'type' => 'wysiwyg',
'title' => get_string('description','view'),
......@@ -318,6 +317,56 @@ function get_basic_elements() {
);
}
}
if (get_config('allowanonymouspages')) {
$elements['anonymise'] = array(
'type' => 'switchbox',
'title' => get_string('anonymise','view'),
'description' => get_string('anonymisedescription','view'),
'defaultvalue' => $view->get('anonymise'),
);
}
return $elements;
}
function get_advanced_elements() {
global $view, $urlallowed, $group, $institution, $USER;
$formatstring = '%s (%s)';
$ownerformatoptions = array(
FORMAT_NAME_FIRSTNAME => sprintf($formatstring, get_string('firstname'), $USER->get('firstname')),
FORMAT_NAME_LASTNAME => sprintf($formatstring, get_string('lastname'), $USER->get('lastname')),
FORMAT_NAME_FIRSTNAMELASTNAME => sprintf($formatstring, get_string('fullname'), full_name())
);
$displayname = display_name($USER);
if ($displayname !== '') {
$ownerformatoptions[FORMAT_NAME_DISPLAYNAME] = sprintf($formatstring, get_string('preferredname'), $displayname);
}
$studentid = (string)get_field('artefact', 'title', 'owner', $USER->get('id'), 'artefacttype', 'studentid');
if ($studentid !== '') {
$ownerformatoptions[FORMAT_NAME_STUDENTID] = sprintf($formatstring, get_string('studentid'), $studentid);
}
$elements = array(
'instructions' => array(
'type' => 'wysiwyg',
'title' => get_string('instructions','view'),
'rows' => 5,
'cols' => 70,
'class' => 'view-description',
'defaultvalue' => $view->get('instructions'),
'rules' => array('maxlength' => 65536),
),
'urlid' => array(
'type' => 'text',
'title' => get_string('viewurl', 'view'),
'prehtml' => '<span class="description">' . (isset($cleanurlbase) ? $cleanurlbase : '') . '</span> ',
'description' => get_string('viewurldescription', 'view') . ' ' . get_string('cleanurlallowedcharacters'),
'defaultvalue' => $view->get('urlid'),
'rules' => array('maxlength' => 100, 'regex' => get_config('cleanurlvalidate')),
'ignore' => !$urlallowed,
),
);
if (!($group || $institution)) {
$default = $view->get('ownerformat');
if (!$default) {
......@@ -332,15 +381,6 @@ function get_basic_elements() {
'rules' => array('required' => true),
);
}
if (get_config('allowanonymouspages')) {
$elements['anonymise'] = array(
'type' => 'switchbox',
'title' => get_string('anonymise','view'),
'description' => get_string('anonymisedescription','view'),
'defaultvalue' => $view->get('anonymise'),
);
}
return $elements;
}
......@@ -596,6 +636,7 @@ function settings_submit(Pieform $form, $values) {
if ($canedittitle) {
set_view_title_and_description($form, $values);
set_view_advanced($form, $values);
}
set_view_layout($form, $values);
......@@ -959,6 +1000,21 @@ function set_view_title_and_description(Pieform $form, $values) {
if (isset($values['anonymise'])) {
$view->set('anonymise', (int)$values['anonymise']);
}
}
function set_view_advanced(Pieform $form, $values) {
global $view, $urlallowed, $new;
if (trim($values['instructions']) !== '') {
require_once('embeddedimage.php');
$view->set('instructions', EmbeddedImage::prepare_embedded_images($values['instructions'], 'instructions', $view->get('id')));
}
else {
$view->set('instructions', '');
}
if (isset($values['ownerformat']) && $view->get('owner')) {
$view->set('ownerformat', $values['ownerformat']);
}
// Change the 'untitled' urlid on first save
if ($new && $urlallowed) {
// Generate one automatically based on the title
......
<?php
/**
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
require_once('view.php');
global $USER;
$view = new View(param_integer('viewid'));
$action = param_alphanumext('action', '');
if (!$USER->can_edit_view($view)) {
json_reply(true, get_string('accessdenied', 'error'));
exit;
}
switch ($action) {
case 'hide':
$view->set('instructionscollapsed', 1);
json_reply(false, array('message' => false, 'data' => 'success'));
break;
case 'show':
$view->set('instructionscollapsed', 0);
json_reply(false, array('message' => false, 'data' => 'success'));
break;
}
json_reply(true, get_string('noviewcontrolaction', 'error', $action));
......@@ -452,6 +452,7 @@ if ($showmnetlink) {
}
$smarty->assign('viewdescription', ArtefactTypeFolder::append_view_url($view->get('description'), $view->get('id')));
$smarty->assign('viewinstructions', ArtefactTypeFolder::append_view_url($view->get('instructions'), $view->get('id')));
$smarty->assign('viewcontent', (isset($viewcontent) ? $viewcontent : null));
$smarty->assign('releaseform', $releaseform);
if (isset($addfeedbackform)) {
......
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