Skip to content

Commit

Permalink
MDL-15471 course tagging improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenny Gray committed Sep 20, 2012
1 parent a3ab18c commit 7dd764b
Show file tree
Hide file tree
Showing 16 changed files with 191 additions and 592 deletions.
332 changes: 99 additions & 233 deletions blocks/tags/block_tags.php

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion blocks/tags/edit_form.php
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -44,5 +43,9 @@ protected function specific_definition($mform) {
}
$mform->addElement('select', 'config_numberoftags', get_string('numberoftags', 'blog'), $numberoftags);
$mform->setDefault('config_numberoftags', 80);

$defaults = array('default'=>'default', 'official'=>'official', ''=>'both');
$mform->addElement('select', 'config_tagtype', get_string('defaultdisplay', 'block_tags'), $defaults);
$mform->setDefault('config_tagtype', '');
}
}
18 changes: 2 additions & 16 deletions blocks/tags/lang/en/block_tags.php
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -25,16 +24,10 @@

$string['add'] = 'Add';
$string['alltags'] = 'All tags:';
$string['alltags1'] = 'all tags';
$string['alltags2'] = 'Show all tags (user profile, blogs and course tags)';
$string['arrowtitle'] = 'Click here to enter the suggested text (grey letters).';
$string['communitytags'] = 'Community tags:';
$string['communitytags1'] = 'community tags';
$string['communitytags2'] = 'Show all user created course tags';
$string['coursetags'] = 'Course tags:';
$string['coursetags1'] = 'course tags';
$string['coursetags2'] = 'Show tags for this course';
$string['disabledtags'] = 'Tags are disabled';
$string['defaultdisplay'] = 'Tag type to display';
$string['edit'] = 'edit...';
$string['editdeletemytag'] = 'Delete tag from this course:';
$string['editmytags'] = 'My tags - shortcuts to all your tagged courses.';
Expand All @@ -56,7 +49,7 @@
$string['moreorderpop'] = 'Popularity';
$string['moreshow'] = 'Show:';
$string['moreshowalltags'] = 'All tags';
$string['moreshowcommtags'] = 'Community tags';
$string['moreshowcommtags'] = 'Non-official tags';
$string['moreshowcoursetags'] = 'Tags for \'{$a}\'';
$string['moreshowmytags'] = 'My tags';
$string['moreshowofficialtags'] = 'Official tags';
Expand All @@ -68,15 +61,8 @@
Different groups of tags may be displayed with the links on the \'Show:\' line,
and may be reordered with the links on the \'Order:\' line.';
$string['mycoursetags'] = 'My course tags:';
$string['mycoursetag1'] = 'Show my course tags';
$string['mycoursetag2'] = 'my course tags';
$string['mytags'] = 'My tags:';
$string['mytags1'] = 'my tags';
$string['mytags2'] = 'Show my personal tags';
$string['notagsyet'] = 'No tags yet';
$string['officialtags'] = 'Official course tags:';
$string['officialtags1'] = 'official tags';
$string['officialtags2'] = 'Show official course tags';
$string['please'] = 'Please';
$string['pluginname'] = 'Tags';
$string['select'] = 'Select...';
Expand Down
15 changes: 14 additions & 1 deletion blocks/tags/settings.php
@@ -1,9 +1,22 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

defined('MOODLE_INTERNAL') || die;

if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configcheckbox('block_tags_showcoursetags', get_string('showcoursetags', 'block_tags'),
get_string('showcoursetagsdef', 'block_tags'), 0));
}

2 changes: 1 addition & 1 deletion blocks/tags/version.php
Expand Up @@ -25,6 +25,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2012061700; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2012082800; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2012061700; // Requires this Moodle version
$plugin->component = 'block_tags'; // Full name of the plugin (used for diagnostics)
1 change: 1 addition & 0 deletions lang/en/role.php
Expand Up @@ -353,6 +353,7 @@
$string['tag:edit'] = 'Edit existing tags';
$string['tag:editblocks'] = 'Edit blocks in tags pages';
$string['tag:manage'] = 'Manage all tags';
$string['tag:flag'] = 'Flag tags as innappropriate';
$string['thisusersroles'] = 'This user\'s role assignments';
$string['unassignarole'] = 'Unassign role {$a}';
$string['unassignerror'] = 'Error while unassigning the role {$a->role} from user {$a->user}.';
Expand Down
11 changes: 11 additions & 0 deletions lib/db/access.php
Expand Up @@ -1669,6 +1669,17 @@
)
),

'moodle/tag:flag' => array(
'riskbitmask' => RISK_SPAM,

'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'manager' => CAP_ALLOW,
'user' => CAP_ALLOW
)
),

