Skip to content

Commit

Permalink
OUBlog: Personal blog interface improvements and usage stats block #8318
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-platts authored and sammarshallou committed Nov 25, 2013
1 parent 51981f8 commit 5fa2e88
Show file tree
Hide file tree
Showing 19 changed files with 1,696 additions and 46 deletions.
6 changes: 6 additions & 0 deletions .sams
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ OPTIONAL_SAMS
<Files feed.php>
OPTIONAL_SAMS
</Files>
<Files stats_update.php>
OPTIONAL_SAMS
</Files>
<Files pluginfile.php>
DISABLE_SAMS
</Files>
<Files *.js>
DISABLE_SAMS
</Files>
32 changes: 30 additions & 2 deletions allposts.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@
$PAGE->set_url($url);

$context = get_context_instance(CONTEXT_MODULE, $cm->id);
oublog_check_view_permissions($oublog, $context, $cm);
if (!empty($CFG->oublogallpostslogin) && $oublog->maxvisibility == OUBLOG_VISIBILITY_PUBLIC) {
// Set blog visibility temporarily to loggedin user to force login to this page.
$oublog->maxvisibility = OUBLOG_VISIBILITY_LOGGEDINUSER;
oublog_check_view_permissions($oublog, $context, $cm);
$oublog->maxvisibility = OUBLOG_VISIBILITY_PUBLIC;
} else {
oublog_check_view_permissions($oublog, $context, $cm);
}

$oublogoutput = $PAGE->get_renderer('mod_oublog');

Expand Down Expand Up @@ -71,7 +78,7 @@

// Get Posts.
list($posts, $recordcount) = oublog_get_posts($oublog, $context, $offset, $cm, null, -1, null,
$tag, $canaudit);
$tag, $canaudit, true);

$PAGE->set_title(format_string($oublog->name));
$PAGE->set_heading(format_string($course->fullname));
Expand Down Expand Up @@ -118,6 +125,24 @@
$PAGE->blocks->add_fake_block($bc, BLOCK_POS_RIGHT);
}

if ($oublog->statblockon) {
// 'Discovery' block.
$stats = array();
$stats[] = oublog_stats_output_visitstats($oublog, $cm, $oublogoutput);
$stats[] = oublog_stats_output_poststats($oublog, $cm, $oublogoutput);
$stats[] = oublog_stats_output_commentstats($oublog, $cm, $oublogoutput);
$stats[] = oublog_stats_output_commentpoststats($oublog, $cm, $oublogoutput, false, true);
$stats = $oublogoutput->render_stats_container('allposts', $stats);
$bc = new block_contents();
$bc->attributes['id'] = 'oublog-discover';
$bc->attributes['class'] = 'oublog-sideblock block';
$bc->title = get_string('discovery', 'oublog', oublog_get_displayname($oublog, true));
$bc->content = $stats;
if (!empty($stats)) {
$PAGE->blocks->add_fake_block($bc, BLOCK_POS_RIGHT);
}
}

if ($feeds = oublog_get_feedblock($oublog, 'all', '', false, $cm)) {
$bc = new block_contents();
$bc->attributes['id'] = 'oublog-feeds';
Expand All @@ -133,6 +158,9 @@

print skip_main_destination();

// Renderer hook so extra info can be added to global blog pages in theme.
echo $oublogoutput->render_viewpage_prepost();

// Print blog posts.
if ($posts) {
echo '<div id="oublog-posts">';
Expand Down
3 changes: 2 additions & 1 deletion backup/moodle2/backup_oublog_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ protected function define_structure() {
$oublog = new backup_nested_element('oublog', array('id'), array('name', 'course',
'accesstoken', 'intro', 'introformat', 'allowcomments', 'individual',
'maxbytes', 'maxattachments', 'maxvisibility', 'global', 'views',
'completionposts', 'completioncomments', 'reportingemail', 'displayname'));
'completionposts', 'completioncomments', 'reportingemail', 'displayname',
'statblockon'));

$instances = new backup_nested_element('instances');

Expand Down
1 change: 1 addition & 0 deletions db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="reportingemail" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Email addresses for reporting posts or comments"/>
<FIELD NAME="displayname" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Alternative name used in some areas of the interface"/>
<FIELD NAME="statblockon" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Show the stat block"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
Expand Down
13 changes: 13 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,18 @@ function xmldb_oublog_upgrade($oldversion=0) {
upgrade_mod_savepoint(true, 2013102800, 'oublog');
}

if ($oldversion < 2013102801) {

// Define field statblockon to be added to oublog.
$table = new xmldb_table('oublog');
$field = new xmldb_field('statblockon', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'displayname');

// Conditionally launch add field statblockon.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2013102801, 'oublog');
}

return true;
}
252 changes: 252 additions & 0 deletions internaldoc/testcase.usagestats.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
This script describes steps to test the OU Blog facility that displays blog usage statistics
from a user perspective. It is intended to cover most of the UI and features.

