Browse Source

We don't need courseid fields in attendance_sessions and attendance_statuses because of now we can create more than one attendances per course

MOODLE_23_STABLE
Artem Andreev 14 years ago
parent
commit
747d96944e
  1. 24
      db/install.xml
  2. 24
      db/upgrade.php
  3. 15
      locallib.php
  4. 4
      version.php

24
db/install.xml

@ -20,11 +20,10 @@
</TABLE> </TABLE>
<TABLE NAME="attendance_sessions" COMMENT="attendance_sessions table retrofitted from MySQL" PREVIOUS="attforblock" NEXT="attendance_log"> <TABLE NAME="attendance_sessions" COMMENT="attendance_sessions table retrofitted from MySQL" PREVIOUS="attforblock" NEXT="attendance_log">
<FIELDS> <FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="courseid"/> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="attendanceid"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="groupid"/> <FIELD NAME="attendanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="groupid"/>
<FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="courseid" NEXT="attendanceid"/> <FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="attendanceid" NEXT="sessdate"/>
<FIELD NAME="attendanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="groupid" NEXT="sessdate"/> <FIELD NAME="sessdate" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="groupid" NEXT="duration"/>
<FIELD NAME="sessdate" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="attendanceid" NEXT="duration"/>
<FIELD NAME="duration" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="sessdate" NEXT="lasttaken"/> <FIELD NAME="duration" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="sessdate" NEXT="lasttaken"/>
<FIELD NAME="lasttaken" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" PREVIOUS="duration" NEXT="lasttakenby"/> <FIELD NAME="lasttaken" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" PREVIOUS="duration" NEXT="lasttakenby"/>
<FIELD NAME="lasttakenby" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="lasttaken" NEXT="timemodified"/> <FIELD NAME="lasttakenby" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="lasttaken" NEXT="timemodified"/>
@ -36,10 +35,9 @@
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance_sessions"/> <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance_sessions"/>
</KEYS> </KEYS>
<INDEXES> <INDEXES>
<INDEX NAME="courseid" UNIQUE="false" FIELDS="courseid" NEXT="groupid"/> <INDEX NAME="attendanceid" UNIQUE="false" FIELDS="attendanceid" NEXT="groupid"/>
<INDEX NAME="groupid" UNIQUE="false" FIELDS="groupid" PREVIOUS="courseid" NEXT="attendanceid"/> <INDEX NAME="groupid" UNIQUE="false" FIELDS="groupid" PREVIOUS="attendanceid" NEXT="sessdate"/>
<INDEX NAME="attendanceid" UNIQUE="false" FIELDS="attendanceid" PREVIOUS="groupid" NEXT="sessdate"/> <INDEX NAME="sessdate" UNIQUE="false" FIELDS="sessdate" PREVIOUS="groupid"/>
<INDEX NAME="sessdate" UNIQUE="false" FIELDS="sessdate" PREVIOUS="attendanceid"/>
</INDEXES> </INDEXES>
</TABLE> </TABLE>
<TABLE NAME="attendance_log" COMMENT="attendance_log table retrofitted from MySQL" PREVIOUS="attendance_sessions" NEXT="attendance_statuses"> <TABLE NAME="attendance_log" COMMENT="attendance_log table retrofitted from MySQL" PREVIOUS="attendance_sessions" NEXT="attendance_statuses">
@ -64,9 +62,8 @@
</TABLE> </TABLE>
<TABLE NAME="attendance_statuses" COMMENT="attendance_statuses table retrofitted from MySQL" PREVIOUS="attendance_log"> <TABLE NAME="attendance_statuses" COMMENT="attendance_statuses table retrofitted from MySQL" PREVIOUS="attendance_log">
<FIELDS> <FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="courseid"/> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="attendanceid"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="attendanceid"/> <FIELD NAME="attendanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="acronym"/>
<FIELD NAME="attendanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="courseid" NEXT="acronym"/>
<FIELD NAME="acronym" TYPE="char" LENGTH="2" NOTNULL="true" SEQUENCE="false" PREVIOUS="attendanceid" NEXT="description"/> <FIELD NAME="acronym" TYPE="char" LENGTH="2" NOTNULL="true" SEQUENCE="false" PREVIOUS="attendanceid" NEXT="description"/>
<FIELD NAME="description" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" PREVIOUS="acronym" NEXT="grade"/> <FIELD NAME="description" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" PREVIOUS="acronym" NEXT="grade"/>
<FIELD NAME="grade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="description" NEXT="visible"/> <FIELD NAME="grade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="description" NEXT="visible"/>
@ -77,8 +74,7 @@
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance_settings"/> <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance_settings"/>
</KEYS> </KEYS>
<INDEXES> <INDEXES>
<INDEX NAME="courseid" UNIQUE="false" FIELDS="courseid" NEXT="attendanceid"/> <INDEX NAME="attendanceid" UNIQUE="false" FIELDS="attendanceid" NEXT="visible"/>
<INDEX NAME="attendanceid" UNIQUE="false" FIELDS="attendanceid" PREVIOUS="courseid" NEXT="visible"/>
<INDEX NAME="visible" UNIQUE="false" FIELDS="visible" PREVIOUS="attendanceid" NEXT="deleted"/> <INDEX NAME="visible" UNIQUE="false" FIELDS="visible" PREVIOUS="attendanceid" NEXT="deleted"/>
<INDEX NAME="deleted" UNIQUE="false" FIELDS="deleted" PREVIOUS="visible"/> <INDEX NAME="deleted" UNIQUE="false" FIELDS="deleted" PREVIOUS="visible"/>
</INDEXES> </INDEXES>

