https://www.mediawiki.org/wiki/Special:Code/MediaWiki/109667
Revision: 109667
Author: jeroendedauw
Date: 2012-01-21 00:36:14 +0000 (Sat, 21 Jan 2012)
Log Message:
-----------
follow up to r109656 - renaming and added tables for online and campus
ambassadors
Modified Paths:
--------------
trunk/extensions/EducationProgram/EducationProgram.php
trunk/extensions/EducationProgram/includes/EPOrg.php
trunk/extensions/EducationProgram/sql/EducationProgram.sql
Modified: trunk/extensions/EducationProgram/EducationProgram.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.php 2012-01-21
00:11:12 UTC (rev 109666)
+++ trunk/extensions/EducationProgram/EducationProgram.php 2012-01-21
00:36:14 UTC (rev 109667)
@@ -148,7 +148,9 @@
$egEPDBObjects['EPMC'] = array( 'table' => 'ep_mcs', 'prefix' => 'mc_' );
$egEPDBObjects['EPCourse'] = array( 'table' => 'ep_courses', 'prefix' =>
'course_' );
$egEPDBObjects['EPStudent'] = array( 'table' => 'ep_students', 'prefix' =>
'student_' );
-$egEPDBObjects[] = array( 'table' => 'ep_students_per_term', 'prefix' =>
'spt_' );
+$egEPDBObjects['EPOA'] = array( 'table' => 'ep_oas', 'prefix' => 'oa_' );
+$egEPDBObjects['EPCA'] = array( 'table' => 'ep_cas', 'prefix' => 'ca_' );
+$egEPDBObjects[] = array( 'table' => 'ep_students_per_course', 'prefix' =>
'spc_' );
// API
$wgAPIModules['deleteeducation'] =
'ApiDeleteEducation';
@@ -198,7 +200,7 @@
// Compatibility with MediaWiki 1.18.
$wgLogNames['institution'] = 'log-name-institution';
$wgLogNames['course'] = 'log-name-course';
- $wgLogNames['term'] = 'log-name-mc';
+ $wgLogNames['mc'] = 'log-name-mc';
$wgLogNames['student'] = 'log-name-student';
$wgLogNames['ambassador'] = 'log-name-ambassador';
$wgLogNames['instructor'] = 'log-name-instructor';
@@ -206,7 +208,7 @@
// Compatibility with MediaWiki 1.18.
$wgLogHeaders['institution'] = 'log-header-institution';
$wgLogHeaders['course'] = 'log-header-course';
- $wgLogHeaders['term'] = 'log-header-mc';
+ $wgLogHeaders['mc'] = 'log-header-mc';
$wgLogHeaders['student'] = 'log-header-student';
$wgLogHeaders['ambassador'] = 'log-header-ambassador';
$wgLogHeaders['instructor'] = 'log-header-instructor';
Modified: trunk/extensions/EducationProgram/includes/EPOrg.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPOrg.php 2012-01-21
00:11:12 UTC (rev 109666)
+++ trunk/extensions/EducationProgram/includes/EPOrg.php 2012-01-21
00:36:14 UTC (rev 109667)
@@ -14,20 +14,20 @@
class EPOrg extends EPDBObject {
/**
- * Cached array of the linked EPCourse objects.
+ * Cached array of the linked EPMC objects.
*
* @since 0.1
* @var array|false
*/
- protected $courses = false;
+ protected $mcs = false;
/**
- * Cached array of the linked EPTerm objects.
+ * Cached array of the linked EPCourse objects.
*
* @since 0.1
* @var array|false
*/
- protected $terms = false;
+ protected $courses = false;
/**
* @see parent::getFieldTypes
@@ -46,7 +46,7 @@
'active' => 'bool',
'courses' => 'int',
- 'terms' => 'int',
+ 'mcs' => 'int',
'students' => 'int',
);
}
@@ -63,7 +63,7 @@
'active' => false,
'courses' => 0,
- 'terms' => 0,
+ 'mcs' => 0,
'students' => 0,
);
}
@@ -85,7 +85,7 @@
*/
public function loadSummaryFields( $summaryFields = null ) {
if ( is_null( $summaryFields ) ) {
- $summaryFields = array( 'courses', 'terms', 'students',
'active' );
+ $summaryFields = array( 'courses', 'mcs', 'students',
'active' );
}
else {
$summaryFields = (array)$summaryFields;
@@ -97,20 +97,20 @@
$fields['courses'] = EPCourse::count( array( 'org_id'
=> $this->getId() ) );
}
- if ( in_array( 'terms', $summaryFields ) ) {
- $fields['terms'] = EPTerm::count( array( 'org_id' =>
$this->getId() ) );
+ if ( in_array( 'mcs', $summaryFields ) ) {
+ $fields['mcs'] = EPMC::count( array( 'org_id' =>
$this->getId() ) );
}
$dbr = wfGetDB( DB_SLAVE );
if ( in_array( 'students', $summaryFields ) ) {
- $termIds = EPTerm::selectFields( 'id', array( 'org_id'
=> $this->getId() ) );
+ $courseIds = EPCourse::selectFields( 'id', array(
'org_id' => $this->getId() ) );
- if ( count( $termIds ) > 0 ) {
+ if ( count( $courseIds ) > 0 ) {
$fields['students'] = $dbr->select(
- 'ep_students_per_term',
+ 'ep_students_per_course',
'COUNT(*) AS rowcount',
- array( 'spt_term_id' => $termIds )
+ array( 'spc_course_id' => $courseIds )
);
$fields['students'] =
$fields['students']->fetchObject()->rowcount;
@@ -123,7 +123,7 @@
if ( in_array( 'active', $summaryFields ) ) {
$now = wfGetDB( DB_SLAVE )->addQuotes( wfTimestampNow()
);
- $fields['active'] = EPTerm::has( array(
+ $fields['active'] = EPCourse::has( array(
'org_id' => $this->getId(),
'end >= ' . $now,
'start <= ' . $now,
@@ -144,10 +144,10 @@
$success = parent::removeFromDB();
if ( $success ) {
- $success = wfGetDB( DB_MASTER )->delete(
'ep_mentors_per_org', array( 'mpo_org_id' => $id ) ) && $success;
+ $success = wfGetDB( DB_MASTER )->delete(
'ep_cas_per_org', array( 'cpo_org_id' => $id ) ) && $success;
- foreach ( EPCourse::select( 'id', array( 'org_id' =>
$id ) ) as /* EPCourse */ $course ) {
- $success = $course->removeFromDB() && $success;
+ foreach ( EPMC::select( 'id', array( 'org_id' => $id )
) as /* EPMC */ $masterCourse ) {
+ $success = $masterCourse->removeFromDB() &&
$success;
}
}
@@ -257,37 +257,37 @@
}
/**
- * Retruns the courses linked to this org.
+ * Retruns the master courses linked to this org.
*
* @since 0.1
*
* @param array|null $fields
*
- * @return array of EPCourse
+ * @return array of EPMC
*/
- public function getCourses( array $fields = null ) {
- if ( $this->courses === false ) {
- $this->courses = EPCourse::select( $fields, array(
'org_id' => $this->getId() ) );
+ public function getMasterCourses( array $fields = null ) {
+ if ( $this->mcs === false ) {
+ $this->mcs = EPMC::select( $fields, array( 'org_id' =>
$this->getId() ) );
}
- return $this->courses;
+ return $this->mcs;
}
/**
- * Retruns the terms linked to this org.
+ * Retruns the courses linked to this org.
*
* @since 0.1
*
* @param array|null $fields
*
- * @return array of EPTerm
+ * @return array of EPCourse
*/
- public function getTerms( array $fields = null ) {
- if ( $this->terms === false ) {
- $this->terms = EPTerm::select( $fields, array( 'org_id'
=> $this->getId() ) );
+ public function getCourses( array $fields = null ) {
+ if ( $this->courses === false ) {
+ $this->courses = EPCourse::select( $fields, array(
'org_id' => $this->getId() ) );
}
- return $this->terms;
+ return $this->courses;
}
/**
Modified: trunk/extensions/EducationProgram/sql/EducationProgram.sql
===================================================================
--- trunk/extensions/EducationProgram/sql/EducationProgram.sql 2012-01-21
00:11:12 UTC (rev 109666)
+++ trunk/extensions/EducationProgram/sql/EducationProgram.sql 2012-01-21
00:36:14 UTC (rev 109667)
@@ -12,7 +12,7 @@
org_active TINYINT unsigned NOT NULL, -- If the org has
any active terms
org_courses SMALLINT unsigned NOT NULL, -- Amount of courses
- org_terms SMALLINT unsigned NOT NULL, -- Amount of terms
+ org_mcs SMALLINT unsigned NOT NULL, -- Amount of master
courses
org_students INT unsigned NOT NULL -- Amount of students
) /*$wgDBTableOptions*/;
@@ -22,6 +22,8 @@
CREATE INDEX /*i*/ep_org_students ON /*_*/ep_orgs (org_students);
CREATE INDEX /*i*/ep_org_active ON /*_*/ep_orgs (org_active);
+
+
-- Master courses. These describe a specific course, time-independent.
CREATE TABLE IF NOT EXISTS /*_*/ep_mcs (
mc_id INT unsigned NOT NULL auto_increment
PRIMARY KEY,
@@ -42,6 +44,8 @@
CREATE INDEX /*i*/ep_mc_students ON /*_*/ep_mcs (mc_students);
CREATE INDEX /*i*/ep_mc_active ON /*_*/ep_mcs (mc_active);
+
+
-- Courses. These are "instances" of a master course in a certain period.
CREATE TABLE IF NOT EXISTS /*_*/ep_courses (
course_id INT unsigned NOT NULL auto_increment
PRIMARY KEY,
@@ -65,6 +69,8 @@
CREATE UNIQUE INDEX /*i*/ep_trem_period ON /*_*/ep_courses (course_org_id,
course_start, course_end);
CREATE INDEX /*i*/ep_course_students ON /*_*/ep_courses (course_students);
+
+
-- Students. In essence this is an extension to the user table.
CREATE TABLE IF NOT EXISTS /*_*/ep_students (
student_id INT unsigned NOT NULL auto_increment
PRIMARY KEY,
@@ -81,15 +87,7 @@
CREATE INDEX /*i*/ep_students_last_active ON /*_*/ep_students
(student_last_active);
CREATE INDEX /*i*/ep_students_active_enroll ON /*_*/ep_students
(student_active_enroll);
--- Mentors. In essence this is an extension to the user table.
-CREATE TABLE IF NOT EXISTS /*_*/ep_mentors (
- mentor_id INT unsigned NOT NULL auto_increment
PRIMARY KEY,
- mentor_user_id INT unsigned NOT NULL -- Foreign key on
user.user_id
-) /*$wgDBTableOptions*/;
-
-CREATE UNIQUE INDEX /*i*/ep_mentors_user_id ON /*_*/ep_mentors
(mentor_user_id);
-
--- Links the courses with all their students.
+-- Links the students with their courses.
CREATE TABLE IF NOT EXISTS /*_*/ep_students_per_course (
spc_student_id INT unsigned NOT NULL, -- Foreign key on
ep_students.student_id
spc_course_id INT unsigned NOT NULL -- Foreign key on
ep_courses.course_id
@@ -97,6 +95,26 @@
CREATE UNIQUE INDEX /*i*/ep_students_per_course ON /*_*/ep_students_per_course
(spc_student_id, spc_course_id);
+
+
+-- Instructors. In essence this is an extension to the user table.
+CREATE TABLE IF NOT EXISTS /*_*/ep_instructors (
+ instructor_id INT unsigned NOT NULL auto_increment
PRIMARY KEY,
+ instructor_user_id INT unsigned NOT NULL -- Foreign key on
user.user_id
+) /*$wgDBTableOptions*/;
+
+CREATE UNIQUE INDEX /*i*/ep_instructors_user_id ON /*_*/ep_instructors
(instructor_user_id);
+
+
+
+-- Campus ambassadors. In essence this is an extension to the user table.
+CREATE TABLE IF NOT EXISTS /*_*/ep_cas (
+ ca_id INT unsigned NOT NULL auto_increment
PRIMARY KEY,
+ ca_user_id INT unsigned NOT NULL -- Foreign key on
user.user_id
+) /*$wgDBTableOptions*/;
+
+CREATE UNIQUE INDEX /*i*/ep_cas_user_id ON /*_*/ep_cas (ca_user_id);
+
-- Links the campus ambassadors with all their orgs.
CREATE TABLE IF NOT EXISTS /*_*/ep_cas_per_org (
cpo_ca_id INT unsigned NOT NULL, -- Foreign key on
ep_cas.ca_id
@@ -105,6 +123,18 @@
CREATE UNIQUE INDEX /*i*/ep_cas_per_org ON /*_*/ep_cas_per_org (cpo_ca_id,
cpo_org_id);
+
+
+-- Online ambassadors. In essence this is an extension to the user table.
+CREATE TABLE IF NOT EXISTS /*_*/ep_oas (
+ oa_id INT unsigned NOT NULL auto_increment
PRIMARY KEY,
+ oa_user_id INT unsigned NOT NULL -- Foreign key on
user.user_id
+) /*$wgDBTableOptions*/;
+
+CREATE UNIQUE INDEX /*i*/ep_oas_user_id ON /*_*/ep_oas (oa_user_id);
+
+
+
-- Revision table, holding blobs of various types of objects, such as orgs or
students.
-- This is somewhat based on the (core) revision table and is meant to serve
-- as a prototype for a more general system to store this kind of data in a
versioned fashion.
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs