commit e18a2966015da29d31579b32ff2b33ad2b5ebfbe
parent 43c26d2b13863a6917c80362a082508de70ae8ca
Author: Yoann <yoann.b87@voila.fr>
Date: Mon, 21 Mar 2011 12:52:28 +0100
Merge branch 'temp' into unstable
Diffstat:
5 files changed, 86 insertions(+), 41 deletions(-)
diff --git a/code/serveur/php/createGame.php b/code/serveur/php/createGame.php
@@ -7,6 +7,7 @@ session_start();
$state = 0;
$err = false;
$msg = "";
+$rels = array();
function getWords($nbwords)
{
@@ -57,6 +58,12 @@ function checked($name, $value) {
}
function probaOf($relation, $relation2) {
+ if (($relation == "r1" && $relation2 == 0)
+ || ($relation == "r2" && $relation2 == 1)
+ || ($relation == "r0" && $relation2 == 2)
+ || ($relation == "trash" && $relation2 == 3))
+ return 1;
+
return 0;
}
@@ -75,49 +82,72 @@ if(isset($_POST['nbcloudwords'])) {
if($state == 1 && isset($_POST['centralword']) && !empty($_POST['centralword'])) {
if($_POST['relation1'] != $_POST['relation2']) {
$centralword = $_POST['centralword'];
- $rels[0] = $relations[$_POST['relation1']][1];
- $rels[1] = $relations[$_POST['relation2']][1];
- $rels[2] = "Est en rapport avec";
- $rels[3] = "N'a aucun rapport avec";
+ $rels[0] = $stringRelations[$_POST['relation1']];
+ $rels[1] = $stringRelations[$_POST['relation2']];
+ $rels[2] = $stringRelations[0];
+ $rels[3] = $stringRelations[-1];
$words = getWords($nbwords);
if($err != true)
$state = 2;
+ else {
+ $err = true;
+ $msg = $strings['err_creategame_cloud_fill_all'];
+ }
+
}
else {
$err = true;
$msg = $strings['err_creategame_eq_relations'];
}
}
+ elseif (isset($_POST['centralword']) && empty($_POST['centralword'])) {
+ $err = true;
+ $msg = $strings['err_creategame_cloud_fill_all'];
+ }
if($state == 2) {
$respwords = getWordsAndResponses($nbwords);
- $r1 = $stringRelations[$_POST['relation1']];
- $r2 = $stringRelations[$_POST['relation2']];
+ $r1 = $_POST['relation1'];
+ $r2 = $_POST['relation2'];
$cloud = array();
$totalDifficulty = 0;
+ $addedWords = 0;
+
+ if($respwords != -1 && isset($_POST['tDifficulty'])) {
+ if(is_numeric($totalDifficulty = $_POST['tDifficulty'])) {
+
+ if(insertNode($centralword))
+ $addedWords++;
+
+ $centralword = getNodeEid($centralword);
- insertNode($centralword);
- $centralword = getNodeEid($centralword);
+ foreach($respwords as $key=>$rw) {
+ $difficulty = $totalDifficulty / count($respwords);
- if($respwords != -1) {
- foreach($respwords as $key=>$rw) {
- insertNode($respwords[$key][0]);
- $cloud[$key] = array('pos'=>$key, 'd'=>1, 'eid'=>getNodeEid($respwords[$key][0]),
- 'probaR1'=> probaOf("r1", $rw[1]),
- 'probaR2'=> probaOf('r2', $rw[1]),
- 'probaR0'=> probaOf('r0', $rw[1]),
- 'probaTrash'=> probaOf('trash', $rw[1]));
+ if(insertNode($respwords[$key][0]))
+ $addedWords++;
- $totalDifficulty += 1;
+ $cloud[$key] = array('pos'=>$key, 'd'=> $difficulty, 'eid'=>getNodeEid($respwords[$key][0]),
+ 'probaR1'=> probaOf("r1", $rw[1]),
+ 'probaR2'=> probaOf('r2', $rw[1]),
+ 'probaR0'=> probaOf('r0', $rw[1]),
+ 'probaTrash'=> probaOf('trash', $rw[1]));
+ }
}
+ else {
+ $err = true;
+ $msg = $strings['err_creategame_isNumeric_tDifficulty'];
+ }
+
+ $state = 3;
+ $msg = $strings['ok_creategame_game_create'];
}
cgInsert($centralword, $cloud, $r1, $r2, $totalDifficulty);
-
}
- else {
+ elseif($state == 2) {
$err = true;
$msg = $strings['err_creategame_fill_all'];
}
@@ -125,8 +155,6 @@ if(isset($_POST['nbcloudwords'])) {
else
$err = true;
-
-
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@@ -166,12 +194,12 @@ else
echo '<tr><td><label for="relation1">Relation 1 : </label></td>';
echo '<td class="inputcell"><select name="relation1">';
foreach($relations as $key=>$r)
- echo '<option value="'.$key.'">'.$stringRelations[$r].'</option>';
+ echo '<option value="'.$r.'">'.$stringRelations[$r].'</option>';
echo '</select></td>';
echo '<td><label for="relation2">Relation 2 : </label></td>';
echo '<td class="inputcell"><select name="relation2">';
foreach($relations as $key=>$r)
- echo '<option value="'.$key.'">'.$stringRelations[$r].'</option>';
+ echo '<option value="'.$r.'">'.$stringRelations[$r].'</option>';
echo '</select></td>';
echo '<input type="hidden" name="nbcloudwords" value="'.$nbwords.'" />';
echo '<tr><td colspan="2"><br /><label for="centralword">Mot central : </label><br /><br /></td>';
@@ -194,7 +222,7 @@ else
echo '</tr><tr><td colspan="2"></td><td colspan="2" class="td2"><input type="submit" value="Enregistrer la partie" /></td></tr>';
}
- else {
+ elseif($state == 2) {
echo 'Mot central : ';
echo $centralword;
echo '<input type="hidden" name="centralword" value="'.$centralword.'" />';
@@ -224,8 +252,17 @@ else
echo '<td colspan="2"></td>';
echo '</tr>';
+ echo '<tr><td colspan="2"><label for="tDifficulty">Difficulté de la partie</label></td>';
+ echo '<td class="inputcell" colspan="2"><select name="tDifficulty">';
+ for($i = 1; $i < 11; $i++)
+ echo '<option value="'.$i.'">'.$i.'</option>';
+ echo '</select></td></tr>';
+
echo '<tr><td colspan="4"><input type="submit" value="Enregistrer" /></td></tr>';
}
+ elseif($state == 3) {
+ echo '<p>nombre de mots ajoutés dans la base de données : '.$addedWords;
+ }
?>
</table>
</form>
diff --git a/code/serveur/php/download.php b/code/serveur/php/download.php
@@ -13,27 +13,28 @@ if(!isset($_SESSION['userId']))
</head>
<body>
<?php include("ressources/menu.inc"); ?>
- <div class="content">
- <?php include("ressources/showmsg.inc"); ?>
- <h2>Téléchargement de l'application</h2>
+<div class="content">
+ <?php include("ressources/showmsg.inc"); ?>
+ <h2>Téléchargement de l'application</h2>
<span class="downloadarea"><a href="ressources/pticlic-alpha-v0.1.apk" id="downloadlink">Téléchargement</a></span>
<h2>Installation de l'application</h2>
- <h3> A partir de votre téléphone </h3>
- <ul>
- <li><a href="ressources/pticlic-alpha-v0.1.apk">Téléchargez le fichier d'installation</a></li>
- <li>Une fois téléchargée, cliquez sur le fichier dans la barre de notification d'Android et suivez
- les instructions d'installation. Vous devrez patientez quelques instant pendant l'installation.</li>
- <li>Une fois l'installation terminée, démarrez l'application</li>
- <li> Suivez attentivement les instructions lors du premier démarrage de l'application</li>
+ <h3> A partir de votre téléphone </h3>
+ <ul>
+ <li><a href="ressources/pticlic-alpha-v0.1.apk">Téléchargez le fichier d'installation</a></li>
+ <li>Vous avez besoin d'autorisé votre téléphone à accepter les sources inconnue. Pour cela, aller dans Préférence→Application. Coché Sources inconnues.</li>
+ <li>Une fois téléchargé, cliquez sur le fichier dans la barre de notification d'Android et suivez
+ les instructions d'installation. Vous devrez patientez quelques instant pendant l'installation.</li>
+ <li>Une fois l'installation terminée, démarrez l'application</li>
+ <li> Suivez attentivement les instructions lors du premier démarrage de l'application</li>
</ul>
<h3> A partir de votre ordinateur </h3>
<ul>
<li><a href="ressources/pticlic-alpha-v0.1.apk">Téléchargez le fichier d'installation</a> </li>
- <li>Transférez ce fichier sur votre téléphone à l'aide de bluetooth, une clé usb ou autre</li>
+ <li>Transférez ce fichier sur votre téléphone à l'aide de bluetooth, une clé usb ou autre</li>
<li>Depuis votre téléphone, retrouvez sur votre carte mémoire l'application que vous
- venez de transférer</li>
- <li>Cliquez sur l'application afin de l'installer sur votre téléphone</li>
- <li>Suivez attentivement les instructions lors du premier démarrage de l'application</li>
+ venez de transférer</li>
+ <li>Cliquez sur l'application afin de l'installer sur votre téléphone</li>
+ <li>Suivez attentivement les instructions lors du premier démarrage de l'application</li>
</ul>
</div>
<?php include("ressources/footer.inc"); ?>
diff --git a/code/serveur/php/pticlic.php b/code/serveur/php/pticlic.php
@@ -648,8 +648,8 @@ function setGameGetScore($user, $pgid, $gid, $answers) {
function insertNode($node) {
$db = getDB();
- if($db->querySingle("SELECT eid FROM node WHERE name=".$node) != null) {
- $db->exec("INSERT INTO node(name,type,weight) VALUES($node,1,50);");
+ if($db->querySingle("SELECT eid FROM node WHERE name='".SQLite3::escapeString($node)."'") == null) {
+ $db->exec("INSERT INTO node(name,type,weight) VALUES('".SQLite3::escapeString($node)."',1,50);");
return true;
}
@@ -664,6 +664,6 @@ function insertNode($node) {
function getNodeEid($node) {
$db = getDB();
- //return $db->querySingle("SELECT eid FROM node WHERE name='".SQLite3::escapeString($node)."';");
+ return $db->querySingle("SELECT eid FROM node WHERE name='".SQLite3::escapeString($node)."';");
}
?>
diff --git a/code/serveur/php/ressources/simple.css b/code/serveur/php/ressources/simple.css
@@ -112,10 +112,12 @@ form input[type=submit] {
.creategame .wordsform {
border-collapse : collapse;
+ margin-top : 20px;
}
.creategame .wordsform td {
border : 1px solid #808080;
+ border-right : none;
vertical-align : middle;
padding : 1.5ex;
text-align : right;
@@ -127,6 +129,7 @@ form input[type=submit] {
text-align : left;
padding-left : 1em;
padding-right : 3em;
+ border-left : 0;
}
diff --git a/code/serveur/php/ressources/strings.inc b/code/serveur/php/ressources/strings.inc
@@ -12,6 +12,10 @@ $strings['err_contact_fill_all'] = "Veuillez remplir tout les champs.";
$strings['err_creategame_fill_all'] = "Tous les mots du nuage ne sont pas renseignés.";
$strings['err_creategame_nbwords_value'] = "Veuillez entrer une valeur supérieure à zéro.";
+$strings['ok_creategame_game_create'] = "La partie à bien été enregistrée.";
+$strings['err_creategame_eq_relations'] = "Les deux relations doivent être différentes.";
+$strings['err_creategame_isNumeric_tDifficulty'] = "La difficulté doit être une valeur numérique";
+$strings['err_creategame_cloud_fill_all'] = "Veuillez remplir l'intégralité des champs.";
$strings['err_index_invalid_msg'] = "Paramètre de la requête invalide. Merci de nous signaler le problème.";
$strings['err_index_redirect'] = "Erreur de redirection. Merci de nous signaler le problème.";