Example #1
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(EscalasPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(EscalasPeer::DATABASE_NAME);
         $criteria->add(EscalasPeer::ID, $pks, Criteria::IN);
         $objs = EscalasPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #2
0
 /**
  * Get the associated Escalas object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Escalas The associated Escalas object.
  * @throws     PropelException
  */
 public function getEscalas(PropelPDO $con = null)
 {
     if ($this->aEscalas === null && $this->escalas_id !== null) {
         $this->aEscalas = EscalasPeer::retrieveByPk($this->escalas_id);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aEscalas->addPercentiless($this);
         		 */
     }
     return $this->aEscalas;
 }
Example #3
0
 public static function calcularmillon($resultadosParciales)
 {
     $resultados = Test::cargarResultadosExcel($resultadosParciales);
     $aspirante = $resultadosParciales[0]->getAspirantes();
     //        $aspirante = new Aspirantes();
     $edad = $aspirante->getEdad();
     $sexo = $aspirante->getSexo();
     $datos = array("G12" => $sexo, "G14" => $edad);
     $idAspirante = $aspirante->getId();
     $resultado = ResultadosPeer::getResultado($resultadosParciales[0]->getPruebas()->getId(), $aspirante->getId());
     $resultadoMillon = test::procesarMillon($resultados, $datos, $idAspirante);
     // esto me devuelve un arreglo con las escalas y sus valores
     $aprobado = true;
     // inicializo un marcador de aprobacion del test
     //        var_dump($resultadoMillon); die();
     foreach ($resultadoMillon as $escala => $valor) {
         // Busco en la base de datos la escala correspondiente por nombre
         $criteria = new Criteria();
         $criteria->add(EscalasPeer::NOMBRE, $escala);
         $Escala = EscalasPeer::doSelectOne($criteria);
         // Creo el Resultadosescalas
         $result = new Resultadosescalas();
         $result->setEscalas($Escala);
         // le seteo la Escala
         $result->setValor($valor);
         // le seteo el valor
         $result->setResultados($resultado);
         // la asocio a el resultado general del test
         $result->save();
         // lo guardo
         if ($escala == "V" and $valor != 0) {
             // si saca algo distito a 0(cero) en la escala de validez, queda afuera
             $aprobado = false;
         }
         if ($escala != "V" and $valor > 70) {
             // si saca mas de 70 en cualquier otra escala, queda afuera
             $aprobado = false;
         }
     }
     // segun aprobado le sereo el estado del resultado Aprobacion o NO
     $resultado->setEstadosresultadosId($aprobado == true ? 1 : 2);
     // TODO: manopleado??
     $resultado->save();
     // guardo el resultado
     // no me quedaria nada mas por hacer ya estaria todo guardado.
 }
Example #4
0
 /**
  * Returns the number of related Escalas objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related Escalas objects.
  * @throws     PropelException
  */
 public function countEscalass(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(TestsPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collEscalass === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(EscalasPeer::TESTS_ID, $this->id);
             $count = EscalasPeer::doCount($criteria, false, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return count of the collection.
             $criteria->add(EscalasPeer::TESTS_ID, $this->id);
             if (!isset($this->lastEscalasCriteria) || !$this->lastEscalasCriteria->equals($criteria)) {
                 $count = EscalasPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collEscalass);
             }
         } else {
             $count = count($this->collEscalass);
         }
     }
     return $count;
 }
Example #5
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = EscalasPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setTestsId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setNombre($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setNombrelargo($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setDescripcion($arr[$keys[4]]);
     }
 }
 /**
  * Selects a collection of Percentiles objects pre-filled with all related objects.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of Percentiles objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     PercentilesPeer::addSelectColumns($criteria);
     $startcol2 = PercentilesPeer::NUM_COLUMNS - PercentilesPeer::NUM_LAZY_LOAD_COLUMNS;
     EscalasPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (EscalasPeer::NUM_COLUMNS - EscalasPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(PercentilesPeer::ESCALAS_ID, EscalasPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BasePercentilesPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = PercentilesPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = PercentilesPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = PercentilesPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             PercentilesPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Escalas rows
         $key2 = EscalasPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = EscalasPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = EscalasPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 EscalasPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (Percentiles) to the collection in $obj2 (Escalas)
             $obj2->addPercentiles($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
<?php

require_once dirname(__FILE__) . '/../bootstrap/unit.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true);
new sfDatabaseManager($configuration);
$t = new lime_test(14);
/*
 * Obtengo la Escala A del 16pf
 */
$criteria = new Criteria();
$criteria->add(EscalasPeer::NOMBRE, "A");
// Escala A
$criteria->add(EscalasPeer::TESTS_ID, 3);
// 16pf
$escala = EscalasPeer::doSelectOne($criteria);
$t->is("A", $escala->getNombre(), "La escala es A");
$percentiles = PercentilesPeer::getPercentilPorEscala($escala->getId(), 0);
$t->is(1, $percentiles[0]->getPercentil(), "En la escala A, 0 puntos = percentil 1");
$percentiles = PercentilesPeer::getPercentilPorEscala($escala->getId(), 1);
$t->is(1, $percentiles[0]->getPercentil(), "En la escala A, 1 puntos = percentil 1");
$percentiles = PercentilesPeer::getPercentilPorEscala($escala->getId(), 2);
$t->is(1, $percentiles[0]->getPercentil(), "En la escala A, 2 puntos = percentil 1");
$percentiles = PercentilesPeer::getPercentilPorEscala($escala->getId(), 3);
$t->is(1, $percentiles[0]->getPercentil(), "En la escala A, 3 puntos = percentil 1");
$percentiles = PercentilesPeer::getPercentilPorEscala($escala->getId(), 4);
$t->is(2, $percentiles[0]->getPercentil(), "En la escala A, 4 puntos = percentil 2");
$percentiles = PercentilesPeer::getPercentilPorEscala($escala->getId(), 5);
$t->is(2, $percentiles[0]->getPercentil(), "En la escala A, 5 puntos = percentil 2");
$percentiles = PercentilesPeer::getPercentilPorEscala($escala->getId(), 6);
$t->is(3, $percentiles[0]->getPercentil(), "En la escala A, 6 puntos = percentil 3");
$percentiles = PercentilesPeer::getPercentilPorEscala($escala->getId(), 7);