MDL-66079 mod_forum: Add field to support whole forum grading

Part of MDL-66074
This commit is contained in:
Andrew Nicols
2019-10-30 10:23:40 +08:00
committed by Mathew May
parent 629726dd3f
commit dc86a0f1c6
9 changed files with 44 additions and 2 deletions
+6
View File
@@ -54,6 +54,9 @@ class core_course_courselib_testcase extends advanced_testcase {
$moduleinfo->blockperiod = 60*60*24;
$moduleinfo->blockafter = 10;
$moduleinfo->warnafter = 5;
// Grading of whole forum settings.
$moduleinfo->grade_forum = 0;
}
/**
@@ -395,6 +398,9 @@ class core_course_courselib_testcase extends advanced_testcase {
$moduleinfo->blockperiod = 60*60*24;
$moduleinfo->blockafter = 10;
$moduleinfo->warnafter = 5;
// Grading of whole forum settings.
$moduleinfo->grade_forum = 0;
}
/**
@@ -55,6 +55,7 @@ class forum {
'assesstimestart' => $forum->get_assess_time_start(),
'assesstimefinish' => $forum->get_assess_time_finish(),
'scale' => $forum->get_scale(),
'grade_forum' => $forum->get_grade_for_forum(),
'maxbytes' => $forum->get_max_bytes(),
'maxattachments' => $forum->get_max_attachments(),
'forcesubscribe' => $forum->get_subscription_mode(),
@@ -69,6 +69,8 @@ class forum {
private $assesstimefinish;
/** @var int $scale The rating scale */
private $scale;
/** @var int $gradeforum The grade for the forum when grading holistcally */
private $gradeforum;
/** @var int $maxbytes Maximum attachment size */
private $maxbytes;
/** @var int $maxattachments Maximum number of attachments */
@@ -121,6 +123,7 @@ class forum {
* @param int $assesstimestart Timestamp to begin assessment
* @param int $assesstimefinish Timestamp to end assessment
* @param int $scale The rating scale
* @param int $forum_grade The holistic grade
* @param int $maxbytes Maximum attachment size
* @param int $maxattachments Maximum number of attachments
* @param int $forcesubscribe Does the forum force users to subscribe?
@@ -154,6 +157,7 @@ class forum {
int $assesstimestart,
int $assesstimefinish,
int $scale,
int $gradeforum,
int $maxbytes,
int $maxattachments,
int $forcesubscribe,
@@ -186,6 +190,7 @@ class forum {
$this->assesstimestart = $assesstimestart;
$this->assesstimefinish = $assesstimefinish;
$this->scale = $scale;
$this->gradeforum = $gradeforum;
$this->maxbytes = $maxbytes;
$this->maxattachments = $maxattachments;
$this->forcesubscribe = $forcesubscribe;
@@ -349,6 +354,15 @@ class forum {
return $this->scale;
}
/**
* Get the grade for the forum when grading holistically.
*
* @return int
*/
public function get_grade_for_forum() : int {
return $this->gradeforum;
}
/**
* Get the maximum bytes.
*
@@ -86,6 +86,7 @@ class entity {
$record->assesstimestart,
$record->assesstimefinish,
$record->scale,
$record->grade_forum,
$record->maxbytes,
$record->maxattachments,
$record->forcesubscribe,
+2 -1
View File
@@ -18,6 +18,7 @@
<FIELD NAME="assesstimestart" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<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="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"/>
@@ -194,4 +195,4 @@
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>
+13
View File
@@ -195,6 +195,19 @@ function xmldb_forum_upgrade($oldversion) {
// Main savepoint reached.
upgrade_mod_savepoint(true, 2019071902, 'forum');
}
if ($oldversion < 2019071902) {
// Define field grade_forum to be added to forum.
$table = new xmldb_table('forum');
$field = new xmldb_field('grade_forum', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'scale');
// Conditionally launch add field grade_forum.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Forum savepoint reached.
upgrade_mod_savepoint(true, 2019081100, 'forum');
return true;
}
+3
View File
@@ -78,6 +78,7 @@ class mod_forum_entities_forum_testcase extends advanced_testcase {
$assesstimestart = 0;
$assesstimefinish = 0;
$scale = 0;
$gradeforum = 0;
$maxbytes = 200;
$maxattachments = 5;
$forcesubscribe = 0;
@@ -111,6 +112,7 @@ class mod_forum_entities_forum_testcase extends advanced_testcase {
$assesstimestart,
$assesstimefinish,
$scale,
$gradeforum,
$maxbytes,
$maxattachments,
$forcesubscribe,
@@ -147,6 +149,7 @@ class mod_forum_entities_forum_testcase extends advanced_testcase {
$this->assertEquals($assesstimestart, $forum->get_assess_time_start());
$this->assertEquals($assesstimefinish, $forum->get_assess_time_finish());
$this->assertEquals($scale, $forum->get_scale());
$this->assertEquals($gradeforum, $forum->get_grade_for_forum());
$this->assertEquals($maxbytes, $forum->get_max_bytes());
$this->assertEquals($maxattachments, $forum->get_max_attachments());
$this->assertEquals($forcesubscribe, $forum->get_subscription_mode());
+3
View File
@@ -81,6 +81,9 @@ class mod_forum_generator extends testing_module_generator {
if (!isset($record->forcesubscribe)) {
$record->forcesubscribe = FORUM_CHOOSESUBSCRIBE;
}
if (!isset($record->grade_forum)) {
$record->grade_forum = 0;
}
return parent::create_instance($record, (array)$options);
}
+1 -1
View File
@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2019100101; // The current module version (Date: YYYYMMDDXX)
$plugin->version = 2019100103; // 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)