Commit 633d9777 authored by GROSS-AMBLARD David's avatar GROSS-AMBLARD David
Browse files

Adds a note on coding styles

Creates a pages directory where all the pages code will go
Moving the skill page into it
parent 969295c6
......@@ -6,7 +6,7 @@
* table names start with an uppercase
* each page should have its own directory, which name is the mode
* Mode X
* Directory X
* Directory pages X
* file X.php
* in it, a X function, taking $conn as input
*
\ No newline at end of file
......@@ -25,7 +25,7 @@ require("lib/HWlib.php");
require("lib/HTML.php");
require("lib/artifacts.php");
require("profile.php");
require("skills.php");
require("pages/skills/skills.php");
require("tasks.php");
require("actions.php");
require("connection.php");
......@@ -80,7 +80,7 @@ switch ($mode) {
saveProfile($conn);
break;
case "skills":
showSkills($conn);
skills($conn);
break;
case "addSkill":
addSkill($conn);
......
......@@ -3,7 +3,7 @@
/**
* showSkillsDeprecated
* showSkillsRec
*
* Show the skill tree and the form to pick up a skill and select an associated level
*
......@@ -43,7 +43,15 @@ function showSkillsRec($conn,$skill,$level,$skillid,$userid,$parentid=0){
}
}
function showSkills($conn){
/**
* skills
*
* Show the skill tree and the form to pick up a skill and select an associated level
*
* @param $conn: A valid database PDO connection
*/
function skills($conn){
global $VIEW;
$VIEW['MAIN'].=HTMLh1("Manage you skills");
......@@ -72,22 +80,10 @@ for (i = 0; i < slider.length; i++) {
if (parent!=null){
var currentValue=parseInt(this.value);
var parentValue=parseInt(parent.value);
//console.log("parent "+parentValue+" < this "+currentValue+"?"+(parentValue<currentValue));
// if(parentValue<currentValue){
// window.alert("You can not be less expert in "+parent.name+" than in "+this.name+". Please increase "+parent.name+" first.");
// this.value=0;
// this.click();
//}
//else {
console.log("index.php?mode=addSkill&submit="+this.id+"&level="+this.value);
var client = new XMLHttpRequest();
client.open('GET', "index.php?mode=addSkill&submit="+this.id+"&level="+this.value);
client.send();
// if one wants to change dynamically the parent
//parent.value=Math.max(this.value,parent.value);
//parent.click();
}
});
}
......@@ -96,84 +92,7 @@ for (i = 0; i < slider.length; i++) {
EOL;
}
/**
* showSkillsDeprecated
*
* Show the skill tree and the form to pick up a skill and select a level associate
*
* @param $conn : A valid database PDO connection
*/
function showSkillsDeprecated($conn){
global $VIEW;
$stmt = $conn->prepare("select skill,level from skills inner join skillTree ON skills.idskill = skillTree.id where iduser = :id ORDER BY level DESC");
$stmt->bindParam(':id', $_SESSION["id"], PDO::PARAM_STR);
$stmt->execute();
$query="select st.skill,s.level from skillTree st join skills as s on st.id=s.idskill where s.iduser=:id";
$stmt2 = $conn->prepare($query);
$stmt2->bindParam(':id', $_SESSION["id"], PDO::PARAM_STR);
$stmt2->execute();
$stmt2->setFetchMode(PDO::FETCH_ASSOC);
$line = array();
while($tmp=$stmt2->fetch()){
$line = array_merge_recursive($line, $tmp);
}
$VIEW['MAIN'].= HTMLtag("div",array("class"=>"row"))
.HTMLtag("div",array("class"=>"col-lg-3","style"=>"margin-top:10%;margin-left:2%"))
.HTMLtag("div",array("class"=>"row"))
."1. Select a level"
.HTMLclosingtag("div")
.HTMLtag("div",array("class"=>"row"))
.HTMLtag("div",array("class"=>"col-lg-2"))
."Beginner"
.HTMLclosingtag("div")
.HTMLtag("div",array("class"=>"col-lg-offset-3 col-lg-2"))
."Confirmed"
.HTMLclosingtag("div")
.HTMLtag("div",array("class"=>"col-lg-offset-3 col-lg-2"))
."Expert"
.HTMLclosingtag("div")
.HTMLclosingtag ("div").
HTMLtag("div",array("class"=>"row")).HTMLtag("input",array("type"=>"range","class"=>"slider","id"=>"level","name"=>"level","min"=>"0","max"=>"100","value"=>"50")).HTMLclosingtag("div").
HTMLtag("div",array("class"=>"row")).HTMLtag("div",array("class"=>"col-lg-offset-5 col-lg-2 col-lg-offset-5")).HTMLtag("p",array("id"=>"value")).HTMLclosingtag("p").HTMLclosingtag("div").HTMLclosingtag("div").
HTMLtag("p",array("id"=>"limit")).HTMLclosingtag("p").HTMLclosingtag("div").
HTMLtag("div",array("class"=>"col-lg-6")).HTMLtag("div",array("class"=>"row"))."<p>2. Apply it</p>".HTMLclosingtag("div")."<div id=\"tree\"></div><script type=\"text/javascript\">var list =".json_encode($line)."; var type=\"skill\";</script>
<script type=\"text/javascript\" src=\"skillTree.js\"></script>".HTMLclosingtag("div").
HTMLtag("div",array("class"=>"col-lg-2","style"=>"margin-top:5%"));
$header=HTMLtr(array(HTMLth("Skill"),HTMLth("Level")));
$table="";
foreach($stmt as $row){
$table.=HTMLtr(array(HTMLtd($row['skill']),HTMLtd($row['level'])));
}
$VIEW['MAIN'].=HTMLtable(array($header,$table),array("class"=>"table table-striped table-bordered table-hover")).HTMLform("index.php?mode=skills","POST",
HTMLbr().
HTMLinput("hidden","mode","saveSkill",null,false,"")
//HTMLinput("submit", "submit", "Launch skyline",null,false,"")
).HTMLbr();
/*
if($_SESSION["username"]=="admin"){
$VIEW['MAIN'].=HTMLform("index.php?mode=skills","POST",
HTMLinput("hidden","mode","generateJson",null,false,"").
HTMLinput("submit", "submit", "Re-generate taxonomy",null,false,"")
);
}
*/
$VIEW['MAIN'].=HTMLclosingtag("div").
//HTMLinput("hidden","mode","saveSkill",null,false).HTMLinput("submit","submit","Validate",null,false).
//HTMLclosingtag("form").
HTMLbr()."<script>
var slider = document.getElementById(\"level\");
var output = document.getElementById(\"value\");
output.innerHTML = slider.value; // Display the default slider value
// Update the current slider value (each time you drag the slider handle)
slider.oninput = function() {
output.innerHTML = this.value;
}
</script>".HTMLclosingtag("div");
}
/**
* addSkill
*
......@@ -274,20 +193,5 @@ EOL;
return $res;
}
/**
* execInBackground
*
* Launch the skyline algorithm in background
*
* @param $cmd : Command to launch the Skyline
*/
function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");// A modifier pour MAC OS
}
}
?>
\ No newline at end of file
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