Commit db7b5d2e authored by stph's avatar stph
Browse files

Implement admin functions activeSemester and Year

parent 5431b78e
...@@ -38,8 +38,7 @@ psql -h localhost -U apisub -d apisub ...@@ -38,8 +38,7 @@ psql -h localhost -U apisub -d apisub
## Install ## Install
apt install php-pgsql apt install php php-pgsql php-xml
apt install php-xml
## Connexion ## Connexion
cp lib/connexion-sample.php lib/connexion.php cp lib/connexion-sample.php lib/connexion.php
...@@ -6,16 +6,16 @@ su postgres ...@@ -6,16 +6,16 @@ su postgres
pg_dump apisub -f /home/stc/apidump/apisub20200929.sql pg_dump apisub -f /home/stc/apidump/apisub20200929.sql
scp stc@pic.crzt.fr:/home/stc/apidump/* . scp stc@pic.crzt.fr:/home/stc/apidump/* .
## Mise à jour des dates ## Mise à jour des dates d'inscription
``` ```
UPDATE config SET closed='f', openbegin='2020-10-20', openend='2020-12-18'; UPDATE config SET closed='f', openbegin='2021-01-08', openend='2021-06-04';
``` ```
## Niveau des étudiants ## Niveau des étudiants
- Vider la table student - Vider la table student
- Ré-insérer les données à jour dans la table student - Ré-insérer les données à jour dans la table student
``` ```
DELETE FROM student; DELETE FROM student;
......
...@@ -11,4 +11,4 @@ See INSTALL & MAJ ...@@ -11,4 +11,4 @@ See INSTALL & MAJ
### `TABLE config` ### `TABLE config`
- Set `closed` to `TRUE` to disable subscription (and unsubscription) - Set `closed` to `TRUE` to disable subscription (and unsubscription)
- Set `closed` to `FALSE` to enable subscription (and unsubscription) and set openbegin and openend to intersemester dates. - Set `closed` to `FALSE` to enable subscription (and unsubscription) and set openbegin and openend to inscription dates.
...@@ -13,11 +13,11 @@ class Admin { ...@@ -13,11 +13,11 @@ class Admin {
} }
public function activeSemester() { public function activeSemester() {
return 'H'; return $this->db->config()['semester'];;
} }
public function activeYear() { public function activeYear() {
return 2021; return $this->db->config()['year'];;
} }
} }
...@@ -22,6 +22,8 @@ CREATE OR REPLACE VIEW vconfig AS ...@@ -22,6 +22,8 @@ CREATE OR REPLACE VIEW vconfig AS
SELECT SELECT
TO_CHAR(openbegin,'TMday FMDD TMmonth FMYYYY') AS openbegin, TO_CHAR(openbegin,'TMday FMDD TMmonth FMYYYY') AS openbegin,
TO_CHAR(openend,'TMday FMDD TMmonth FMYYYY') AS openend, TO_CHAR(openend,'TMday FMDD TMmonth FMYYYY') AS openend,
semester(openend) AS semester,
DATE_PART('year', openend) AS year,
NOT(closed) AND CURRENT_DATE >= openbegin AND CURRENT_DATE <= openend AS isactive NOT(closed) AND CURRENT_DATE >= openbegin AND CURRENT_DATE <= openend AS isactive
FROM config; FROM config;
......
...@@ -84,11 +84,11 @@ DECLARE ...@@ -84,11 +84,11 @@ DECLARE
m INTEGER; m INTEGER;
BEGIN BEGIN
m = DATE_PART('month', $1); m = DATE_PART('month', $1);
/* Winter intersemester is either january or february or march */ /* Winter intersemester inscriptions begin in september and Api end in february */
IF m = 1 OR m = 2 OR m = 3 THEN IF m >= 9 OR m <= 2 THEN
RETURN 'H'; RETURN 'H';
/* Summer intersemester is either june or july or august or september */ /* Summer intersemester inscriptions begin in march and Api end in august */
ELSIF m = 6 OR m = 7 OR m = 8 OR m = 9 THEN ELSIF m >= 3 OR m <= 8 THEN
RETURN 'E'; RETURN 'E';
ELSE ELSE
RETURN 'X'; RETURN 'X';
......
...@@ -28,7 +28,7 @@ COMMIT; ...@@ -28,7 +28,7 @@ COMMIT;
INSERT INTO api (id,dbegin,code,name,description,duration,size,ects,resplogin) VALUES ( INSERT INTO api (id,dbegin,code,name,description,duration,size,ects,resplogin) VALUES (
gen_random_uuid(), gen_random_uuid(),
TO_DATE('01/01/2020','DD/MM/YYYY'), TO_DATE('01/01/2020','DD/MM/YYYY'),
'code', code,
'title, 'title,
'longtitle', 'longtitle',
duration, duration,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment