Browse Source

Switch status grade from integer to decimal

MOODLE_28_STABLE
Davo Smith 10 years ago
parent
commit
5ed33cc950
  1. 2
      db/install.xml
  2. 13
      db/upgrade.php
  3. 10
      export.php
  4. 8
      preferences.php
  5. 4
      renderer.php
  6. 4
      renderhelpers.php
  7. 2
      version.php

2
db/install.xml

@ -68,7 +68,7 @@
<FIELD NAME="attendanceid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/> <FIELD NAME="attendanceid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="acronym" TYPE="char" LENGTH="2" NOTNULL="true" SEQUENCE="false"/> <FIELD NAME="acronym" TYPE="char" LENGTH="2" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="description" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false"/> <FIELD NAME="description" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="grade" TYPE="int" LENGTH="3" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/> <FIELD NAME="grade" TYPE="number" LENGTH="5" NOTNULL="true" DEFAULT="0" SEQUENCE="false" DECIMALS="2"/>
<FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/> <FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
<FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/> <FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="setnumber" TYPE="int" LENGTH="5" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Allows different sets of statuses to be allocated to different sessions"/> <FIELD NAME="setnumber" TYPE="int" LENGTH="5" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Allows different sets of statuses to be allocated to different sessions"/>

13
db/upgrade.php

@ -145,5 +145,18 @@ function xmldb_attendance_upgrade($oldversion=0) {
upgrade_mod_savepoint(true, 2015040502, 'attendance'); upgrade_mod_savepoint(true, 2015040502, 'attendance');
} }
if ($oldversion < 2015040503) {
// Changing type of field grade on table attendance_statuses to number.
$table = new xmldb_table('attendance_statuses');
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '5, 2', null, XMLDB_NOTNULL, null, '0', 'description');
// Launch change of type for field grade.
$dbman->change_field_type($table, $field);
// Attendance savepoint reached.
upgrade_mod_savepoint(true, 2015040503, 'attendance');
}
return $result; return $result;
} }

10
export.php

@ -118,6 +118,7 @@ if ($mform->is_submitted()) {
} }
if ($reportdata->gradable) { if ($reportdata->gradable) {
$data->tabhead[] = get_string('grade'); $data->tabhead[] = get_string('grade');
$data->tabhead[] = get_string('percentage', 'attendance');
} }
$i = 0; $i = 0;
@ -151,7 +152,14 @@ if ($mform->is_submitted()) {
$cellsgenerator = new user_sessions_cells_text_generator($reportdata, $user); $cellsgenerator = new user_sessions_cells_text_generator($reportdata, $user);
$data->table[$i] = array_merge($data->table[$i], $cellsgenerator->get_cells(isset($formdata->includeremarks))); $data->table[$i] = array_merge($data->table[$i], $cellsgenerator->get_cells(isset($formdata->includeremarks)));
if ($reportdata->gradable) { if ($reportdata->gradable) {
$data->table[$i][] = $reportdata->grades[$user->id].' / '.$reportdata->maxgrades[$user->id]; $data->table[$i][] = format_float($reportdata->grades[$user->id]).' / '.
format_float($reportdata->maxgrades[$user->id]);
if ($reportdata->maxgrades[$user->id]) {
$percent = $reportdata->grades[$user->id] * 100.0 / $reportdata->maxgrades[$user->id];
} else {
$percent = 0.0;
}
$data->table[$i][] = $percent;
} }
$i++; $i++;
} }

8
preferences.php

