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
## Install
apt install php-pgsql
apt install php-xml
apt install php php-pgsql php-xml
## Connexion
cp lib/connexion-sample.php lib/connexion.php
......@@ -6,16 +6,16 @@ su postgres
pg_dump apisub -f /home/stc/apidump/apisub20200929.sql
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
- Vider la table student
- Vider la table student
- Ré-insérer les données à jour dans la table student
```
DELETE FROM student;
......
......@@ -11,4 +11,4 @@ See INSTALL & MAJ
### `TABLE config`
- 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 {
}
public function activeSemester() {
return 'H';
return $this->db->config()['semester'];;
}
public function activeYear() {
return 2021;
return $this->db->config()['year'];;
}
}
......@@ -22,6 +22,8 @@ CREATE OR REPLACE VIEW vconfig AS
SELECT
TO_CHAR(openbegin,'TMday FMDD TMmonth FMYYYY') AS openbegin,
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
FROM config;
......
......@@ -84,11 +84,11 @@ DECLARE
m INTEGER;
BEGIN
m = DATE_PART('month', $1);
/* Winter intersemester is either january or february or march */
IF m = 1 OR m = 2 OR m = 3 THEN
/* Winter intersemester inscriptions begin in september and Api end in february */
IF m >= 9 OR m <= 2 THEN
RETURN 'H';
/* Summer intersemester is either june or july or august or september */
ELSIF m = 6 OR m = 7 OR m = 8 OR m = 9 THEN
/* Summer intersemester inscriptions begin in march and Api end in august */
ELSIF m >= 3 OR m <= 8 THEN
RETURN 'E';
ELSE
RETURN 'X';
......
......@@ -28,7 +28,7 @@ COMMIT;
INSERT INTO api (id,dbegin,code,name,description,duration,size,ects,resplogin) VALUES (
gen_random_uuid(),
TO_DATE('01/01/2020','DD/MM/YYYY'),
'code',
code,
'title,
'longtitle',
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