Commit 3ef35932 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1784778: hide other blocks from a peer

hide all blocks in a view when accessing as peer role
but the view doesn't have a peer assessment block

behatnotneeded

Change-Id: I4e4c1d7d485db10b95a5188b95c6d9c33d06d464
parent b6ea8510
......@@ -46,3 +46,4 @@ $string['feedbacknotificationtext'] = "%s add a peer assessment on %s
To see this peer assessment online, follow this link:
%s";
$string['typeassessmentfeedback'] = 'Peer assessment';
$string['nopeerassessmentrequired'] = 'You cannot see the content on this page because it does not require a peer assessment.';
......@@ -1304,6 +1304,17 @@ class User {
}
return false;
}
/**
* Function to check if the user has access role as peer only
*
* @param $v View object to check the access to
*/
public function has_peer_role_only($v) {
$user_roles = get_column('view_access', 'role', 'usr', $this->get('id'), 'view', $v->get('id'));
return (!empty($user_roles) && count($user_roles) == 1 && $user_roles[0] == 'peer');
}
/**
* Function to check current user can edit collection
*
......
......@@ -6979,6 +6979,14 @@ class View {
public function is_site_template() {
return ($this->get('template') == View::SITE_TEMPLATE);
}
/**
* Returns true if the view contains at least one peer assessment block
* @return boolean
*/
public function has_peer_assessement_block() {
return get_records_select_assoc('block_instance', 'blocktype = ? AND view = ?', array('peerassessment', $this->get('id')));
}
}
class ViewSubmissionException extends UserException {
......
......@@ -153,7 +153,14 @@
<div id="view" class="view-container">
<div id="bottom-pane">
<div id="column-container" class="user-page-content">
{$viewcontent|safe}
{if $viewcontent}
{$viewcontent|safe}
{else}
<div class="alert alert-info">
<span class="icon icon-lg icon-info-circle left" role="presentation" aria-hidden="true"></span>
{str tag=nopeerassessmentrequired section=artefact.peerassessment}
</div>
{/if}
</div>
</div>
<div class="viewfooter view-container">
......
......@@ -288,7 +288,11 @@ if ($owner && $owner == $USER->get('id')) {
}
}
$viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
// Don't show page content to a user with peer role
// if the view doesn't have a peer assessment block
if (!$USER->has_peer_role_only($view) || $view->has_peer_assessement_block()) {
$viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
}
$smarty = smarty(
$javascript,
......@@ -448,7 +452,7 @@ if ($showmnetlink) {
}
$smarty->assign('viewdescription', ArtefactTypeFolder::append_view_url($view->get('description'), $view->get('id')));
$smarty->assign('viewcontent', $viewcontent);
$smarty->assign('viewcontent', (isset($viewcontent) ? $viewcontent : null));
$smarty->assign('releaseform', $releaseform);
if (isset($addfeedbackform)) {
$smarty->assign('enablecomments', 1);
......
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