mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-5875 forum: Option to display post word count
This commit is contained in:
parent
6319737865
commit
506522d582
@ -44,7 +44,7 @@ class backup_forum_activity_structure_step extends backup_activity_structure_ste
|
||||
'maxbytes', 'maxattachments', 'forcesubscribe', 'trackingtype',
|
||||
'rsstype', 'rssarticles', 'timemodified', 'warnafter',
|
||||
'blockafter', 'blockperiod', 'completiondiscussions', 'completionreplies',
|
||||
'completionposts'));
|
||||
'completionposts', 'displaywordcount'));
|
||||
|
||||
$discussions = new backup_nested_element('discussions');
|
||||
|
||||
|
3
mod/forum/db/install.xml
Normal file → Executable file
3
mod/forum/db/install.xml
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="mod/forum/db" VERSION="20120122" COMMENT="XMLDB file for Moodle mod/forum"
|
||||
<XMLDB PATH="mod/forum/db" VERSION="20130205" COMMENT="XMLDB file for Moodle mod/forum"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@ -29,6 +29,7 @@
|
||||
<FIELD NAME="completiondiscussions" TYPE="int" LENGTH="9" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Nonzero if a certain number of posts are required to mark this forum completed for a user."/>
|
||||
<FIELD NAME="completionreplies" TYPE="int" LENGTH="9" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Nonzero if a certain number of replies are required to mark this forum complete for a user."/>
|
||||
<FIELD NAME="completionposts" TYPE="int" LENGTH="9" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Nonzero if a certain number of posts or replies (total) are required to mark this forum complete for a user."/>
|
||||
<FIELD NAME="displaywordcount" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
|
@ -44,19 +44,33 @@
|
||||
function xmldb_forum_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager(); // loads ddl manager and xmldb classes
|
||||
$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
|
||||
|
||||
// Moodle v2.2.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
if ($oldversion < 2013020500) {
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
// Define field displaywordcount to be added to forum.
|
||||
$table = new xmldb_table('forum');
|
||||
$field = new xmldb_field('displaywordcount', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'completionposts');
|
||||
|
||||
// Conditionally launch add field displaywordcount.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Forum savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2013020500, 'forum');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -135,6 +135,8 @@ $string['displaymode'] = 'Display mode';
|
||||
$string['displayperiod'] = 'Display period';
|
||||
$string['displaystart'] = 'Display start';
|
||||
$string['displaystart_help'] = 'This setting specifies whether a forum post should be displayed from a certain date. Note that administrators can always view forum posts.';
|
||||
$string['displaywordcount'] = 'Display word count';
|
||||
$string['displaywordcount_help'] = 'This setting specifies whether the word count of each post should be displayed or not.';
|
||||
$string['eachuserforum'] = 'Each person posts one discussion';
|
||||
$string['edit'] = 'Edit';
|
||||
$string['editedby'] = 'Edited by {$a->name} - original submission {$a->date}';
|
||||
|
@ -3451,7 +3451,8 @@ function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost=fa
|
||||
$postclass = 'shortenedpost';
|
||||
$postcontent = format_text(forum_shorten_post($post->message), $post->messageformat, $options, $course->id);
|
||||
$postcontent .= html_writer::link($discussionlink, get_string('readtherest', 'forum'));
|
||||
$postcontent .= html_writer::tag('span', '('.get_string('numwords', 'moodle', count_words(strip_tags($post->message))).')...', array('class'=>'post-word-count'));
|
||||
$postcontent .= html_writer::tag('div', '('.get_string('numwords', 'moodle', count_words($post->message)).')',
|
||||
array('class'=>'post-word-count'));
|
||||
} else {
|
||||
// Prepare whole post
|
||||
$postclass = 'fullpost';
|
||||
@ -3459,8 +3460,13 @@ function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost=fa
|
||||
if (!empty($highlight)) {
|
||||
$postcontent = highlight($highlight, $postcontent);
|
||||
}
|
||||
if (!empty($forum->displaywordcount)) {
|
||||
$postcontent .= html_writer::tag('div', get_string('numwords', 'moodle', count_words($post->message)),
|
||||
array('class'=>'post-word-count'));
|
||||
}
|
||||
$postcontent .= html_writer::tag('div', $attachedimages, array('class'=>'attachedimages'));
|
||||
}
|
||||
|
||||
// Output the post content
|
||||
$output .= html_writer::tag('div', $postcontent, array('class'=>'posting '.$postclass));
|
||||
$output .= html_writer::end_tag('div'); // Content
|
||||
|
@ -82,6 +82,11 @@ class mod_forum_mod_form extends moodleform_mod {
|
||||
$mform->addHelpButton('maxattachments', 'maxattachments', 'forum');
|
||||
$mform->setDefault('maxattachments', $CFG->forum_maxattachments);
|
||||
|
||||
$mform->addElement('selectyesno', 'displaywordcount', get_string('displaywordcount', 'forum'));
|
||||
$mform->addHelpButton('displaywordcount', 'displaywordcount', 'forum');
|
||||
$mform->setDefault('displaywordcount', 0);
|
||||
$mform->setAdvanced('displaywordcount');
|
||||
|
||||
if ($CFG->enablerssfeeds && isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds) {
|
||||
//-------------------------------------------------------------------------------
|
||||
$mform->addElement('header', '', get_string('rss'));
|
||||
|
@ -19,6 +19,7 @@
|
||||
* div.left
|
||||
* div.options
|
||||
* div.commands
|
||||
* div.post-word-count
|
||||
* div.forum-post-rating
|
||||
* div.link
|
||||
* div.footer
|
||||
@ -40,6 +41,8 @@
|
||||
.forumpost .options .forum-post-rating {float:left;}
|
||||
.forumpost .content .posting {overflow:auto;max-width:100%;}
|
||||
.forumpost .content .attachedimages img {max-width:100%;}
|
||||
.forumpost .post-word-count { font-size: .85em; font-style: italic; }
|
||||
.forumpost .shortenedpost .post-word-count { display: inline; padding: 0 .3em; }
|
||||
|
||||
.dir-rtl .forumpost .row .topic,
|
||||
.dir-rtl .forumpost .row .content-mask,
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$module->version = 2012112902; // The current module version (Date: YYYYMMDDXX)
|
||||
$module->requires = 2012112900; // Requires this Moodle version
|
||||
$module->version = 2013020500; // The current module version (Date: YYYYMMDDXX)
|
||||
$module->requires = 2012112900; // Requires this Moodle version
|
||||
$module->component = 'mod_forum'; // Full name of the plugin (used for diagnostics)
|
||||
$module->cron = 60;
|
||||
|
@ -465,7 +465,7 @@ h2.tagline {
|
||||
padding-right: 10px;
|
||||
}
|
||||
.forumpost .content .shortenedpost a,
|
||||
.forumpost .content .shortenedpost span.post-word-count,
|
||||
.forumpost .content .post-word-count,
|
||||
.forumpost .commands,
|
||||
.forumpost .topic .author,
|
||||
.forumpost .options .link {
|
||||
@ -710,4 +710,4 @@ h2.tagline {
|
||||
#adminsettings .form-buttons {
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
@ -80,8 +80,8 @@ table.mod_index {width:90%;margin:1em auto;}
|
||||
.forumpost.firstpost .row.header {background-color:#DDD;}
|
||||
.forumpost .topic .author {font-size: 0.8em;padding:4px;}
|
||||
.forumpost .topic .subject {font-weight: bold;padding:4px 4px 0;}
|
||||
.forumpost .content div,
|
||||
.forumpost .options div {padding:4px;}
|
||||
.forumpost .content > div,
|
||||
.forumpost .options > div {padding:4px;}
|
||||
.forumpost.unread {background: #9EBEFF;}
|
||||
.forumpost.unread .content {border:2px solid #0046C7;} /** inside border of unread posts in nested format in */
|
||||
.forumpost .comment-ctrl,
|
||||
|
@ -30,7 +30,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$version = 2013020800.00; // YYYYMMDD = weekly release date of this DEV branch
|
||||
$version = 2013020800.01; // YYYYMMDD = weekly release date of this DEV branch
|
||||
// RR = release increments - 00 in DEV branches
|
||||
// .XX = incremental changes
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user