Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Agrega atributo 'publicar' a Encuesta. Elimina CRUD en Pregunta (ya n…

…o necesario).
  • Loading branch information...
commit 868a5290a118da54806333e059a27c06c1c06fbb 1 parent 45c0009
Tute Costa authored
2  README.textile
View
@@ -24,5 +24,3 @@ h3. Installation
h3. Enhancements:
* One question-answer per user!
-* Pregunta CRUD operations are not needed anymore.
-
1  config/schema/frage.sql
View
@@ -23,6 +23,7 @@ DROP TABLE IF EXISTS `fr_encuestas`;
CREATE TABLE `fr_encuestas` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`nombre` varchar(255) DEFAULT NULL,
+ `publicar` tinyint(4) DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
58 controllers/preguntas_controller.php
View
@@ -8,11 +8,6 @@ function beforeFilter() {
$this->Auth->allow('completar');
}
- function index() {
- $this->Pregunta->recursive = 0;
- $this->set('preguntas', $this->paginate());
- }
-
function completar($id) {
$u = $this->Auth->user();
if (!is_array($u)) {
@@ -41,58 +36,5 @@ function completar($id) {
$this->Pregunta->PreguntasVoto->saveAll($this->data);
$this->redirect('/frage/encuestas/resultados/' . $id);
}
-
- function view($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid pregunta', true));
- $this->redirect(array('action' => 'index'));
- }
- $this->set('pregunta', $this->Pregunta->read(null, $id));
- }
-
- function add() {
- if (!empty($this->data)) {
- $this->Pregunta->create();
- if ($this->Pregunta->save($this->data)) {
- $this->Session->setFlash(__('The pregunta has been saved', true));
- $this->redirect(array('controller' => 'encuestas'));
- } else {
- $this->Session->setFlash(__('The pregunta could not be saved. Please, try again.', true));
- }
- }
- $this->set('frEncuestas', $this->Pregunta->Encuesta->find('list'));
- }
-
- function edit($id = null) {
- if (!$id && empty($this->data)) {
- $this->Session->setFlash(__('Invalid pregunta', true));
- $this->redirect(array('action' => 'index'));
- }
- if (!empty($this->data)) {
- if ($this->Pregunta->save($this->data)) {
- $this->Session->setFlash(__('The pregunta has been saved', true));
- $this->redirect(array('controller' => 'encuestas'));
- } else {
- $this->Session->setFlash(__('The pregunta could not be saved. Please, try again.', true));
- }
- }
- if (empty($this->data)) {
- $this->data = $this->Pregunta->read(null, $id);
- }
- $this->set('frEncuestas', $this->Pregunta->Encuesta->find('list'));
- }
-
- function delete($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid id for pregunta', true));
- $this->redirect(array('action'=>'index'));
- }
- if ($this->Pregunta->delete($id)) {
- $this->Session->setFlash(__('Pregunta deleted', true));
- $this->redirect(array('controller' => 'encuestas'));
- }
- $this->Session->setFlash(__('Pregunta was not deleted', true));
- $this->redirect(array('action' => 'index'));
- }
}
?>
6 views/encuestas/form.ctp
View
@@ -50,10 +50,10 @@ $(function(){
<?php
echo $form->input('id');
echo $form->input('nombre');
+echo $form->input('publicar', array('type' => 'checkbox'));
if (isset($this->data['Pregunta']))
-foreach ($this->data['Pregunta'] as $k => $p) {
- echo $this->element('pregunta', array('id' => $k));
-}
+ foreach ($this->data['Pregunta'] as $k => $p)
+ echo $this->element('pregunta', array('id' => $k));
?>
</fieldset>
<p><a href="#add-question" id="add-question">Agregar nueva pregunta</a>.</p>
1  views/preguntas/add.ctp
View
@@ -1 +0,0 @@
-<? include 'form.ctp' ?>
1  views/preguntas/edit.ctp
View
@@ -1 +0,0 @@
-<? include 'form.ctp' ?>
14 views/preguntas/form.ctp
View
@@ -1,14 +0,0 @@
-<div class="frage form">
-<?= $form->create('Pregunta') ?>
-<fieldset>
-<legend><?php __('Agregar / Editar Pregunta') ?></legend>
-<?php
-echo $form->input('id');
-echo $form->input('fr_encuesta_id');
-echo $form->input('pregunta');
-echo $form->input('tipo', array('type' => 'radio', 'options' => $PREGUNTAS_TIPOS,
- 'separator' => '<br>'));
-?>
-</fieldset>
-<?= $form->end('Enviar') ?>
-</div>
10 views/preguntas/index.ctp
View
@@ -1,10 +0,0 @@
-<h2>Encuestas</h2>
-<ul>
-<?
-foreach ($preguntas as $p) {
- echo ' <li><a href="/frage/preguntas/edit/'.$p['Pregunta']['id'].'">' . $p['Pregunta']['pregunta'] . '</a></li>';
-}
-?>
-</ul>
-
-<p><a href="/frage/preguntas/add">Nueva pregunta</a></p>
Please sign in to comment.
Something went wrong with that request. Please try again.