$operations = $ds->loadList($sql); $old_plagesop = 0; $old_operation_id = 0; $nb_oper_par_plage = 0; $nb_plage[$_prat->user_id] = 0; $preparation[$_prat->user_id] = array(); foreach ($operations as $keyOp => $curr_op) { if ($old_operation_id and $old_plagesop == $curr_op["plageop_id"]) { $testValid = 30 * 60 > $curr_op["sec_entree"] - $operations[$old_operation_id]["sec_sortie"]; $testValid = $testValid && $operations[$old_operation_id]["sec_sortie"] < $curr_op["sec_entree"]; if ($testValid) { $preparation[$_prat->user_id][] = $curr_op["sec_entree"] - $operations[$old_operation_id]["sec_sortie"]; $nb_oper_par_plage++; if ($nb_oper_par_plage == 1) { $nb_plage[$_prat->user_id] = $nb_plage[$_prat->user_id] + 1; } } } else { $nb_oper_par_plage = 0; } $old_operation_id = $keyOp; $old_plagesop = $curr_op["plageop_id"]; } if (count($preparation[$_prat->user_id])) { // Mémorisation des données dans MySQL $sql = "INSERT INTO `temps_prepa` (`temps_prepa_id`, `chir_id`, `nb_prepa`, `nb_plages`, `duree_moy`, `duree_ecart`)\r\n VALUES (NULL, \r\n '{$_prat->user_id}',\r\n '" . count($preparation[$_prat->user_id]) . "',\r\n '" . $nb_plage[$_prat->user_id] . "',\r\n '" . strftime("%H:%M:%S", CMbArray::average($preparation[$_prat->user_id])) . "',\r\n '" . strftime("%H:%M:%S", CMbArray::variance($preparation[$_prat->user_id])) . "');"; $ds->exec($sql); $ds->error(); } } echo "Liste des temps de Préparation mise à jour";
public function testAverage() { $this->assertEquals(10, $this->stub->average(array(5, 10, 15))); }