Author: Fabrizio
Date: 2010-01-31 16:12:34 +0100 (Sun, 31 Jan 2010)
New Revision: 27350
Added:
plugins/sfQuizPlugin/.project
plugins/sfQuizPlugin/trunk/lib/filter/doctrine/PlugintopicsFormFilter.class.php
plugins/sfQuizPlugin/trunk/lib/form/NameOfPlayersCollectionForm.class.php
plugins/sfQuizPlugin/trunk/lib/form/doctrine/PlugintopicsForm.class.php
plugins/sfQuizPlugin/trunk/lib/form/nameOfPlayersForm.class.php
plugins/sfQuizPlugin/trunk/lib/form/playerNameForm.class.php
plugins/sfQuizPlugin/trunk/lib/form/playersNumberForm.class.php
plugins/sfQuizPlugin/trunk/lib/model/doctrine/Plugintopics.class.php
plugins/sfQuizPlugin/trunk/lib/model/doctrine/PlugintopicsTable.class.php
Modified:
plugins/sfQuizPlugin/trunk/config/doctrine/schema.yml
plugins/sfQuizPlugin/trunk/data/fixtures/quiz.yml
plugins/sfQuizPlugin/trunk/i18n/it/messages.xml
plugins/sfQuizPlugin/trunk/lib/gestioneQuiz.php
plugins/sfQuizPlugin/trunk/lib/model/doctrine/PluginQuizAnswersTable.class.php
plugins/sfQuizPlugin/trunk/lib/model/doctrine/PluginQuizQuestionsTable.class.php
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/actions/actions.class.php
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/actions/components.class.php
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/_boardPlayer.php
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/gameSuccess.php
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/indexSuccess.php
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/namesOfPlayersSuccess.php
Log:
[sfQuizPlugin] More refactoring
Added: plugins/sfQuizPlugin/.project
===================================================================
--- plugins/sfQuizPlugin/.project (rev 0)
+++ plugins/sfQuizPlugin/.project 2010-01-31 15:12:34 UTC (rev 27350)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>sfQuizPlugin</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
Property changes on: plugins/sfQuizPlugin/.project
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: plugins/sfQuizPlugin/trunk/config/doctrine/schema.yml
===================================================================
--- plugins/sfQuizPlugin/trunk/config/doctrine/schema.yml 2010-01-31
14:52:46 UTC (rev 27349)
+++ plugins/sfQuizPlugin/trunk/config/doctrine/schema.yml 2010-01-31
15:12:34 UTC (rev 27350)
@@ -50,7 +50,7 @@
immagine:
type: string(50)
notnull: true
- topics_id: integer(1)
+ topics_id: integer(4)
relations:
Quiz:
local: quiz_id
@@ -99,4 +99,11 @@
QuizQuestions:
local: quiz_questions_id
foreign: id
- type: one
\ No newline at end of file
+ type: one
+topics:
+ tableName: topics
+ columns:
+ id:
+ type: integer(4)
+ primary: true
+ autoincrement: true
\ No newline at end of file
Modified: plugins/sfQuizPlugin/trunk/data/fixtures/quiz.yml
===================================================================
--- plugins/sfQuizPlugin/trunk/data/fixtures/quiz.yml 2010-01-31 14:52:46 UTC
(rev 27349)
+++ plugins/sfQuizPlugin/trunk/data/fixtures/quiz.yml 2010-01-31 15:12:34 UTC
(rev 27350)
@@ -18,7 +18,7 @@
question: In symfony 1.4, qual'è l'ORM predefinito?
en:
question: With symfony 1.4, what is the default ORM?
- type_response: singola
+ type_response: single
Question02:
Quiz: Quiz01
Translation:
@@ -26,7 +26,7 @@
question: Con quale versione di PHP funziona symfony 2?
en:
question: With which version of PHP works symfony 2?
- type_response: singola
+ type_response: single
Question03:
Quiz: Quiz01
Translation:
@@ -40,7 +40,7 @@
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?
- type_response: singola
+ type_response: single
Question04:
Quiz: Quiz01
Translation:
@@ -48,7 +48,7 @@
question: In symfony 1.4 qual'è la convenzione per le azioni?
en:
question: In symfony 1.4 what is the convention for the actions?
- type_response: singola
+ type_response: single
Question05:
Quiz: Quiz01
Translation:
@@ -56,7 +56,7 @@
question: Quale dei seguenti libri cartacei non è mai esistito?
en:
question: Which of the following paper books never existed?
- type_response: singola
+ type_response: single
QuizAnswers:
Answer01a:
Translation:
Modified: plugins/sfQuizPlugin/trunk/i18n/it/messages.xml
===================================================================
--- plugins/sfQuizPlugin/trunk/i18n/it/messages.xml 2010-01-31 14:52:46 UTC
(rev 27349)
+++ plugins/sfQuizPlugin/trunk/i18n/it/messages.xml 2010-01-31 15:12:34 UTC
(rev 27350)
@@ -42,8 +42,12 @@
</trans-unit>
<trans-unit id="10">
<source>Next question</source>
- <target>Domanda successiva </target>
+ <target>Domanda successiva</target>
</trans-unit>
+ <trans-unit id="11">
+ <source>Player %name% results</source>
+ <target>Percorso del giocatore %name%</target>
+ </trans-unit>
</body>
</file>
Added:
plugins/sfQuizPlugin/trunk/lib/filter/doctrine/PlugintopicsFormFilter.class.php
===================================================================
---
plugins/sfQuizPlugin/trunk/lib/filter/doctrine/PlugintopicsFormFilter.class.php
(rev 0)
+++
plugins/sfQuizPlugin/trunk/lib/filter/doctrine/PlugintopicsFormFilter.class.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * Plugintopics form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810
2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PlugintopicsFormFilter extends BasetopicsFormFilter
+{
+}
Added: plugins/sfQuizPlugin/trunk/lib/form/NameOfPlayersCollectionForm.class.php
===================================================================
--- plugins/sfQuizPlugin/trunk/lib/form/NameOfPlayersCollectionForm.class.php
(rev 0)
+++ plugins/sfQuizPlugin/trunk/lib/form/NameOfPlayersCollectionForm.class.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -0,0 +1,20 @@
+<?php
+
+class NameOfPlayersCollectionForm extends sfForm
+{
+ public function configure()
+ {
+
+ if(!$nome = $this->getOption('size'))
+ {
+ throw new InvalidArgumentException(_('You must provide a size.'));
+ }
+
+ for ($i = 0; $i < $this->getOption('size'); $i++)
+ {
+ $form = new PlayerNameForm();
+ $this->embedForm($i, $form);
+ }
+
+ }
+}
\ No newline at end of file
Added: plugins/sfQuizPlugin/trunk/lib/form/doctrine/PlugintopicsForm.class.php
===================================================================
--- plugins/sfQuizPlugin/trunk/lib/form/doctrine/PlugintopicsForm.class.php
(rev 0)
+++ plugins/sfQuizPlugin/trunk/lib/form/doctrine/PlugintopicsForm.class.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * Plugintopics form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage form
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormPluginTemplate.php 23810 2009-11-12
11:07:44Z Kris.Wallsmith $
+ */
+abstract class PlugintopicsForm extends BasetopicsForm
+{
+}
Added: plugins/sfQuizPlugin/trunk/lib/form/nameOfPlayersForm.class.php
===================================================================
--- plugins/sfQuizPlugin/trunk/lib/form/nameOfPlayersForm.class.php
(rev 0)
+++ plugins/sfQuizPlugin/trunk/lib/form/nameOfPlayersForm.class.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -0,0 +1,17 @@
+<?php
+
+class NameOfPlayersForm extends BaseForm
+{
+ public function configure()
+ {
+
+ $form = new NameOfPlayersCollectionForm(null, array(
+ 'size' => $this->getOption('size')
+ ));
+
+ $this->embedForm('newNameOfPlayers', $form);
+
+ $this->widgetSchema->setNameFormat('newNameOfPlayersBind[%s]');
+
+ }
+}
\ No newline at end of file
Added: plugins/sfQuizPlugin/trunk/lib/form/playerNameForm.class.php
===================================================================
--- plugins/sfQuizPlugin/trunk/lib/form/playerNameForm.class.php
(rev 0)
+++ plugins/sfQuizPlugin/trunk/lib/form/playerNameForm.class.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -0,0 +1,16 @@
+<?php
+
+class PlayerNameForm extends BaseForm
+{
+ public function configure()
+ {
+ $this->setWidget('playerName', new sfWidgetFormInputText());
+
+ $this->setValidator('playerName', new sfValidatorString(array(
+ 'min_length' => 1,
+ 'max_length' => sfConfig::get('max_length_player_name')
+ )));
+
+
$this->widgetSchema->getFormFormatter()->setTranslationCatalogue('traduzioni_form');
+ }
+}
\ No newline at end of file
Added: plugins/sfQuizPlugin/trunk/lib/form/playersNumberForm.class.php
===================================================================
--- plugins/sfQuizPlugin/trunk/lib/form/playersNumberForm.class.php
(rev 0)
+++ plugins/sfQuizPlugin/trunk/lib/form/playersNumberForm.class.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -0,0 +1,42 @@
+<?php
+class PlayersNumberForm extends BaseForm
+{
+ public function configure()
+ {
+
+ $numDomScelte = array (
+ '1' => '1',
+ '2' => '2',
+ '5' => '5',
+ '10' => '10',
+ '15' => '15',
+ '20' => '20',
+ );
+
+ $this->widgetSchema['numDom'] = new sfWidgetFormChoice(array(
+ 'choices' => $numDomScelte));
+
+ $this->setWidgets(array(
+ 'playersNumber' => new sfWidgetFormInputText(),
+ 'numberQuestionsForPlayer' => $this->widgetSchema['numDom'],
+ ));
+
+ $this->widgetSchema->setLabels(array(
+ 'playersNumber' => 'Number of players',
+ 'numberQuestionsForPlayer' => 'Number of questions to ask each player'
+ ));
+
+ $this->widgetSchema['playersNumber']->setAttribute('size', 3);
+ $this->widgetSchema['playersNumber']->setAttribute('maxlength', 2);
+
+ $this->widgetSchema->setNameFormat('playersNumber[%s]');
+
+
+ $this->setValidators(array(
+ 'playersNumber' => new sfValidatorNumber(array('min' => 1, 'max' =>
sfConfig::get('app_max_num_giocatori'))),
+ 'numberQuestionsForPlayer' => new sfValidatorChoice(array('choices' =>
$numDomScelte))
+ ));
+
+
$this->widgetSchema->getFormFormatter()->setTranslationCatalogue('traduzioni_form');
+ }
+}
\ No newline at end of file
Modified: plugins/sfQuizPlugin/trunk/lib/gestioneQuiz.php
===================================================================
--- plugins/sfQuizPlugin/trunk/lib/gestioneQuiz.php 2010-01-31 14:52:46 UTC
(rev 27349)
+++ plugins/sfQuizPlugin/trunk/lib/gestioneQuiz.php 2010-01-31 15:12:34 UTC
(rev 27350)
@@ -5,7 +5,7 @@
* @author Fabrizio Pucci <[email protected]>
*
*/
-class GestioneQuiz
+class QuizManager
{
/**
@@ -21,28 +21,28 @@
*
* @var int
*/
- private $numGiocatori;
+ private $numPlayers;
/**
* Nomi dei giocatori
*
* @var array
*/
- private $nomiGiocatori = array();
+ private $nameOfPlayers = array();
/**
* Numero totale delle domande da fare a ciascun giocatore
*
* @var int
*/
- private $numDomPerGiocatore;
+ private $numQuestForPlayer;
/**
* Memorizza l'indice array della domanda corrente
*
* @var int
*/
- private $chiaveDomandaCorrente;
+ private $keyCurrentQuestion;
/**
*
@@ -52,23 +52,23 @@
*
* @var array
*/
- private $punteggio = array();
+ private $score = array();
/**
* Elenco delle domande da fare
- * Vanno da 0 a ($numDomPerGiocatore * $numGiocatori)
+ * Vanno da 0 a ($numQuestForPlayer * $numPlayers)
* Struttura: [num domanda] = [domanda_id]
*
* @var array
*/
- private $domande = array();
+ private $questions = array();
/**
* Difficoltà supportate nativamente dal quiz
*
* @var array
*/
- private $difficolta = array('difficoltaCostante', 'difficoltaCrescente',
'difficoltaMassima');
+ private $difficulty = array('constantDifficulty', 'increasingDifficulty',
'maxDifficulty');
/**
* Numero delle risposte da visualizzare per ciascuna domanda
@@ -76,22 +76,22 @@
*
* @var int
*/
- private $numRispostePerDomanda;
+ private $numAnswersForQuestion;
/**
* [num domanda][] = array(
- * 'risposte_id' => '',
- * 'giusta' => ''
+ * 'answers_id' => '',
+ * 'correct' => ''
* );
*
* @var array
*/
- private $risposte = array();
+ private $answers = array();
/**
* [num domanda][] = array(
- * 'risposte_id' => $risposta->id,
- * 'giusta' => $risposta->giusta
+ * 'answers_id' => $answer->id,
+ * 'correct' => $answer->correct
* );
*
* @var array
@@ -126,13 +126,13 @@
* @param int $num
* @return void
*/
- public function numGiocatori($num = null)
+ public function numPlayers($num = null)
{
if ($num != null)
{
- $this->numGiocatori = $num;
+ $this->numPlayers = $num;
}
- return $this->numGiocatori;
+ return $this->numPlayers;
}
/**
@@ -141,32 +141,32 @@
* @param int $num Valore da assegnare
* @return int
*/
- public function numDomPerGiocatore($num = null)
+ public function numQuestForPlayer($num = null)
{
if ($num != null)
{
- $this->numDomPerGiocatore = $num;
+ $this->numQuestForPlayer = $num;
}
- return $this->numDomPerGiocatore;
+ return $this->numQuestForPlayer;
}
- public function setNomiGiocatori(array $nomi)
+ public function setNameOfPlayers(array $nomi)
{
foreach ($nomi as $nome)
{
- $this->nomiGiocatori[] = $nome;
+ $this->nameOfPlayers[] = $nome;
}
}
- public function addNomeGiocatore($nome)
+ public function addPlayerName($nome)
{
- $this->nomiGiocatori[] = $nome;
+ $this->nameOfPlayers[] = $nome;
}
- public function nomeGiocatore($i)
+ public function playerName($i)
{
- return $this->nomiGiocatori[$i];
+ return $this->nameOfPlayers[$i];
}
/**
@@ -200,18 +200,18 @@
return $this->modalitaRispostePerDomanda;
}
- public function getNumRispostePerDomanda()
+ public function getNumAnswersForQuestion()
{
- return $this->numRispostePerDomanda;
+ return $this->numAnswersForQuestion;
}
- public function getNumRispostePerDomandaCorrente()
+ public function getNumAnswersForCurrentQuestion()
{
- if ($this->getModalitaRispostePerDomanda == 'difficoltaCostante')
+ if ($this->getModalitaRispostePerDomanda == 'constantDifficulty')
{
- return $this->numRispostePerDomanda;
+ return $this->numAnswersForQuestion;
}
- else if ($this->getModalitaRispostePerDomanda == 'difficoltaCrescente')
+ else if ($this->getModalitaRispostePerDomanda == 'increasingDifficulty')
{
// Algoritmo in base a numero domanda attuale?
}
@@ -224,17 +224,17 @@
*
* @return void
*/
- public function setDomande()
+ public function setQuestions()
{
- $domande =
Doctrine::getTable('QuizQuestions')->inizializzaDomandeDaFare($this->getQuiz(),
$this->numGiocatori * $this->numDomPerGiocatore);
-
- foreach($domande as $domanda)
+ $questions =
Doctrine::getTable('QuizQuestions')->inizializzaDomandeDaFare($this->getQuiz(),
$this->numPlayers * $this->numQuestForPlayer);
+
+ foreach($questions as $question)
{
- $this->domande[] = $domanda->id;
+ $this->questions[] = $question->id;
}
-
+
}
/**
@@ -242,28 +242,28 @@
*
* @return array
*/
- public function getDomande()
+ public function getQuestions()
{
- return $this->domande;
+ return $this->questions;
}
/**
* @return unknown_type
*/
- public function setRisposte()
+ public function setAnswers()
{
- foreach ($this->getDomande() as $d => $domanda)
+ foreach ($this->getQuestions() as $d => $question)
{
- $risposte =
Doctrine::getTable('QuizAnswers')->inizializzaRisposteDaFare($domanda, 5);
+ $answers =
Doctrine::getTable('QuizAnswers')->inizializzaRisposteDaFare($question, 5);
- foreach($risposte as $r => $risposta)
+ foreach($answers as $r => $answer)
{
- $this->risposte[$d][]= array(
- 'answers_id' => $risposta->id,
- 'correct' => $risposta->giusta
+ $this->answers[$d][]= array(
+ 'answers_id' => $answer->id,
+ 'correct' => $answer->correct
);
//echo $risposta->Translation['it']->risposta;
@@ -272,16 +272,16 @@
}
- public function setRispostaData($risposta, $giocatore=null, $domanda=null)
+ public function setRispostaData($answer, $player=null, $question=null)
{
- $giocatore = $giocatore ? $giocatore : $this->numeroGiocatoreCorrente();
- $domanda = $domanda ? $domanda : $this->numeroDomandaCorrente();
- $risposta_id = $this->risposte[$domanda][$risposta]['answers_id'];
+ $player = $player ? $player : $this->numberCurrentPlayer();
+ $question = $question ? $question : $this->numberCurrentQuestion();
+ $answer_id = $this->answers[$question][$answer]['answers_id'];
$this->risposteDate[$giocatore][$domanda] = array(
- 'answer' => $risposta,
- 'answers_id' => $risposta_id,
- 'correct' => $this->rispostaGiusta($domanda, $risposta)
+ 'answer' => $answer,
+ 'answers_id' => $answer_id,
+ 'correct' => $this->correctAnswer($question, $answer)
);
}
@@ -291,20 +291,20 @@
}
/**
- * @param int $num [0..$numGiocatori*numDomPerGiocatore-1]
+ * @param int $num [0..$numPlayers*numQuestForPlayer-1]
* @return unknown_type
*/
- public function setChiaveDomandaCorrente($num)
+ public function setKeyCurrentQuestion($num)
{
/*
- if ($num > ($this->numGiocatori * $this->numDomPerGiocatore) - 1)
+ if ($num > ($this->numPlayers * $this->numQuestForPlayer) - 1)
{
$messaggio = 'Tentativo di settare come domanda corrente '.$num;
- $messaggio .= ', un valore maggiore di '.($this->numGiocatori *
$this->numDomPerGiocatore - 1);
+ $messaggio .= ', un valore maggiore di '.($this->numPlayers *
$this->numQuestForPlayer - 1);
throw new Exception($messaggio, 001);
}
*/
- $this->chiaveDomandaCorrente = $num;
+ $this->keyCurrentQuestion = $num;
}
/**
@@ -312,10 +312,10 @@
*
* @return int
*/
- public function getChiaveDomandaCorrente()
+ public function getKeyCurrentQuestion()
{
- return $this->chiaveDomandaCorrente;
+ return $this->keyCurrentQuestion;
}
/**
@@ -324,9 +324,9 @@
*
* @return number Numero domanda (parte da 1)
*/
- public function numeroDomandaCorrente()
+ public function numberCurrentQuestion()
{
- return round(($this->getChiaveDomandaCorrente()+1)/$this->numGiocatori());
+ return round(($this->getKeyCurrentQuestion()+1)/$this->numPlayers());
}
/**
@@ -334,16 +334,16 @@
*
* @return number|number
*/
- public function numeroGiocatoreCorrente()
+ public function numberCurrentPlayer()
{
- $numDomandaCorrente = $this->getChiaveDomandaCorrente()+1;
- if ($numDomandaCorrente <= $this->numGiocatori())
+ $numDomandaCorrente = $this->getKeyCurrentQuestion()+1;
+ if ($numDomandaCorrente <= $this->numPlayers())
{
return $numDomandaCorrente;
}
else
{
- return ($numDomandaCorrente % $this->numGiocatori());
+ return ($numDomandaCorrente % $this->numPlayers());
}
}
@@ -352,10 +352,10 @@
*
* @return string
*/
- public function nomeGiocatoreCorrente()
+ public function nameCurrentPlayer()
{
- return $this->nomeGiocatore($this->numeroGiocatoreCorrente()-1);
+ return $this->playerName($this->numberCurrentPlayer()-1);
}
/**
@@ -364,10 +364,10 @@
* @param int $dom Chiave array della domanda
* @return string
*/
- public function testoDomanda($dom)
+ public function textQuestion($dom)
{
- $id = $this->domande[$dom];
- return Doctrine::getTable('QuizQuestions')->testoDomanda($id);
+ $id = $this->questions[$dom];
+ return Doctrine::getTable('QuizQuestions')->textQuestion($id);
}
/**
@@ -375,51 +375,52 @@
*
* @return string
*/
- public function testoDomandaCorrente()
+ public function textCurrentQuestion()
{
- return $this->testoDomanda($this->getChiaveDomandaCorrente());
+ return $this->textQuestion($this->getKeyCurrentQuestion());
}
- public function testiRisposte($dom)
+ public function textsAnswers($dom)
{
- foreach($this->risposte[$dom] as $i => $risposta)
+ foreach($this->answers[$dom] as $i => $answer)
{
- $risp =
Doctrine::getTable('QuizAnswers')->testoRisposta($risposta['answers_id']);
+ $risp =
Doctrine::getTable('QuizAnswers')->textAnswer($answer['answers_id']);
$r[$i] = array(
- 'testo' => $risp[0]->Translation['it']->answer,
+ 'text' => $risp[0]->Translation['it']->answer,
);
}
return $r;
}
- public function testiRisposteCorrenti()
+ public function textsCurrentAnswers()
{
- return $this->testiRisposte($this->getChiaveDomandaCorrente());
+ return $this->textsAnswers($this->getKeyCurrentQuestion());
}
- public function rispostaGiusta($domanda, $risposta)
+ public function correctAnswer($question, $answer)
{
/*
- echo "Cerco $domanda e $risposta. Verifica
".$this->risposte[$domanda][$risposta]['giusta'];
+ echo "Cerco $domanda e $risposta. Verifica
".$this->answers[$question][$answer]['correct'];
echo "<pre>";
- print_r($this->risposte);
+ print_r($this->answers);
echo "</pre>";
*/
- return $this->risposte[$domanda][$risposta]['giusta'];
+ return $this->answers[$question][$answer]['correct'];
}
/**
* @return unknown_type
*/
- public function turnoSuccessivo()
+ public function nextRound()
{
- $this->setChiaveDomandaCorrente($this->getChiaveDomandaCorrente()+1);
- //echo $this->getChiaveDomandaCorrente() . ' - '.
$this->numDomPerGiocatore();exit;
- return $this->getChiaveDomandaCorrente() <= $this->numDomPerGiocatore()?
true : false;
+
+ $this->setKeyCurrentQuestion($this->getKeyCurrentQuestion()+1);
+
+ return $this->getKeyCurrentQuestion() <= $this->numQuestForPlayer()? true :
false;
}
}
Modified:
plugins/sfQuizPlugin/trunk/lib/model/doctrine/PluginQuizAnswersTable.class.php
===================================================================
---
plugins/sfQuizPlugin/trunk/lib/model/doctrine/PluginQuizAnswersTable.class.php
2010-01-31 14:52:46 UTC (rev 27349)
+++
plugins/sfQuizPlugin/trunk/lib/model/doctrine/PluginQuizAnswersTable.class.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -13,13 +13,13 @@
* @param unknown_type $limit
* @return Doctrine_Collection
*/
- public function inizializzaRisposteDaFare($quiz_domande_id, $limit)
+ public function inizializzaRisposteDaFare($quiz_questions_id, $limit)
{
$q = Doctrine_Query::create()
->select('r.id, r.correct')
->from('QuizAnswers r')
- ->where('r.quiz_answers_id = ? AND r.correct = 0', $quiz_domande_id)
+ ->where('r.quiz_questions_id = ? AND r.correct = 0', $quiz_questions_id)
->orderBy('RAND()')
;
@@ -27,19 +27,19 @@
{
$q = $q->limit($limit);
}
- $sbagliate = $q->execute();
+ $wrongs = $q->execute();
$q = Doctrine_Query::create()
->select('r.id, r.correct')
->from('QuizAnswers r')
- ->where('r.quiz_answers_id = ? AND r.correct = 1', $quiz_domande_id);
+ ->where('r.quiz_questions_id = ? AND r.correct = 1', $quiz_questions_id);
- $giuste = $q->execute();
- return $sbagliate->merge($giuste);
+ $corrects = $q->execute();
+ return $wrongs->merge($corrects);
}
- public function testoRisposta($id)
+ public function textAnswer($id)
{
$q= Doctrine_Query::create()
->select('r.id')
Modified:
plugins/sfQuizPlugin/trunk/lib/model/doctrine/PluginQuizQuestionsTable.class.php
===================================================================
---
plugins/sfQuizPlugin/trunk/lib/model/doctrine/PluginQuizQuestionsTable.class.php
2010-01-31 14:52:46 UTC (rev 27349)
+++
plugins/sfQuizPlugin/trunk/lib/model/doctrine/PluginQuizQuestionsTable.class.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -25,7 +25,7 @@
* @param int $id
* @return Doctrine_Collection
*/
- public function testoDomanda($id)
+ public function textQuestion($id)
{
$q = Doctrine_Query::create()
Added: plugins/sfQuizPlugin/trunk/lib/model/doctrine/Plugintopics.class.php
===================================================================
--- plugins/sfQuizPlugin/trunk/lib/model/doctrine/Plugintopics.class.php
(rev 0)
+++ plugins/sfQuizPlugin/trunk/lib/model/doctrine/Plugintopics.class.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -0,0 +1,16 @@
+<?php
+
+/**
+ * Plugintopics
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
+ */
+abstract class Plugintopics extends Basetopics
+{
+
+}
\ No newline at end of file
Added: plugins/sfQuizPlugin/trunk/lib/model/doctrine/PlugintopicsTable.class.php
===================================================================
--- plugins/sfQuizPlugin/trunk/lib/model/doctrine/PlugintopicsTable.class.php
(rev 0)
+++ plugins/sfQuizPlugin/trunk/lib/model/doctrine/PlugintopicsTable.class.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -0,0 +1,7 @@
+<?php
+/**
+ */
+class PlugintopicsTable extends Doctrine_Table
+{
+
+}
\ No newline at end of file
Modified:
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/actions/actions.class.php
===================================================================
--- plugins/sfQuizPlugin/trunk/modules/sfQuizStart/actions/actions.class.php
2010-01-31 14:52:46 UTC (rev 27349)
+++ plugins/sfQuizPlugin/trunk/modules/sfQuizStart/actions/actions.class.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -5,12 +5,12 @@
public function executeIndex(sfWebRequest $request)
{
- $this->form = new NumeroGiocatoriForm();
+ $this->form = new PlayersNumberForm();
if ($request->isMethod('post'))
{
- $this->form->bind($request->getParameter('numeroGiocatori'));
+ $this->form->bind($request->getParameter('playersNumber'));
if ($this->form->isValid())
{
$this->redirect('@quiz-names-of-players?'.http_build_query($this->form->getValues()));
@@ -29,43 +29,43 @@
public function executeNamesOfPlayers(sfWebRequest $request)
{
- $this->form = new NomiGiocatoriForm(null, array(
- 'size' => $request->getParameter('numeroGiocatori')
+ $this->form = new NameOfPlayersForm(null, array(
+ 'size' => $request->getParameter('playersNumber')
));
if ($request->isMethod('post'))
{
- $this->form->bind($request->getParameter('newNomiGiocatoriBind'));
+ $this->form->bind($request->getParameter('newNameOfPlayersBind'));
if ($this->form->isValid())
{
- $quiz = new GestioneQuiz();
+ $quiz = new QuizManager();
// Setta il quiz
$quiz->setQuiz(1);
// Setta numero giocatori
- $quiz->numGiocatori($request->getParameter('numeroGiocatori'));
+ $quiz->numPlayers($request->getParameter('playersNumber'));
// Setta numero domande per giocatore
-
$quiz->numDomPerGiocatore($request->getParameter('numeroDomandePerGiocatore'));
+
$quiz->numQuestForPlayer($request->getParameter('numberQuestionsForPlayer'));
// Setta la chiave array della domanda corrente
- $quiz->setChiaveDomandaCorrente(0);
+ $quiz->setKeyCurrentQuestion(0);
// Setta i nomi dei giocatori
- $giocatori = $request->getParameter('newNomiGiocatoriBind');
- foreach($giocatori['newNomiGiocatori'] as $giocatore)
+ $giocatori = $request->getParameter('newNameOfPlayersBind');
+ foreach($giocatori['newNameOfPlayers'] as $giocatore)
{
- $quiz->addNomeGiocatore($giocatore['nomeGiocatore']);
+ $quiz->addPlayerName($giocatore['playerName']);
}
// Setta le domande da fare
- $quiz->setDomande();
+ $quiz->setQuestions();
// Setta le risposte da fare
- $quiz->setRisposte();
+ $quiz->setAnswers();
$this->getUser()->setAttribute('quiz', $quiz);
@@ -84,28 +84,29 @@
$this->quiz = $this->getUser()->getAttribute('quiz');
-
- if($this->quiz->numeroDomandaCorrente()
>($this->quiz->numDomPerGiocatore() * $this->quiz->numGiocatori()))
+ //print_r($this->quiz->getQuestions());exit;
+
+ if($this->quiz->numberCurrentQuestion() >($this->quiz->numQuestForPlayer()
* $this->quiz->numPlayers()))
{
$this->redirect('@quiz-end-game');
}
- $domanda = $this->quiz->testoDomandaCorrente();
- $this->domanda = $domanda[0]->Translation['it']->question;
+ $question = $this->quiz->textCurrentQuestion();
+ $this->question = $question[0]->Translation['it']->question;
- $this->risposte = $this->quiz->testiRisposteCorrenti();
+ $this->answers = $this->quiz->textsCurrentAnswers();
if ($request->isMethod('post'))
{
// Memorizzo risposta
- $this->quiz->setRispostaData($request->getParameter('risposta'));
+ $this->quiz->setRispostaData($request->getParameter('answer'));
- if (!$this->quiz->turnoSuccessivo()) {$this->redirect('quiz-end-game');};
- // echo __('La tua risposta è %risposta%', array('%risposta%' =>
$request->getParameter('risposta'))).'. ';
+ if (!$this->quiz->nextRound()) {$this->redirect('quiz-end-game');};
+ // echo __('La tua risposta è %answer%', array('%answer%' =>
$request->getParameter('answer'))).'. ';
- if ($this->quiz->rispostaGiusta($this->quiz->getChiaveDomandaCorrente(),
$request->getParameter('risposta')))
+ if ($this->quiz->correctAnswer($this->quiz->getKeyCurrentQuestion(),
$request->getParameter('answer')))
{
$this->redirect('@quiz-correct-answer');
Modified:
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/actions/components.class.php
===================================================================
--- plugins/sfQuizPlugin/trunk/modules/sfQuizStart/actions/components.class.php
2010-01-31 14:52:46 UTC (rev 27349)
+++ plugins/sfQuizPlugin/trunk/modules/sfQuizStart/actions/components.class.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -3,9 +3,9 @@
{
public function executeBoardPlayer()
{
- $this->nome = $this->quiz->nomeGiocatoreCorrente();
- $this->giocatore = $this->quiz->numeroGiocatoreCorrente()-1;
- $this->totDomande = $this->quiz->numDomPerGiocatore();
+ $this->name = $this->quiz->nameCurrentPlayer();
+ $this->player = $this->quiz->numberCurrentPlayer()-1;
+ $this->totQuestions = $this->quiz->numQuestForPlayer();
$this->risposteDate = $this->quiz->getRisposteDate();
}
}
\ No newline at end of file
Modified:
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/_boardPlayer.php
===================================================================
--- plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/_boardPlayer.php
2010-01-31 14:52:46 UTC (rev 27349)
+++ plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/_boardPlayer.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -1,10 +1,10 @@
-Percorso giocatore <?php echo $nome?>
+<?php __('Player %name% results', array('%name%' => $name))?>
-<?php for ($d=1; $d<=$totDomande; $d++):?>
+<?php for ($d=1; $d<=$totQuestions; $d++):?>
<div>
-<?php echo $d.': ' ?>
-<?php if (isset($risposteDate[$giocatore+1][$d])):?>
-<?php echo $risposteDate[$giocatore+1][$d]['giusta'] ? __('Correct') :
__('Wrong') ?>
+
+<?php if (array_key_exists($player+1, $risposteDate) &&
isset($risposteDate[$player+1][$d]['correct'])):?>
+<?php echo $risposteDate[$player+1][$d]['correct'] ? __('Correct') :
__('Wrong') ?>
<?php else: ?>
<?php echo __('To respond') ?>
Modified:
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/gameSuccess.php
===================================================================
--- plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/gameSuccess.php
2010-01-31 14:52:46 UTC (rev 27349)
+++ plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/gameSuccess.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -4,16 +4,16 @@
</div>
<h2>
-<?php echo __('Question %num% for the player %nome%', array('%num%' =>
$quiz->numeroDomandaCorrente(), '%nome%' => $quiz->nomeGiocatoreCorrente()))?>
+<?php echo __('Question %num% for the player %name%', array('%num%' =>
$quiz->numberCurrentQuestion(), '%name%' => $quiz->nameCurrentPlayer()))?>
</h2>
<p>
-<?php echo $domanda ?>
+<?php echo $question ?>
</p>
<form method="post">
-<?php foreach ($risposte as $i => $risposta): ?>
-<input type="radio" name="risposta" value="<?php echo $i ?>" />
-<?php echo $risposta['testo'] ?><br />
+<?php foreach ($answers as $i => $answer): ?>
+<input type="radio" name="answer" value="<?php echo $i ?>" />
+<?php echo $answer['text'] ?><br />
<?php endforeach ?>
<input type="submit" value=">>">
Modified:
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/indexSuccess.php
===================================================================
--- plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/indexSuccess.php
2010-01-31 14:52:46 UTC (rev 27349)
+++ plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/indexSuccess.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -1,8 +1,8 @@
<p><?php echo __('Welcome') ?></p>
<form method="post">
-<?php echo $form['numeroGiocatori']->renderRow() ?><br />
-<?php echo $form['numeroDomandePerGiocatore']->renderRow() ?><br />
+<?php echo $form['playersNumber']->renderRow() ?><br />
+<?php echo $form['numberQuestionsForPlayer']->renderRow() ?><br />
<?php echo $form->renderHiddenFields() ?>
<input type="submit" value="<?php echo _('>>') ?>">
Modified:
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/namesOfPlayersSuccess.php
===================================================================
---
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/namesOfPlayersSuccess.php
2010-01-31 14:52:46 UTC (rev 27349)
+++
plugins/sfQuizPlugin/trunk/modules/sfQuizStart/templates/namesOfPlayersSuccess.php
2010-01-31 15:12:34 UTC (rev 27350)
@@ -1,11 +1,11 @@
<form method="post">
-<?php foreach ($form['newNomiGiocatori'] as $i => $nome): ?>
+<?php foreach ($form['newNameOfPlayers'] as $i => $nome): ?>
<div>
- <?php echo $nome['nomeGiocatore']->renderLabel(__('Nome giocatore %num%',
array('%num%' => ($i+1)))) ?>
- <?php echo $nome['nomeGiocatore']->render() ?>
- <?php echo $nome['nomeGiocatore']->renderError() ?>
+ <?php echo $nome['playerName']->renderLabel(__('Nome giocatore %num%',
array('%num%' => ($i+1)))) ?>
+ <?php echo $nome['playerName']->render() ?>
+ <?php echo $nome['playerName']->renderError() ?>
</div>
<?php endforeach; ?>
<?php echo $form->renderHiddenFields() ?>
--
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.