Commit 12ac3f85 authored by Aaron Wells's avatar Aaron Wells Committed by Gerrit Code Review
Browse files

Merge "Bug 1681952: Display members not currently submitting anything to group"

parents 43883e90 8489a483
......@@ -68,6 +68,8 @@ class PluginBlocktypeGroupViews extends MaharaCoreBlocktype {
'count' => $items['count'],
'limit' => $items['limit'],
'offset' => $items['offset'],
'jumplinks' => (!empty($pagination['jumplinks']) ? $pagination['jumplinks'] : 0),
'numbersincludeprevnext' => (!empty($pagination['numbersincludeprevnext']) ? $pagination['numbersincludeprevnext'] : 1),
'numbersincludefirstlast' => false,
'resultcounttextsingular' => $pagination['resultcounttextsingular'] ? $pagination['resultcounttextsingular'] : get_string('result'),
'resultcounttextplural' => $pagination['resultcounttextplural'] ? $pagination['resultcounttextplural'] :get_string('results'),
......@@ -78,6 +80,8 @@ class PluginBlocktypeGroupViews extends MaharaCoreBlocktype {
}
public static function render_instance(BlockInstance $instance, $editing=false) {
global $USER;
$configdata = $instance->get('configdata');
if (!isset($configdata['showgroupviews'])) {
// If not set, use default
......@@ -164,6 +168,22 @@ class PluginBlocktypeGroupViews extends MaharaCoreBlocktype {
if (!$editing && isset($data['group_view_submission_form'])) {
$dwoo->assign('group_view_submission_form', $data['group_view_submission_form']);
}
// Get members who have no submitted work - only show to those allowed to see submitted work
if (!empty($configdata['showsubmitted']) && group_user_can_assess_submitted_views($groupid, $USER->get('id')) && isset($data['nosubmissions'])) {
$nosubmissions = $data['nosubmissions'];
$pagination = array(
'baseurl' => $baseurl,
'id' => 'nosubmissions_pagination',
'datatable' => 'nosubmissionslist',
'jsonscript' => 'blocktype/groupviews/nosubmissions.json.php',
'jumplinks' => 6,
'numbersincludeprevnext' => 3,
'resultcounttextsingular' => get_string('member', 'group'),
'resultcounttextplural' => get_string('members', 'group'),
);
self::render_items($nosubmissions, 'blocktype:groupviews:nosubmissions.tpl', $configdata, $pagination);
$dwoo->assign('nosubmissions', $nosubmissions);
}
return $dwoo->fetch('blocktype:groupviews:groupviews.tpl');
}
......@@ -373,6 +393,16 @@ class PluginBlocktypeGroupViews extends MaharaCoreBlocktype {
'limit' => $limit,
'offset' => 0,
);
// Display a list of members who are yet to submit views to the group
$nosubmissions = self::find_members_without_submissions($group->id);
$data['nosubmissions'] = array(
'data' => array_slice($nosubmissions, 0, $limit),
'count' => count($nosubmissions),
'limit' => $limit,
'offset' => 0,
);
}
}
......@@ -396,6 +426,32 @@ class PluginBlocktypeGroupViews extends MaharaCoreBlocktype {
return $data;
}
/**
* Return list of members that have not submitted any pages/collections to the group
*
* @param integer $groupid The group to check
*
* @return array $members
*/
public static function find_members_without_submissions($groupid) {
if ($nosubmissions = get_records_sql_array("SELECT u.id FROM {usr} u JOIN {group_member} gm ON gm.member = u.id
WHERE gm.group = ? AND u.deleted = 0 AND gm.member NOT IN (
SELECT DISTINCT m.member FROM {group} g
JOIN {group_member} m ON m.group = g.id
JOIN {view} v ON v.owner = m.member
WHERE g.id = ?
AND g.submittableto = 1
AND v.submittedgroup = g.id
) ORDER BY u.lastname, u.firstname", array($groupid, $groupid))) {
foreach ($nosubmissions as $member) {
$member->displayname = display_name($member->id);
$member->url = profile_url($member->id);
}
return $nosubmissions;
}
return array();
}
public static function get_instance_title() {
return get_string('title', 'blocktype.groupviews');
}
......
<?php
/**
*
* @package mahara
* @subpackage blocktype/groupviews
* @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.
*
*/
/**
* returns all members without submissions to a given group id
*/
define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
safe_require('blocktype', 'groupviews');
require_once(get_config('libroot') . 'view.php');
require_once(get_config('libroot') . 'group.php');
$offset = param_integer('offset', 0);
$groupid = param_integer('group');
$editing = param_boolean('editing', false);
$group_homepage_view = group_get_homepage_view($groupid);
$bi = group_get_homepage_view_groupview_block($groupid);
if (!can_view_view($group_homepage_view)
|| !group_user_can_assess_submitted_views($groupid, $USER->get('id'))) {
json_reply(true, get_string('accessdenied', 'error'));
}
$configdata = $bi->get('configdata');
if (!isset($configdata['showsubmitted'])) {
$configdata['showsubmitted'] = 1;
}
$limit = isset($configdata['count']) ? intval($configdata['count']) : 5;
$limit = ($limit > 0) ? $limit : 5;
if (empty($configdata['showsubmitted'])) {
$nosubmissions = array(
'data' => array(),
'count' => 0,
'limit' => $limit,
'offset' => 0
);
}
else {
$nosubmissions = PluginBlocktypeGroupViews::find_members_without_submissions($groupid);
$nosubmissions = array(
'data' => array_slice($nosubmissions, $offset, $limit),
'count' => count($nosubmissions),
'limit' => $limit,
'offset' => $offset,
);
$baseurl = $group_homepage_view->get_url();
$baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'group=' . $groupid . '&editing=' . $editing;
$pagination = array(
'baseurl' => $baseurl,
'id' => 'nosubmissions_pagination',
'datatable' => 'nosubmissionslist',
'jsonscript' => 'blocktype/groupviews/nosubmissions.json.php',
'jumplinks' => 6,
'numbersincludeprevnext' => 3,
'resultcounttextsingular' => get_string('member', 'group'),
'resultcounttextplural' => get_string('members', 'group'),
);
PluginBlocktypeGroupViews::render_items($nosubmissions, 'blocktype:groupviews:nosubmissions.tpl', $configdata, $pagination);
}
json_reply(false, array('data' => $nosubmissions));
......@@ -105,6 +105,7 @@ $string['nosharedviewsyet'] = 'There are no pages shared with this group yet';
$string['viewssharedtogroupbyothers'] = 'Pages shared with this group by others';
$string['submissionstogroup'] = 'Submissions to this group';
$string['nosubmittedviewscollectionsyet'] = 'There are no pages or collections submitted to this group yet';
$string['nosubmissionsfrom'] = 'Members without a submission to the group';
$string['submittogroup'] = 'Submit a page or collection to this group';
$string['yoursubmissions'] = 'You have submitted';
$string['youhavesubmitted'] = 'You have submitted <a href="%s">%s</a> to this group';
......
......@@ -1487,20 +1487,17 @@ function group_view_submission_form($groupid) {
'autofocus' => false,
'successcallback' => 'group_view_submission_form_submit',
'elements' => array(
'text1' => array(
'type' => 'html',
'class' => 'forassessment text-inline text-small',
'value' => get_string('forassessment1', 'view'),
),
'inputgroup' => array(
'type' => 'fieldset',
'class' => 'input-group',
'elements' => array(
'options' => array(
'type' => 'select',
'title' => get_string('forassessment1', 'view'),
'collapseifoneoption' => false,
'optgroups' => $optgroups,
'options' => $options,
'class' => 'forassessment text-inline text-small',
),
'submit' => array(
'type' => 'button',
......
......@@ -118,7 +118,28 @@
{/if}
<hr />
{/if}
{if $nosubmissions}
<h4 class="title list-group-item-heading">
{str tag="nosubmissionsfrom" section="view"}:
</h4>
<ul id="nosubmissionslist" class="list-group grouppages">
{$nosubmissions.tablerows|safe}
</ul>
{if $nosubmissions.pagination}
<div id="nosubmissions_page_container" class="hidden pagination-container">
{$nosubmissions.pagination|safe}
</div>
{/if}
{if $nosubmissions.pagination_js}
<script>
jQuery(function($) {literal}{{/literal}
{$nosubmissions.pagination_js|safe}
$('#nosubmissions_page_container').removeClass('hidden');
{literal}}{/literal});
</script>
{/if}
<hr />
{/if}
{if $mysubmitted || $group_view_submission_form}
<h4 class="title list-group-item-heading">
......
{foreach from=$items item=item}
<li class="list-group-item text-midtone">
<a href="{$item->url}" class="outer-link">
<span class="sr-only">{$item->displayname}</span>
</a>
<h5 class="text-inline">{$item->displayname}</h5>
</li>
{/foreach}
......@@ -487,3 +487,8 @@
.notification-parent .bulk-actions label.btn-default {
padding-bottom: 3px;
}
.forassessment label {
display: inline-block !important;
margin-top: -25px;
}
\ No newline at end of file
@javascript @core @group
Feature: Mahara users submit pages / colelctions to a group
As a mahara user
I need to submit content to the group
As a group admin user
I need to see who has and has not submitted content
Background:
Given the following "users" exist:
| username | password | email | firstname | lastname | institution | authname | role |
| groupAdmin | Kupuhipa1 | grpadmin@example.com | Group | Admin | mahara | internal | admin |
| userA | Kupuhipa1 | test01@example.com | Pete | Mc | mahara | internal | member |
| userB | Kupuhipa1 | test02@example.com | Son | Nguyen | mahara | internal | member |
| userC | Kupuhipa1 | test03@example.com | Jack | Smith | mahara | internal | member |
And the following "groups" exist:
| name | owner | description | grouptype | open | invitefriends | editroles | submittableto | allowarchives | members | staff |
| Group one | groupAdmin | This is group 01 | standard | ON | ON | all | ON | OFF | userA, userB, userC | |
And the following "pages" exist:
| title | description| ownertype | ownername |
| Page userA_01 | This is the page 01 | user | userA |
| Page userA_02 | This is the page 02 | user | userA |
| Page userA_03 | This is the page 03 | user | userA |
| Page userB_01 | This is the page 04 | user | userB |
| Page userB_02 | This is the page 05 | user | userB |
| Page userC_01 | This is the page 06 | user | userC |
| Page userC_02 | This is the page 07 | user | userC |
And the following "collections" exist:
| title | description| ownertype | ownername | pages |
| Collection userA_01 | This is the collection 01 | user | userA | Page userA_01, Page userA_02 |
| Collection userA_02 | This is the collection 02 | user | userA | Page userA_03 |
| Collection userB_01 | This is the collection 03 | user | userB | Page userB_01 |
| Collection userC_01 | This is the collection 05 | user | userC | Page userC_01 |
Scenario: Group users submit content to the group and group admin checks who is still to submit content
# UserA submits a collection to the group
Given I log in as "userA" with password "Kupuhipa1"
And I choose "Find groups" in "Groups" from main menu
When I click on "Group one"
And I scroll to the base of id "groupviewlist"
And I select "Collection userA_01" from "Submit for assessment"
And I press "Submit"
And I press "Yes"
Then I should see "Collection submitted"
And I log out
# UserB submits a page to the group
Given I log in as "userB" with password "Kupuhipa1"
And I choose "Find groups" in "Groups" from main menu
When I click on "Group one"
And I scroll to the base of id "groupviewlist"
And I select "Page userB_02" from "Submit for assessment"
And I press "Submit"
And I press "Yes"
Then I should see "Page submitted"
And I log out
# UserC didn't submit anything so should appear on the need to do submissions list
Given I log in as "groupAdmin" with password "Kupuhipa1"
And I choose "Find groups" in "Groups" from main menu
When I click on "Group one"
And I scroll to the base of id "groupviewlist"
Then I should see "Jack Smith" in the "ul#nosubmissionslist" "css_element"
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