24
db/upgrade.php

@ -279,7 +279,7 @@ function xmldb_attforblock_upgrade($oldversion=0) {
upgrade_mod_savepoint(true, 2010123003, 'attforblock'); upgrade_mod_savepoint(true, 2010123003, 'attforblock');
} }
if ($oldversion < 2011053006) { if ($oldversion < 2011061800) {
$table = new xmldb_table('attendance_sessions'); $table = new xmldb_table('attendance_sessions');
$field = new xmldb_field('description'); $field = new xmldb_field('description');
@ -304,7 +304,27 @@ function xmldb_attforblock_upgrade($oldversion=0) {
$rs->close(); $rs->close();
} }
upgrade_mod_savepoint(true, 2011053006, 'attforblock'); // now we can create more than one attendances per course
// thus sessions and statuses belongs to attendance
// so we don't need courseid fields in attendance_sessions and attendance_statuses
$index = new xmldb_index('courseid', XMLDB_INDEX_NOTUNIQUE, array('courseid'));
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}
$field = new xmldb_field('courseid');
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
$table = new xmldb_table('attendance_statuses');
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
upgrade_mod_savepoint(true, 2011061800, 'attforblock');
} }
return $result; return $result;
} }

15
locallib.php

@ -452,9 +452,8 @@ class attforblock {
public function get_hidden_sessions_count() { public function get_hidden_sessions_count() {
global $DB; global $DB;
$where = "courseid = :cid AND attendanceid = :aid AND sessdate < :csdate"; $where = "attendanceid = :aid AND sessdate < :csdate";
$params = array( $params = array(
'cid' => $this->course->id,
'aid' => $this->id, 'aid' => $this->id,
'csdate'=> $this->course->startdate); 'csdate'=> $this->course->startdate);
@ -465,15 +464,14 @@ class attforblock {
global $DB; global $DB;
if ($this->pageparams->startdate && $this->pageparams->enddate) { if ($this->pageparams->startdate && $this->pageparams->enddate) {
$where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :csdate AND sessdate >= :sdate AND sessdate < :edate"; $where = "attendanceid = :aid AND sessdate >= :csdate AND sessdate >= :sdate AND sessdate < :edate";
} else { } else {
$where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :csdate"; $where = "attendanceid = :aid AND sessdate >= :csdate";
} }
if ($this->get_current_group() > attforblock::SELECTOR_ALL) { if ($this->get_current_group() > attforblock::SELECTOR_ALL) {
$where .= " AND groupid=:cgroup"; $where .= " AND groupid=:cgroup";
} }
$params = array( $params = array(
'cid' => $this->course->id,
'aid' => $this->id, 'aid' => $this->id,
'csdate' => $this->course->startdate, 'csdate' => $this->course->startdate,
'sdate' => $this->pageparams->startdate, 'sdate' => $this->pageparams->startdate,
@ -914,10 +912,10 @@ class attforblock {
global $DB; global $DB;
if ($this->pageparams->startdate && $this->pageparams->enddate) { if ($this->pageparams->startdate && $this->pageparams->enddate) {
$where = "ats.courseid=:cid AND ats.attendanceid = :aid AND $where = "ats.attendanceid = :aid AND ats.sessdate >= :csdate AND
ats.sessdate >= :csdate AND ats.sessdate >= :sdate AND ats.sessdate < :edate"; ats.sessdate >= :sdate AND ats.sessdate < :edate";
} else { } else {
$where = "AND ats.courseid=:cid AND ats.attendanceid = :aid AND ats.sessdate >= :csdate"; $where = "AND ats.attendanceid = :aid AND ats.sessdate >= :csdate";
} }
$sql = "SELECT ats.id, ats.sessdate, ats.duration, ats.description, al.statusid, al.remarks $sql = "SELECT ats.id, ats.sessdate, ats.duration, ats.description, al.statusid, al.remarks
@ -929,7 +927,6 @@ class attforblock {
$params = array( $params = array(
'uid' => $userid, 'uid' => $userid,
'cid' => $this->course->id,
'aid' => $this->id, 'aid' => $this->id,
'csdate' => $this->course->startdate, 'csdate' => $this->course->startdate,
'sdate' => $this->pageparams->startdate, 'sdate' => $this->pageparams->startdate,

4
version.php

@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php /// This fragment is called by moodle_needs_upgrading() and /admin/index.php
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
$module->version = 2011053006; // The current module version (Date: YYYYMMDDXX) $module->version = 2011061800; // The current module version (Date: YYYYMMDDXX)
$module->release = '2.3.1'; $module->release = '2.4.0';
$module->cron = 0; // Period for cron to check this module (secs) $module->cron = 0; // Period for cron to check this module (secs)
?> ?>

Loading…
Cancel
Save