Skip to content

Commit

Permalink
MDL-66360 forum: rename sendstudentnotifications_forum to forum_grade…
Browse files Browse the repository at this point in the history
…_notify
  • Loading branch information
lameze committed Nov 12, 2019
1 parent 5f1307e commit 254fc00
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mod/forum/classes/local/data_mappers/legacy/forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function to_legacy_objects(array $forums) : array {
'assesstimefinish' => $forum->get_assess_time_finish(),
'scale' => $forum->get_scale(),
'grade_forum' => $forum->get_grade_for_forum(),
'sendstudentnotifications_forum' => $forum->should_notify_students_default_when_grade_for_forum(),
'grade_forum_notify' => $forum->should_notify_students_default_when_grade_for_forum(),
'maxbytes' => $forum->get_max_bytes(),
'maxattachments' => $forum->get_max_attachments(),
'forcesubscribe' => $forum->get_subscription_mode(),
Expand Down
12 changes: 6 additions & 6 deletions mod/forum/classes/local/entities/forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class forum {
private $scale;
/** @var int $gradeforum The grade for the forum when grading holistically */
private $gradeforum;
/** @var bool $sendstudentnotificationsforum Whether to notify students when the forum is graded holistically */
private $sendstudentnotificationsforum;
/** @var bool $gradeforumnotify Whether to notify students when the forum is graded holistically */
private $gradeforumnotify;
/** @var int $maxbytes Maximum attachment size */
private $maxbytes;
/** @var int $maxattachments Maximum number of attachments */
Expand Down Expand Up @@ -126,7 +126,7 @@ class forum {
* @param int $assesstimefinish Timestamp to end assessment
* @param int $scale The rating scale
* @param int $gradeforum The holistic grade
* @param bool $sendstudentnotificationsforum Default for whether to notify students when grade holistically
* @param bool $gradeforumnotify Default for whether to notify students when grade holistically
* @param int $maxbytes Maximum attachment size
* @param int $maxattachments Maximum number of attachments
* @param int $forcesubscribe Does the forum force users to subscribe?
Expand Down Expand Up @@ -161,7 +161,7 @@ public function __construct(
int $assesstimefinish,
int $scale,
int $gradeforum,
bool $sendstudentnotificationsforum,
bool $gradeforumnotify,
int $maxbytes,
int $maxattachments,
int $forcesubscribe,
Expand Down Expand Up @@ -195,7 +195,7 @@ public function __construct(
$this->assesstimefinish = $assesstimefinish;
$this->scale = $scale;
$this->gradeforum = $gradeforum;
$this->sendstudentnotificationsforum = $sendstudentnotificationsforum;
$this->gradeforumnotify = $gradeforumnotify;
$this->maxbytes = $maxbytes;
$this->maxattachments = $maxattachments;
$this->forcesubscribe = $forcesubscribe;
Expand Down Expand Up @@ -383,7 +383,7 @@ public function is_grading_enabled(): bool {
* @return bool
*/
public function should_notify_students_default_when_grade_for_forum(): bool {
return $this->sendstudentnotificationsforum;
return $this->gradeforumnotify;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion mod/forum/classes/local/factories/entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function get_forum_from_stdclass(
$record->assesstimefinish,
$record->scale,
$record->grade_forum,
$record->sendstudentnotifications_forum,
$record->grade_forum_notify,
$record->maxbytes,
$record->maxattachments,
$record->forcesubscribe,
Expand Down
2 changes: 1 addition & 1 deletion mod/forum/db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<FIELD NAME="assesstimefinish" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="scale" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="grade_forum" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="sendstudentnotifications_forum" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="grade_forum_notify" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="maxbytes" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="maxattachments" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Number of attachments allowed per post"/>
<FIELD NAME="forcesubscribe" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
Expand Down
13 changes: 13 additions & 0 deletions mod/forum/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,18 @@ function xmldb_forum_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2019100108, 'forum');
}

if ($oldversion < 2019100109) {

$table = new xmldb_table('forum');
$field = new xmldb_field('sendstudentnotifications_forum');
if ($dbman->field_exists($table, $field)) {
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'grade_forum');
$dbman->rename_field($table, $field, 'grade_forum_notify');
}

// Forum savepoint reached.
upgrade_mod_savepoint(true, 2019100109, 'forum');

}
return true;
}
2 changes: 1 addition & 1 deletion mod/forum/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static function get_forums_by_courses_returns() {
'assesstimefinish' => new external_value(PARAM_INT, 'Assess finish time'),
'scale' => new external_value(PARAM_INT, 'Scale'),
'grade_forum' => new external_value(PARAM_INT, 'Whole forum grade'),
'sendstudentnotifications_forum' => new external_value(PARAM_INT, 'Whether to send notifications to students upon grading by default'),
'grade_forum_notify' => new external_value(PARAM_INT, 'Whether to send notifications to students upon grading by default'),
'maxbytes' => new external_value(PARAM_INT, 'Maximum attachment size'),
'maxattachments' => new external_value(PARAM_INT, 'Maximum number of attachments'),
'forcesubscribe' => new external_value(PARAM_INT, 'Force users to subscribe'),
Expand Down
2 changes: 1 addition & 1 deletion mod/forum/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

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

$plugin->version = 2019100108; // The current module version (Date: YYYYMMDDXX)
$plugin->version = 2019100109; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2019051100; // Requires this Moodle version
$plugin->component = 'mod_forum'; // Full name of the plugin (used for diagnostics)

0 comments on commit 254fc00

Please sign in to comment.