'moodle/tag:editblocks' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
Expand Down
4 changes: 2 additions & 2 deletions lib/db/install.xml
Expand Up @@ -2019,8 +2019,8 @@
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="primary"/>
</KEYS>
<INDEXES>
<INDEX NAME="name" UNIQUE="true" FIELDS="name" COMMENT="tag names are unique"/>
</INDEXES>
<INDEX NAME="name" UNIQUE="true" FIELDS="name" COMMENT="tag names are unique" NEXT="idname"/>
<INDEX NAME="idname" UNIQUE="true" FIELDS="id, name" COMMENT="Improves performance of autocomplete in tag block" PREVIOUS="name"/> </INDEXES>
</TABLE>
<TABLE NAME="tag_correlation" COMMENT="The rationale for the 'tag_correlation' table is performance. It works as a cache for a potentially heavy load query done at the 'tag_instance' table. So, the 'tag_correlation' table stores redundant information derived from the 'tag_instance' table" PREVIOUS="tag" NEXT="tag_instance">
<FIELDS>
Expand Down
16 changes: 15 additions & 1 deletion lib/db/upgrade.php
Expand Up @@ -1206,5 +1206,19 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012090700.01);
}

if ($oldversion < 2012092000.00) {
// Define index idname (unique) to be added to tag
$table = new xmldb_table('tag');
$index = new xmldb_index('idname', XMLDB_INDEX_UNIQUE, array('id', 'name'));

// Conditionally launch add index idname
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}

// Main savepoint reached
upgrade_main_savepoint(true, 2012092000.01);
}

return true;
}
}
2 changes: 1 addition & 1 deletion tag/coursetags_edit.php
Expand Up @@ -96,7 +96,7 @@
$title = get_string('edittitle', $tagslang);
echo $OUTPUT->heading($title, 2, 'mdl-align');

$mytags = coursetag_print_cloud(coursetag_get_tags(0, $USER->id, 'default'), true);
$mytags = tag_print_cloud(coursetag_get_tags(0, $USER->id, 'default'), 150, true);
$outstr = '
<div class="coursetag_edit_centered">
<div>
Expand Down
30 changes: 15 additions & 15 deletions tag/coursetags_more.php
Expand Up @@ -105,56 +105,56 @@
if ($show == 'course' and $courseid) {

if ($sort == 'popularity') {
$tags = coursetag_print_cloud(coursetag_get_tags($courseid, 0, '', 0, 'popularity'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_tags($courseid, 0, '', 0, 'popularity'), 150, true);
} else if ($sort == 'date') {
$tags = coursetag_print_cloud(coursetag_get_tags($courseid, 0, '', 0, 'timemodified'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_tags($courseid, 0, '', 0, 'timemodified'), 150, true);
} else {
$tags = coursetag_print_cloud(coursetag_get_tags($courseid, 0, '', 0, 'name'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_tags($courseid, 0, '', 0, 'name'), 150, true);
}

// My tags
} else if ($show == 'my' and $loggedin) {

if ($sort == 'popularity') {
$tags = coursetag_print_cloud(coursetag_get_tags(0, $USER->id, 'default', 0, 'popularity'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_tags(0, $USER->id, 'default', 0, 'popularity'), 150, true);
} else if ($sort == 'date') {
$tags = coursetag_print_cloud(coursetag_get_tags(0, $USER->id, 'default', 0, 'timemodified'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_tags(0, $USER->id, 'default', 0, 'timemodified'), 150, true);
} else {
$tags = coursetag_print_cloud(coursetag_get_tags(0, $USER->id, 'default', 0, 'name'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_tags(0, $USER->id, 'default', 0, 'name'), 150, true);
}

// Official course tags
} else if ($show == 'official') {

if ($sort == 'popularity') {
$tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'official', 0, 'popularity'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_tags(0, 0, 'official', 0, 'popularity'), 150, true);
} else if ($sort == 'date') {
$tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'official', 0, 'timemodified'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_tags(0, 0, 'official', 0, 'timemodified'), 150, true);
} else {
$tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'official', 0, 'name'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_tags(0, 0, 'official', 0, 'name'), 150, true);
}

// Community (official and personal together) also called user tags
} else if ($show == 'community') {

if ($sort == 'popularity') {
$tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'default', 0, 'popularity'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_tags(0, 0, 'default', 0, 'popularity'), 150, true);
} else if ($sort == 'date') {
$tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'default', 0, 'timemodified'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_tags(0, 0, 'default', 0, 'timemodified'), 150, true);
} else {
$tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'default', 0, 'name'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_tags(0, 0, 'default', 0, 'name'), 150, true);
}

// All tags for courses and blogs and any thing else tagged - the fallback default ($show == all)
} else {

$subtitle = $showalltags;
if ($sort == 'popularity') {
$tags = coursetag_print_cloud(coursetag_get_all_tags('popularity'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_all_tags('popularity'), 150, true);
} else if ($sort == 'date') {
$tags = coursetag_print_cloud(coursetag_get_all_tags('timemodified'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_all_tags('timemodified'), 150, true);
} else {
$tags = coursetag_print_cloud(coursetag_get_all_tags('name'), true, 200, 90);
$tags = tag_print_cloud(coursetag_get_all_tags('name'), 150, true);
}

}
Expand Down

0 comments on commit 7dd764b

Please sign in to comment.