@ -59,7 +59,8 @@ switch ($att->pageparams->action) {
case att_preferences_page_params::ACTION_ADD: case att_preferences_page_params::ACTION_ADD:
$newacronym = optional_param('newacronym', null, PARAM_TEXT); $newacronym = optional_param('newacronym', null, PARAM_TEXT);
$newdescription = optional_param('newdescription', null, PARAM_TEXT); $newdescription = optional_param('newdescription', null, PARAM_TEXT);
$newgrade = optional_param('newgrade', 0, PARAM_INT); $newgrade = optional_param('newgrade', 0, PARAM_RAW);
$newgrade = unformat_float($newgrade);
$att->add_status($newacronym, $newdescription, $newgrade); $att->add_status($newacronym, $newdescription, $newgrade);
if ($pageparams->statusset > $maxstatusset) { if ($pageparams->statusset > $maxstatusset) {
@ -103,7 +104,10 @@ switch ($att->pageparams->action) {
case att_preferences_page_params::ACTION_SAVE: case att_preferences_page_params::ACTION_SAVE:
$acronym = required_param_array('acronym', PARAM_MULTILANG); $acronym = required_param_array('acronym', PARAM_MULTILANG);
$description = required_param_array('description', PARAM_MULTILANG); $description = required_param_array('description', PARAM_MULTILANG);
$grade = required_param_array('grade', PARAM_INT); $grade = required_param_array('grade', PARAM_RAW);
foreach ($grade as &$val) {
$val = unformat_float($val);
}
$statuses = $att->get_statuses(false); $statuses = $att->get_statuses(false);
foreach ($acronym as $id => $v) { foreach ($acronym as $id => $v) {

4
renderer.php

@ -860,7 +860,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
} }
if ($reportdata->gradable) { if ($reportdata->gradable) {
$row->cells[] = $reportdata->grades[$user->id].' / '.$reportdata->maxgrades[$user->id]; $row->cells[] = format_float($reportdata->grades[$user->id]).' / '.format_float($reportdata->maxgrades[$user->id]);
} }
if ($reportdata->sessionslog) { if ($reportdata->sessionslog) {
@ -962,7 +962,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
$table->data[$i][] = $i; $table->data[$i][] = $i;
$table->data[$i][] = $this->construct_text_input('acronym['.$st->id.']', 2, 2, $st->acronym); $table->data[$i][] = $this->construct_text_input('acronym['.$st->id.']', 2, 2, $st->acronym);
$table->data[$i][] = $this->construct_text_input('description['.$st->id.']', 30, 30, $st->description); $table->data[$i][] = $this->construct_text_input('description['.$st->id.']', 30, 30, $st->description);
$table->data[$i][] = $this->construct_text_input('grade['.$st->id.']', 4, 4, $st->grade); $table->data[$i][] = $this->construct_text_input('grade['.$st->id.']', 4, 4, format_float($st->grade));
$table->data[$i][] = $this->construct_preferences_actions_icons($st, $prefdata); $table->data[$i][] = $this->construct_preferences_actions_icons($st, $prefdata);
$i++; $i++;

4
renderhelpers.php

@ -237,7 +237,7 @@ function construct_user_data_stat($stat, $statuses, $gradable, $grade, $maxgrade
$row = new html_table_row(); $row = new html_table_row();
$row->cells[] = get_string('attendancegrade', 'attendance') . $row->cells[] = get_string('attendancegrade', 'attendance') .
$OUTPUT->help_icon('gradebookexplanation', 'attendance') . ':'; $OUTPUT->help_icon('gradebookexplanation', 'attendance') . ':';
$row->cells[] = $grade . ' / ' . $maxgrade; $row->cells[] = format_float($grade) . ' / ' . format_float($maxgrade);
$stattable->data[] = $row; $stattable->data[] = $row;
$row = new html_table_row(); $row = new html_table_row();
@ -247,7 +247,7 @@ function construct_user_data_stat($stat, $statuses, $gradable, $grade, $maxgrade
} else { } else {
$percent = $grade / $maxgrade * 100; $percent = $grade / $maxgrade * 100;
} }
$row->cells[] = sprintf("%0.{$decimalpoints}f", $percent); $row->cells[] = format_float(sprintf("%0.{$decimalpoints}f", $percent));
$stattable->data[] = $row; $stattable->data[] = $row;
} }

2
version.php

@ -22,7 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
$plugin->version = 2015040502; $plugin->version = 2015040503;
$plugin->requires = 2014042900; $plugin->requires = 2014042900;
$plugin->release = '2.9.1'; $plugin->release = '2.9.1';
$plugin->maturity = MATURITY_STABLE; $plugin->maturity = MATURITY_STABLE;

Loading…
Cancel
Save