Ejemplo n.º 1
0
 public function equals(\Uci\Bundle\BaseDatosBundle\Entity\Pregunta $pregunta)
 {
     $esIgual = FALSE;
     if (strcasecmp($this->titulo, $pregunta->getTitulo()) == 0) {
         $respuestasParametro = $pregunta->getRespuesta();
         if (count($this->respuesta) > 0) {
             if (count($this->respuesta) == count($respuestasParametro)) {
                 foreach ($this->respuesta as $respuestActual) {
                     $esIgual = FALSE;
                     foreach ($respuestasParametro as $respuestParametro) {
                         if ($respuestActual->getTextoRespuesta() == $respuestParametro->getTextoRespuesta()) {
                             $esIgual = TRUE;
                         }
                     }
                     if ($esIgual == FALSE) {
                         break;
                     }
                 }
             } else {
                 $esIgual = FALSE;
             }
         } else {
             $esIgual = TRUE;
         }
     } else {
         $esIgual = FALSE;
     }
     return $esIgual;
 }
 /**
  * {@inheritDoc}
  */
 public function equals(\Uci\Bundle\BaseDatosBundle\Entity\Pregunta $pregunta)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'equals', array($pregunta));
     return parent::equals($pregunta);
 }
Ejemplo n.º 3
0
 private function importarArchivo(&$arregloPreguntas, $tipoRespuesta, $ubicacion)
 {
     $em = $this->getDoctrine()->getManager();
     $preguntasParametro = $em->getRepository('UciBaseDatosBundle:Pregunta')->findAll();
     $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject($ubicacion);
     $objWorksheet = $phpExcelObject->setActiveSheetIndex(0);
     $highestRow = $objWorksheet->getHighestRow();
     //Se recorre toda la hoja excel desde la fila 2 y se almacenan los datos
     for ($row = 4; $row <= $highestRow; ++$row) {
         $dataRow = $objWorksheet->rangeToArray('A' . $row . ':' . 'E' . $row, null, true, true, true);
         if (isset($dataRow[$row]['A']) && $dataRow[$row]['A'] > '') {
             if (strpos($dataRow[$row]['A'], "::") === 0 && isset($dataRow[$row]['C']) && $dataRow[$row]['C'] > '') {
                 $pregunta = new Pregunta();
                 $textoPregunta = trim($dataRow[$row]['C']);
                 $pregunta->setTitulo($textoPregunta);
                 $pregunta->setTipoRespuesta($tipoRespuesta);
             } else {
                 if (strpos($dataRow[$row]['A'], "=") === 0 || strpos($dataRow[$row]['A'], "~") === 0) {
                     $respuesta = new Respuesta();
                     $textoRespuesta = trim($dataRow[$row]['C']);
                     $respuesta->setTextoRespuesta($textoRespuesta);
                     if (isset($dataRow[$row]['E']) && $dataRow[$row]['E'] > '' && $dataRow[$row]['E'] != 'Feedback') {
                         $textoRetroalimentacion = trim($dataRow[$row]['E']);
                         $respuesta->setTextoRetroalimentacion($textoRetroalimentacion);
                     }
                     if (strpos($dataRow[$row]['A'], "=") === 0) {
                         $esCorrecta = 1;
                     } else {
                         if (strpos($dataRow[$row]['A'], "~") === 0) {
                             $esCorrecta = 0;
                         }
                     }
                     $respuesta->setCorrecta($esCorrecta);
                     $pregunta->addRespuesta($respuesta);
                 }
             }
             if (strpos($dataRow[$row]['A'], "}") === 0 && $this->existePregunta($pregunta, $preguntasParametro) == FALSE) {
                 $arregloPreguntas[] = $pregunta;
             }
         }
         //endif
     }
     //end for
 }