Note that this feature is intended to display statistics based on blog usage and content,
and as it is only practical to create a small data set in these tests it is recommended
to further test the functionality on a system with real data independently.

NOTE: In this test case, the word 'blog' always refers to the OU blog.

The test steps in this script follow on from each other and aren't independent.


Initial setup
=============

This test case requires:

- Two user accounts (admin & student - admin must have permissions to create/configure activities)
- Both users should have an avatar (user picture) set for their profile
- A test course in which activities can be added, both test users should be enrolled on this course
- Two groups [G1 and G2], both test users should be members of G1. admin should be member of G2 also
- Personal blogs setup on the test system
- Numerous blog activities with various configurations for testing (see CRE)
- Numerous blog, posts and comments for testing (see CRE)

The test server must have debugging set to DEVELOPER level and to display
errors; during all parts of the test script, there should be no debugging
warnings.

CRE Creating blog and data
===========================

CRE01 / admin.

Create a new blog activity 'CRE01' with Intro text "Course-wide blog"
Set Allow comments to 'Comments not allowed'
Set Individual blogs to 'No (blog together on in groups)'
Tick Show blog usage extra statistics checkbox
Ensure group mode is 'No groups'
Save and return to course.

CRE02 / admin.

Create a new blog activity 'CRE02' with Intro text "Group blog"
Set Allow comments to 'Yes, from logged in users'
Set Individual blogs to 'No (blog together on in groups)'
Tick Show blog usage extra statistics checkbox
Set group mode to 'Visible groups'
Save and return to course.

CRE03 / admin.

Create a new blog activity 'CRE03' with Intro text "Individual blog"
Set Allow comments to 'Yes, from logged in users'
Set Individual blogs to 'Visible individual blogs'
Tick Show blog usage extra statistics checkbox
Ensure group mode is 'No groups'
Save and return to course.

CRE04 / admin

Enter blog CRE01
Select 'New blog post' and add a new blog post, setting title to 'Post01'
Add any message text you like and set Allow comments to 'Yes, from logged in users'
Repeat adding another post, this time leaving Title field empty
Select 'Add your comment' against Post01 and add a new comment (no title, any text).

CRE05 / student [change]

Enter blog CRE01
Select 'Add your comment' against Post01 and add a new comment (no title, any text)
Repeat (so you have added two comments to Post01, there are now three in total)
Select 'Add your comment' against the untitled post and add a new comment (no title, any text).

CRE06 / admin

Repeat steps in CRE04 using blog CRE02, ensuring G1 group is selected as the current blog.

CRE07 / admin

In blog CRE02 switch to the G2 group blog
Select 'New blog post' and add a new blog post, setting title to 'Post02'
Add any message text you like and set Allow comments to 'No comments'.

CRE08 / student [change]

Repeat steps in CRE05 using blog CRE02, ensuring G1 group is selected as the current blog.

CRE09 / admin [change]

From course home page select CRE03 blog
Ensure current user is selected on the Visible individual drop-down
Repeat steps in CRE04 using this blog.

CRE10 / student [change]

From course home page select CRE03 blog
Select the admin user from the Visible individual drop-down
Repeat steps in CRE05 using this blog.

CRE10 / student

In CRE03 blog select current user from the Visible individual drop-down
Select 'New blog post' and add a new blog post, setting title to 'Post02'
Add any message text you like and set Allow comments to 'No comments'.


CRS Checking usage 'block' on course-wide blog
==============================================

CRS01 / admin [change]

From the course home page access the CRE01 blog
-- A 'Blog usage' 'block' should show to the right
-- The 'block' should contain only a 'Most commented posts' tab
-- There should be two entries in this tab:
-- Post01 should be at the top, showing 2 comments (post creator comments are not counted)
-- Untitled post should be after this, showing 1 comment
-- The admin user's avatar should be to the left of the entries
-- The post time when created should be displayed below the post title
-- The post title should link to the post
-- The 'bar' for Post01 comments should take the full width available in the block
-- The 'bar' for the other post should be half the available width between label and edge of block.

CRS02 / admin

Still in CRE01 'Blog usage' 'block':
Select + & - link by the current time period filter
-- This should expand/collapse the time filter form
Select Time period 'All time' from drop-down and select Update button
(assuming the current filter is not 'All time', select a different time period in this case)
-- A 'spinner' should be shown against the Update button
-- The time period title should be updated (e.g. to 'All time')
-- The description should be updated (e.g. to 'Posts with the most number of comments')
-- The list of posts with comments should remain the same.
Revisit (refresh) the blog page
-- The previously selected Time period and expand/collapse state should be remembered.

GRP Checking usage 'block' on group blog
========================================

GRP01 / admin

