An XML file manage courses list
This commit is contained in:
parent
e86deee36e
commit
6e9554e2f2
134
Course.class.php
Normal file
134
Course.class.php
Normal file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
class Course
|
||||
{
|
||||
private $id;
|
||||
private $name;
|
||||
private $code;
|
||||
private $branch;
|
||||
private $registerdate;
|
||||
private $validated = false;
|
||||
|
||||
public function __construct($node = null)
|
||||
{
|
||||
if (isset($node))
|
||||
{
|
||||
$this->id = $node->getAttribute("xml:id");
|
||||
$this->registerdate = $node->getAttribute("registerdate");
|
||||
if (intval($node->getAttribute("validated")))
|
||||
$this->validated = true;
|
||||
$this->name = $node->getAttribute("name");
|
||||
$this->code = $node->getAttribute("code");
|
||||
$this->branch = $node->getAttribute("branch");
|
||||
}
|
||||
}
|
||||
|
||||
public static function new_Course($name, $code, $branch = "")
|
||||
{
|
||||
$c = new Course();
|
||||
$c->id = sha1($code);
|
||||
$c->registerdate = time();
|
||||
$c->name = $name;
|
||||
$c->code = $code;
|
||||
$c->branch = $branch;
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
public static function getCourses($filename = "courses.xml")
|
||||
{
|
||||
$courses = array();
|
||||
$treeXML = new DOMDocument('1.0', 'UTF-8');
|
||||
|
||||
if (@$treeXML->load($filename))
|
||||
{
|
||||
$nodes = $treeXML->getElementsByTagName("course");
|
||||
foreach($nodes as $node)
|
||||
{
|
||||
$c = new Course($node);
|
||||
$courses[$c->id] = $c;
|
||||
}
|
||||
}
|
||||
|
||||
return $courses;
|
||||
}
|
||||
|
||||
public static function setCourses($courses, $filename = "courses.xml")
|
||||
{
|
||||
$treeXML = new DOMDocument('1.0', 'UTF-8');
|
||||
$root_node = $treeXML->createElement("users");
|
||||
$treeXML->appendChild($root_node);
|
||||
|
||||
foreach ($courses as $course)
|
||||
$root_node->appendChild($course->to_xml($treeXML));
|
||||
|
||||
$treeXML->formatOutput = true;
|
||||
$treeXML->save($filename);
|
||||
}
|
||||
|
||||
public function to_xml($root)
|
||||
{
|
||||
$qnode = $root->createElement("course");
|
||||
|
||||
$qnode->setAttribute("xml:id", $this->id);
|
||||
$qnode->setAttribute("name", $this->name);
|
||||
$qnode->setAttribute("code", intval($this->code));
|
||||
$qnode->setAttribute("branch", $this->branch);
|
||||
$qnode->setAttribute("registerdate", $this->registerdate);
|
||||
$qnode->setAttribute("validated", $this->validated);
|
||||
|
||||
return $qnode;
|
||||
}
|
||||
|
||||
public function set_validated($validated)
|
||||
{
|
||||
$this->validated = $validated;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function isValidated()
|
||||
{
|
||||
return $this->validated;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
$cs = Course::getCourses();
|
||||
|
||||
foreach($cs as $c)
|
||||
$c->set_validated(true);
|
||||
Course::setCourses($cs);
|
||||
//*/
|
||||
/*
|
||||
$cs = Course::getCourses();
|
||||
|
||||
$c = Course::new_Course("Base de donnees", "RELA");
|
||||
$cs[] = $c;
|
||||
|
||||
$c = Course::new_Course("Compression de donnee", "CODO");
|
||||
$cs[] = $c;
|
||||
|
||||
$c = Course::new_Course("Protocole de liaisons", "PROLI");
|
||||
$cs[] = $c;
|
||||
|
||||
$c = Course::new_Course("Typologie des langages", "TYLA", "TDA;SRC");
|
||||
$cs[] = $c;
|
||||
|
||||
$c = Course::new_Course("Active directory", "ACDI");
|
||||
$cs[] = $c;
|
||||
|
||||
$c = Course::new_Course("Graphes reseaux flots", "GRF");
|
||||
$cs[] = $c;
|
||||
|
||||
Course::setCourses($cs);
|
||||
//*/
|
||||
?>
|
46
index.php
46
index.php
@ -119,48 +119,24 @@
|
||||
<img src="left_triangle2.gif" id="arrow" alt="<">
|
||||
<h3>Quelques détails</h3>
|
||||
<p>
|
||||
Le champ "De quelle matière s'agit-il ?" n'est là qu'a titre
|
||||
indicatif. Il va permettre à la personne qui valide votre question
|
||||
d'aller vérifier par lui même la véracité de votre réponse.
|
||||
Ce champ est là à titre indicatif. Il va permettre à la personne
|
||||
qui valide votre question d'aller vérifier par lui même la
|
||||
véracité de votre réponse ; et il permet également de filtrer
|
||||
les questions en fonction des matière que chacun souhaite réviser.
|
||||
</p>
|
||||
</aside>
|
||||
|
||||
<article id="list">
|
||||
<label for="course">De quelle matière s'agit-il ?</label><br>
|
||||
|
||||
<select name="course" id="course">
|
||||
<optgroup label="Cours communs">
|
||||
<option value="SGBD">SGBD</option>
|
||||
<option value="CompressionDeDonnées">
|
||||
Compression de données</option>
|
||||
<option value="ProtocolesDeLiaisons">
|
||||
Protocoles De Liaisons</option>
|
||||
<option value="TYLA">TYLA</option>
|
||||
<option value="ActiveDirectory">
|
||||
Active Directory</option>
|
||||
<option value="GrapheFlotReseau">
|
||||
Graphes Flots Reseaux</option>
|
||||
</optgroup>
|
||||
<?php
|
||||
include("Course.class.php");
|
||||
$cs = Course::getCourses();
|
||||
|
||||
<optgroup label="Electif">
|
||||
<option value="RXAN">RXAN</option>
|
||||
</optgroup>
|
||||
foreach($cs as $c)
|
||||
print '<option value="'.$c->getId().'">'.$c->getName().'</option>';
|
||||
|
||||
<optgroup label="TDA">
|
||||
<option value="TYLA">TYLA</option>
|
||||
<option value="CCMP">CCMP</option>
|
||||
<option value="SLPS">SLPS</option>
|
||||
<option value="FMPS">FMPS</option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="MTM">
|
||||
<option value="ITIL">ITIL</option>
|
||||
<option value="Qualite">Qualité</option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="Autre">
|
||||
<option value="Autre" selected>Autre</option>
|
||||
</optgroup>
|
||||
?>
|
||||
</select>
|
||||
</article>
|
||||
|
||||
@ -191,7 +167,7 @@
|
||||
onclick="add()"/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="email">Merci d'indiquer votre email</label><br/>
|
||||
<label for="email">Merci d'indiquer votre adresse électronique :</label><br/>
|
||||
<input id="email" name="email" type="text" />
|
||||
</p>
|
||||
<p>
|
||||
|
Reference in New Issue
Block a user