/** * {@inheritDoc} */ public function addRespuesta(\Uci\Bundle\BaseDatosBundle\Entity\Respuesta $respuesta) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'addRespuesta', array($respuesta)); return parent::addRespuesta($respuesta); }
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 }