update lessons + correct_lessons [todo] update location + correct_location
This commit is contained in:
parent
adb2fee18e
commit
cf15f3af1e
|
@ -50,7 +50,7 @@
|
|||
|
||||
|
||||
|
||||
public function info(){
|
||||
public function lessons(){
|
||||
|
||||
/* [1] Get database data
|
||||
=========================================================*/
|
||||
|
@ -65,7 +65,8 @@
|
|||
|
||||
|
||||
|
||||
echo "<form method='POST' action='/correct/".$this->diplome_id."'>";
|
||||
echo "<form method='POST' action='/xlessons/".$this->diplome_id."'>";
|
||||
echo "<table><thead style='font-weight: bold;'><tr><td>Read name</td><td>Correction</td></tr></thead><tbody>";
|
||||
|
||||
foreach($d_cols as $data){
|
||||
|
||||
|
@ -74,18 +75,22 @@
|
|||
$color = $data['color'];
|
||||
$name = $data['name'];
|
||||
|
||||
echo "$basename <input type='text' style='display: inline-block; margin: 1em .2em; padding: .2em; border: none; background-color: $color;' name='name[$id]' value='$name'><br>";
|
||||
echo "<tr><td>$basename</td><td><input type='text' style='display: inline-block; margin: 1em .2em; padding: .2em; border: none; background-color: $color;' name='name[$id]' value='$name'></td></tr>";
|
||||
|
||||
}
|
||||
echo "</tbody></table>";
|
||||
|
||||
echo "<input type='submit' value='SAVE'>";
|
||||
|
||||
echo "</form>";
|
||||
|
||||
}
|
||||
|
||||
// todo
|
||||
public function location(){}
|
||||
|
||||
|
||||
public function correct(){
|
||||
public function correct_lessons(){
|
||||
|
||||
|
||||
/* [1] Update data
|
||||
|
@ -114,7 +119,7 @@
|
|||
/* [2] Update file one the fly
|
||||
=========================================================*/
|
||||
/* (1) Get corrections */
|
||||
$sqlr = DatabaseDriver::getPDO()->prepare("SELECT CONCAT(basename, color) as uid, name FROM event WHERE id_diplome = :idd");
|
||||
$sqlr = DatabaseDriver::getPDO()->prepare("SELECT id_event, name FROM event WHERE id_diplome = :idd");
|
||||
$sqlr->execute([ ':idd' => $this->diplome_id ]);
|
||||
|
||||
/* (2) Manage error */
|
||||
|
@ -125,7 +130,7 @@
|
|||
$corrections = [];
|
||||
|
||||
foreach($fetched as $c)
|
||||
$corrections[$c['uid']] = $c['name'];
|
||||
$corrections[$c['id_event']] = $c['name'];
|
||||
|
||||
|
||||
/* (3) Get file pointer */
|
||||
|
@ -142,7 +147,7 @@
|
|||
for( $l = 0 ; $l < count($line)-1 ; $l++ ){
|
||||
|
||||
// {1} If got the right pointer //
|
||||
if( preg_match('@^DESCRIPTION:(.+#[\da-f]{6})$@', $line[$l], $m) ){
|
||||
if( preg_match('@^DESCRIPTION:event\@(\d+)$@', $line[$l], $m) ){
|
||||
|
||||
// {2} If is in the list of correction //
|
||||
if( !isset($corrections[$m[1]]) )
|
||||
|
@ -162,6 +167,9 @@
|
|||
header('Location: /');
|
||||
}
|
||||
|
||||
// todo
|
||||
public function correct_location(){}
|
||||
|
||||
/* POST-CALL
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -41,24 +41,35 @@
|
|||
|
||||
/* [2] Display the links
|
||||
=========================================================*/
|
||||
echo "<table><thead><tr><td>Diplome</td><td>Config</td><td>Link</td><td>Last Update</td></tr></thead><tbody>";
|
||||
echo "<table><thead style='font-weight: bold;'><tr><td>Diplome</td><td>Lessons' name</td><td>Location</td><td>Link</td><td>Last Update</td></tr></thead><tbody>";
|
||||
|
||||
foreach($diplomes as $id=>$data){
|
||||
|
||||
$name = $data[0];
|
||||
$upda = $data[1];
|
||||
|
||||
echo "<tr><td>$name</td>";
|
||||
|
||||
$URI = $_SERVER['REQUEST_URI'];
|
||||
$url = $_SERVER['HTTP_HOST'].$URI."ics/$id.ics";
|
||||
$link = __ROOT__."/tmp/$id.ics";
|
||||
echo "<td><a href='/info/$id'>Correct</a></td>";
|
||||
|
||||
// name
|
||||
echo "<tr><td>$name</td>";
|
||||
|
||||
// link to correct lessons
|
||||
echo "<td><a href='/lessons/$id'>Correct</a></td>";
|
||||
echo "<td><a";
|
||||
if( file_exists($link) )
|
||||
echo " href='/ics/$id.ics'";
|
||||
|
||||
// link to correct location
|
||||
echo "<td><a href='/location/$id'>Correct</a></td>";
|
||||
echo "<td><a";
|
||||
if( file_exists($link) )
|
||||
echo " href='/ics/$id.ics'";
|
||||
|
||||
// link to .ics
|
||||
echo ">https://$url</a></td>";
|
||||
|
||||
// update date
|
||||
echo "<td>$upda</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
|
|
|
@ -20,17 +20,33 @@
|
|||
}
|
||||
},
|
||||
|
||||
"/info/{diplome_id}": {
|
||||
"/location/{diplome_id}": {
|
||||
"methods": ["GET"],
|
||||
"controller": "ics:info",
|
||||
"controller": "ics:location",
|
||||
"arguments": {
|
||||
"diplome_id": "T\\d+"
|
||||
}
|
||||
},
|
||||
|
||||
"/correct/{diplome_id}": {
|
||||
"/lessons/{diplome_id}": {
|
||||
"methods": ["GET"],
|
||||
"controller": "ics:lessons",
|
||||
"arguments": {
|
||||
"diplome_id": "T\\d+"
|
||||
}
|
||||
},
|
||||
|
||||
"/xlessons/{diplome_id}": {
|
||||
"methods": ["POST"],
|
||||
"controller": "ics:correct",
|
||||
"controller": "ics:correct_lessons",
|
||||
"arguments": {
|
||||
"diplome_id": "T\\d+"
|
||||
}
|
||||
},
|
||||
|
||||
"/xlocation/{diplome_id}": {
|
||||
"methods": ["POST"],
|
||||
"controller": "ics:correct_location",
|
||||
"arguments": {
|
||||
"diplome_id": "T\\d+"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue