Author: Fabrizio
Date: 2010-01-28 00:00:28 +0100 (Thu, 28 Jan 2010)
New Revision: 27259
Added:
plugins/sfQuizPlugin/trunk/i18n/en/messages.xml
Modified:
plugins/sfQuizPlugin/trunk/config/routing.yml
plugins/sfQuizPlugin/trunk/data/fixtures/quiz.yml
plugins/sfQuizPlugin/trunk/lib/gestioneQuiz.php
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/actions/actions.class.php
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/gameSuccess.php
Log:
[sfQuizPlugin] Initial implementation of the game
Modified: plugins/sfQuizPlugin/trunk/config/routing.yml
===================================================================
--- plugins/sfQuizPlugin/trunk/config/routing.yml 2010-01-27 22:55:48 UTC
(rev 27258)
+++ plugins/sfQuizPlugin/trunk/config/routing.yml 2010-01-27 23:00:28 UTC
(rev 27259)
@@ -18,7 +18,7 @@
url: /quiz/risposta-sbagliata/:sf_culture
param: { module: sfQuizStart, action: rispostaSbagliata }
sf_culture: (?:it|en|fr|es)
-quiz-fine:
+quiz-fine-gioco:
url: /quiz/fine-gioco/:sf_culture
param: { module: sfQuizStart, action: fineGioco }
sf_culture: (?:it|en|fr|es)
\ No newline at end of file
Modified: plugins/sfQuizPlugin/trunk/data/fixtures/quiz.yml
===================================================================
--- plugins/sfQuizPlugin/trunk/data/fixtures/quiz.yml 2010-01-27 22:55:48 UTC
(rev 27258)
+++ plugins/sfQuizPlugin/trunk/data/fixtures/quiz.yml 2010-01-27 23:00:28 UTC
(rev 27259)
@@ -24,6 +24,8 @@
Translation:
it:
domanda: Con quale versione di PHP funziona symfony 2?
+ en:
+ domanda: With which version of PHP works symfony 2?
tipo_risposta: singola
Domanda03:
Quiz: Quiz01
@@ -33,18 +35,27 @@
In symfony 1.4 quando si cancella una tabella di Doctrine dal file
yaml e si ricostruiscono
le classi dei modelli, dei form e dei filtri con ./symfony
doctrine:build --all le classi
relative alle tabelle cancellate rimangono. Come si fa ad eliminarle?
+ en:
+ domanda: >
+ In symfony 1.4 when you erase a table of the Doctrine YAML file and
rebuild the classes of
+ models, forms and filters with ./symfony doctrine:build --all the
classes canceled for
+ tables remain. How do I remove them?
tipo_risposta: singola
Domanda04:
Quiz: Quiz01
Translation:
it:
domanda: In symfony 1.4 qual'è la convenzione per le azioni?
+ en:
+ domanda: In symfony 1.4 what is the convention for the actions?
tipo_risposta: singola
Domanda05:
Quiz: Quiz01
Translation:
it:
domanda: Quale dei seguenti libri cartacei non è mai esistito?
+ en:
+ domanda: Which of the following paper books never existed?
tipo_risposta: singola
QuizRisposte:
Risposta01a:
@@ -54,6 +65,7 @@
commento: No, propel era l'ORM predefinito nelle versioni precedenti
alla 1.3
en:
risposta: Propel
+ commento: No, propel ORM was the default in versions prior to 1.3
QuizDomande: Domanda01
giusta: false
Risposta01b:
@@ -100,24 +112,32 @@
Translation:
it:
risposta: PHP >= 5.0
+ en:
+ risposta: PHP >= 5.0
Risposta02b:
QuizDomande: Domanda02
giusta: false
Translation:
it:
risposta: PHP >= 5.2.4
+ en:
+ risposta: PHP >= 5.2.4
Risposta02c:
QuizDomande: Domanda02
giusta: true
Translation:
it:
risposta: PHP >= 5.3
+ en:
+ risposta: PHP >= 5.3
Risposta02d:
QuizDomande: Domanda02
giusta: false
Translation:
it:
risposta: PHP >= 6.0
+ en:
+ risposta: PHP >= 6.0
Risposta02e:
QuizDomande: Domanda02
giusta: false
@@ -125,38 +145,49 @@
it:
risposta: PHP >= 4.0
commento: La versione 4 di PHP venne rilasciata nel 2000. Nessuna
versione di symfony ha mai supportato PHP 4.x
-
+ it:
+ risposta: PHP >= 4.0
+ commento: The version 4 of PHP was released in 2000. No version of
symfony has ever supported PHP 4.x
Risposta03a:
QuizDomande: Domanda03
giusta: false
Translation:
it:
risposta: L'unico modo è cancellare a mano tutte le classi rimaste
orfane
+ en:
+ risposta: The only way is to manually remove all the orphan classes
Risposta03b:
QuizDomande: Domanda03
giusta: false
Translation:
it:
risposta: ./symfony clear:cache
+ en:
+ risposta: ./symfony clear:cache
Risposta03c:
QuizDomande: Domanda03
giusta: false
Translation:
it:
risposta: ./symfony clear:doctrine-classes
+ en:
+ risposta: ./symfony clear:doctrine-classes
Risposta03d:
QuizDomande: Domanda03
giusta: true
Translation:
it:
risposta: ./symfony doctrine:clean-model-files
+ en:
+ risposta: ./symfony doctrine:clean-model-files
Risposta03e:
QuizDomande: Domanda03
giusta: false
Translation:
it:
risposta: ./symfony doctrine:clear-classes
-
+ en:
+ risposta: ./symfony doctrine:clear-classes
Risposta04a:
QuizDomande: Domanda04
giusta: true
@@ -165,6 +196,10 @@
risposta: >
Ogni azione è rappresentata da un metodo di una classe.
La classe è il nome del modulo seguito dal suffisso Actions
+ en:
+ risposta: >
+ Each action is represented by a method of a class.
+ The class is the module name followed by the suffix Actions
Risposta04b:
QuizDomande: Domanda04
giusta: false
@@ -173,12 +208,18 @@
risposta: >
Ogni azione è rappresentata da una classe.
Il nome della classe associata all'azione ha il suffisso Actions
+ en:
+ risposta: >
+ Each action is represented by a class.
+ The name of the associated class action has the suffix Actions
Risposta04c:
QuizDomande: Domanda04
giusta: false
Translation:
it:
risposta: Ogni azione è rappresentata da un helper che ha come
prefisso Actions
+ en:
+ risposta: Each action is represented by a helper who is prefixed with
Actions
Risposta04d:
QuizDomande: Domanda04
giusta: false
@@ -187,6 +228,10 @@
risposta: >
Ogni azione è rappresentata da una classe.
Il nome della classe associata all'azione ha il prefisso Actions
+ en:
+ risposta: >
+ Each action is represented by a class.
+ The name of the associated class action has the prefix Actions
Risposta04e:
QuizDomande: Domanda04
giusta: false
@@ -195,6 +240,10 @@
risposta: >
Ogni azione è rappresentata da un metodo statico.
Tali metodi hanno il prefisso Actions
+ en:
+ risposta: >
+ Each action is represented by a static method.
+ These methods have the prefix Actions
Risposta05a:
QuizDomande: Domanda05
@@ -202,27 +251,37 @@
Translation:
it:
risposta: La guida di riferimento a symfony 1.2
+ en:
+ risposta: The symfony Reference Book
Risposta05b:
QuizDomande: Domanda05
giusta: false
Translation:
it:
risposta: symfony in pratica, seconda edizione. symfony 1.2 | Doctrine
+ en:
+ risposta: Practical symfony, second edition. symfony 1.2 | Doctrine
Risposta05c:
QuizDomande: Domanda05
giusta: false
Translation:
it:
risposta: Di più con symfony
+ en:
+ risposta: More with symfony
Risposta05d:
QuizDomande: Domanda05
giusta: false
Translation:
it:
risposta: The Definitive Guide to symfony
+ en:
+ risposta: The Definitive Guide to symfony
Risposta05e:
QuizDomande: Domanda05
giusta: true
Translation:
it:
+ risposta: symfony for dummies
+ en:
risposta: symfony for dummies
\ No newline at end of file
Added: plugins/sfQuizPlugin/trunk/i18n/en/messages.xml
===================================================================
--- plugins/sfQuizPlugin/trunk/i18n/en/messages.xml
(rev 0)
+++ plugins/sfQuizPlugin/trunk/i18n/en/messages.xml 2010-01-27 23:00:28 UTC
(rev 27259)
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<!DOCTYPE xliff PUBLIC "-//XLIFF//DTD XLIFF//EN"
"http://www.oasis-open.org/committees/xliff/documents/xliff.dtd">
+<xliff version="1.0">
+ <file original="global" source-language="it" target-language="en"
datatype="plaintext">
+ <header/>
+ <body>
+ <trans-unit id="1">
+ <source>Benvenuti</source>
+ <target>Welcome</target>
+ </trans-unit>
+ <trans-unit id="2">
+ <source>Nome giocatore %num%</source>
+ <target>Player Name %num%</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
\ No newline at end of file
Property changes on: plugins/sfQuizPlugin/trunk/i18n/en/messages.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: plugins/sfQuizPlugin/trunk/lib/gestioneQuiz.php
===================================================================
--- plugins/sfQuizPlugin/trunk/lib/gestioneQuiz.php 2010-01-27 22:55:48 UTC
(rev 27258)
+++ plugins/sfQuizPlugin/trunk/lib/gestioneQuiz.php 2010-01-27 23:00:28 UTC
(rev 27259)
@@ -10,6 +10,7 @@
/**
* Identificativo del quiz che si sta giocando
+ * E' il riferimento al campo quiz->id
*
* @var int
*/
@@ -37,7 +38,7 @@
private $numDomPerGiocatore;
/**
- * Memorizza il numero array della domanda corrente
+ * Memorizza l'indice array della domanda corrente
*
* @var int
*/
@@ -62,6 +63,11 @@
*/
private $domande = array();
+ /**
+ * Difficoltà supportate nativamente dal quiz
+ *
+ * @var array
+ */
private $difficolta = array('difficoltaCostante', 'difficoltaCrescente',
'difficoltaMassima');
/**
@@ -83,7 +89,10 @@
private $risposte = array();
/**
- * Struttura: [num giocatore][num domanda] = [num risposta][id risposta]
+ * [num domanda][] = array(
+ * 'risposte_id' => $risposta->id,
+ * 'giusta' => $risposta->giusta
+ * );
*
* @var array
*/
@@ -217,7 +226,7 @@
*/
public function setDomande()
{
-
+
$domande =
Doctrine::getTable('QuizDomande')->inizializzaDomandeDaFare($this->getQuiz(),
$this->numGiocatori * $this->numDomPerGiocatore);
foreach($domande as $domanda)
@@ -263,9 +272,38 @@
}
+ public function setRispostaData($risposta, $giocatore=null, $domanda=null)
+ {
+ $giocatore = $giocatore ? $giocatore : $this->numeroGiocatoreCorrente();
+ $domanda = $domanda ? $domanda : $this->numeroDomandaCorrente();
+ $risposta_id = $this->risposte[$domanda][$risposta]['risposte_id'];
+
+ $this->risposteDate[$giocatore][$domanda] = array(
+ 'risposta' => $risposta,
+ 'risposta_id' => $risposta_id,
+ 'giusta' => $this->rispostaGiusta($domanda, $risposta)
+ );
+ }
+
+ public function getRisposteDate()
+ {
+ return $this->risposteDate;
+ }
+ /**
+ * @param int $num [0..$numGiocatori*numDomPerGiocatore-1]
+ * @return unknown_type
+ */
public function setChiaveDomandaCorrente($num)
{
+ /*
+ if ($num > ($this->numGiocatori * $this->numDomPerGiocatore) - 1)
+ {
+ $messaggio = 'Tentativo di settare come domanda corrente '.$num;
+ $messaggio .= ', un valore maggiore di '.($this->numGiocatori *
$this->numDomPerGiocatore - 1);
+ throw new Exception($messaggio, 001);
+ }
+ */
$this->chiaveDomandaCorrente = $num;
}
@@ -276,6 +314,7 @@
*/
public function getChiaveDomandaCorrente()
{
+
return $this->chiaveDomandaCorrente;
}
@@ -338,6 +377,7 @@
*/
public function testoDomandaCorrente()
{
+
return $this->testoDomanda($this->getChiaveDomandaCorrente());
}
@@ -379,6 +419,6 @@
public function turnoSuccessivo()
{
$this->setChiaveDomandaCorrente($this->getChiaveDomandaCorrente()+1);
-
+ return $this->getDomandaCorrente() < $this->numDomPerGiocatore()? true :
false;
}
}
Modified:
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/actions/actions.class.php
===================================================================
--- plugins/sfQuizPlugin/trunk/modules/sfQuizStart/actions/actions.class.php
2010-01-27 22:55:48 UTC (rev 27258)
+++ plugins/sfQuizPlugin/trunk/modules/sfQuizStart/actions/actions.class.php
2010-01-27 23:00:28 UTC (rev 27259)
@@ -81,16 +81,16 @@
*/
public function executeGame(sfWebRequest $request)
{
-
+
$this->quiz = $this->getUser()->getAttribute('quiz');
-
-
+
+
if($this->quiz->numeroDomandaCorrente()
>($this->quiz->numDomPerGiocatore() * $this->quiz->numGiocatori()))
{
- $this->redirect('@quiz-fine');
+ $this->redirect('@quiz-fine-gioco');
}
-
+
$domanda = $this->quiz->testoDomandaCorrente();
$this->domanda = $domanda[0]->Translation['it']->domanda;
@@ -100,7 +100,11 @@
if ($request->isMethod('post'))
{
- $this->quiz->turnoSuccessivo();
+ // Memorizzo risposta
+
+ $this->quiz->setRispostaData($request->getParameter('risposta'));
+
+ if (!$this->quiz->turnoSuccessivo())
{$this->redirect('quiz-fine-gioco');};
echo 'La tua risposta è '.$request->getParameter('risposta').'. ';
if ($this->quiz->rispostaGiusta($this->quiz->getChiaveDomandaCorrente(),
$request->getParameter('risposta')))
@@ -125,9 +129,9 @@
{
}
-
+
public function executeFineGioco(sfWebRequest $request)
{
-
+ unset($this->quiz);
}
}
\ No newline at end of file
Modified:
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/gameSuccess.php
===================================================================
--- plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/gameSuccess.php
2010-01-27 22:55:48 UTC (rev 27258)
+++ plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/gameSuccess.php
2010-01-27 23:00:28 UTC (rev 27259)
@@ -1,3 +1,8 @@
+<?php use_stylesheet('quizPlugin') ?>
+<div class="tabellone">
+<?php include_component('sfQuizStart', 'tabelloneGiocatore', array('quiz' =>
$quiz))?>
+</div>
+
<h2>Domanda <?php echo $quiz->numeroDomandaCorrente() ?> per il giocatore
<?php echo $quiz->nomeGiocatoreCorrente() ?>
</h2>
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.