From the course home page access the CRE02 blog
Select the Visible group G1
-- A 'Blog usage' 'block' should show to the right
-- The 'block' should contain 'Most posts', 'Most comments' and 'Most commented posts' tabs
-- You should be able to expand/collapse each tab by selecting its heading (1 open at a time)
-- There should be two entries in the 'Most posts' tab
-- One for each group, with 2 posts for G1's blog above 1 for G2's
-- The default avatar should be to the left of the entries (unless a group picture is set)
-- The blog 'name' should be a link to the group's blog within the activity
-- There should be one entry in the 'Most comments' tab - for G1's blog (3 comments)
-- There should be two entries in the 'Most commented posts' tab - Post01 (2 comments) Untitled post (1 comment)
-- The admin avatar should show against the posts and the title link to the post.

GRP02 / admin

From the course home page access the CRE02 blog
Select the Visible group 'All participants'
'Most posts' and 'Most comments' tabs should be as per GRP01
'Most commented posts' should now list posts with most comments across all group blogs
-- Post01 and Untitled post should be listed as per GRP01, but with addition of link to G1's blog below.

IND Checking usage 'block' on individual blog
=============================================

IND01 / admin

From the course home page access the CRE03 blog
Select the Visible individual admin user
-- A 'Blog usage' 'block' should show to the right
-- The 'block' should contain 'Most posts', 'Most comments' and 'Most commented posts' tabs
-- You should be able to expand/collapse each tab by selecting it's heading (1 open at a time)
-- There should be two entries in the 'Most posts' tab
-- One for each user, with 2 posts for admin's blog above 1 for student's
-- The user's avatar should be to the left of the entries
-- The blog 'name' should be a link to the user's blog within the activity
-- There should be one entry in the 'Most comments' tab - for admin's blog (3 comments)
-- There should be two entries in the 'Most commented posts' tab - Post01 (2 comments) Untitled post (1 comment)
-- The admin avatar should show against the posts and the title link to the post.

IND02 / admin

From the course home page access the CRE03 blog
Select the Visible individual 'View all users'
'Most posts' and 'Most comments' tabs should be as per IND01
'Most commented posts' should now list posts with most comments across all user blogs
-- Post01 and Untitled post should be listed as per IND01, but with addition of link to admin's blog below.

OFF Checking usage 'block' displays appropriately
=================================================

OFF01 / admin

From the course home page access blog CRE02
Select Edit settings from the Administration block
Un-tick Show blog usage statistics block - Save and display the activity
-- Only 'Most commented posts' should now be showing in the Blog usage block
Select Edit settings from the Administration block again
Tick Show blog usage extra statistics (turn back on)
Update group mode from 'Visible groups' to 'Separate groups', save and display
-- Blog usage block should not be showing at all.

OFF02 / admin

From the course home page access blog CRE03
Select Edit settings from the Administration block
Update Allow comments to 'Comments not allowed', Save and display
-- Only 'Most posts' should now be showing in the Blog usage block
Select Edit settings from the Administration block
Update 'Individual blogs' to 'Separate individual blogs', Save and display
-- Blog usage block should not be showing at all.

PER Checking personal blog usage
=================================

PER01 / admin

Access the user's personal blog via /mod/oublog/view.php
Select 'New blog post' and add a new blog post, setting title to 'Post01'
Set visibility to 'Visible to anyone in the world'
Add any message text you like and set Allow comments to 'Yes, from logged in users'
Repeat, adding an untitled post, set visibility to 'Visible to everyone logged in to the system'
Select 'Add your comment' against Post01 and add a new comment (no title, any text)
Copy the URL to admin student's blog page for use in next step.

PER02 / student

Access admin's personal blog via /mod/oublog/view.php?user=XXX
Select 'Add your comment' against Post01 and add a new comment (no title, any text)
Select 'Add your comment' against the untitled post and add a new comment (no title, any text)
Return to admin users personal blog main page
Within the Blog usage 'block' select 'Most commented posts'
-- Post01 should be displayed in the list with 1 comment
-- 'Untitled post' should be displayed in the list with 1 comment.

PER03 / guest

In a different browser access admin's personal blog via /mod/oublog/view.php?user=XXX
Within the Blog usage 'block' select 'Most commented posts'
-- Post01 should be displayed in the list with 1 comment
-- Admin user's avatar should not be displayed (default should be shown).

PER04 / student

Access admin's personal blog via /mod/oublog/view.php?user=XXX
Select the 'Site entries' link (right block)
-- On the Personal blogs page the Blog usage block should be displayed
-- The 'block' should contain 'Most visited', 'Most posts', 'Most comments' and 'Most commented posts' tabs
-- Ensure each tab expands correctly
-- Items in the 'Most commented posts' tab should have links to the user's blog page below.
Loading

0 comments on commit 5fa2e88

Please sign in to comment.