Пример #1
0
 public function createObject()
 {
     $obj = new Study();
     $obj->setName('prueba');
     $obj->save();
     return $obj;
 }
Пример #2
0
/**
 * get data for an individual study based on 
 * the user's researcher_id and a supplied study_id
 * creates $study smarty variable
 */
function smarty_function_study($params, &$smarty)
{
    if (!Check::digits($params['study_id'])) {
        $smarty->assign('study', array());
        return;
    }
    $s = new Study();
    $study = $s->study($_SESSION['user']['researcher_id'], $params['study_id']);
    $p = new Enrollment();
    $participants = $p->howmany(array(" where study_id=%u and active>0 ", $params['study_id']));
    $smarty->assign('study', $study);
    $smarty->assign('participants', $participants);
}
Пример #3
0
 public function saveschedule()
 {
     try {
         if (!Check::digits($_POST['study_id'], $empty = false)) {
             throw new Exception("bad study id!");
         } else {
             $study_id = $_POST['study_id'];
         }
         if (!Check::digits($_POST['task_id'])) {
             throw new Exception("bad task id!");
         } else {
             $task_id = $_POST['task_id'];
         }
         // start and end date are taken from the study itself
         if (Check::isdate($_POST['startdate'])) {
             $startdate = $_POST['startdate'];
         } else {
             throw new Exception("bad startdate");
         }
         if (Check::isdate($_POST['enddate'])) {
             $enddate = $_POST['enddate'];
         } else {
             throw new Exception("bad enddate");
         }
         list($startdate, $enddate) = Check::order($startdate, $enddate);
         $st = new Study();
         $study = $st->getone($study_id);
         if ($startdate < $study['startdate']) {
             $startdate = $study['startdate'];
         }
         if ($enddate > $study['enddate']) {
             $enddate = $study['enddate'];
         }
         $timesofday = trim($_POST['timesofday']);
         $timesofday = preg_replace('#\\s#', '', $timesofday);
         $timesofday = preg_replace('#,#', ';', $timesofday);
         if (!preg_match('#^(?:\\d\\d?\\:\\d\\d;|\\d\\d?\\:\\d\\d$)*$#', $timesofday)) {
             throw new Exception("bad timesofday - format HH:MM;...");
         }
         $tsod = array();
         foreach (explode(";", $timesofday) as $tod) {
             if (empty($tod)) {
                 continue;
             }
             list($hour, $min) = explode(":", $tod);
             if ($hour >= 0 and $hour <= 23 and $min >= 0 and $min <= 59) {
                 $tsod[] = sprintf("%02d:%02d", $hour, $min);
             }
         }
         $timesofday = implode(";", $tsod);
         $daysofweek = $_POST['daysofweek'];
         $daysofweek = preg_replace('#\\s#', '', $daysofweek);
         $daysofweek = preg_replace('#;#', ',', $daysofweek);
         if (!preg_match('#^(?:\\w+(?:,|$))*#', $daysofweek)) {
             throw new Exception("bad daysofweek should be: Mon,Tue,...");
         }
         $dsow = array();
         foreach (explode(",", $daysofweek) as $dow) {
             if (!preg_match('#^(mon|tue|wed|thu|fri|sat|sun)?#i', $dow, $m)) {
                 continue;
             }
             if ($m[1] == "") {
                 continue;
             }
             $dsow[] = ucfirst(strtolower($m[1]));
         }
         $daysofweek = implode(",", $dsow);
         $s = new Schedule();
         if ($s->upd(array('task_id' => $task_id, 'study_id' => $study_id), array('startdate' => $startdate, 'enddate' => $enddate, 'timesofday' => $timesofday, 'daysofweek' => $daysofweek)) === false) {
             throw new Exception($s->err());
         }
         View::assign('task_id', $task_id);
         View::assign('study_id', $study_id);
         return 'task.tpl';
     } catch (Exception $e) {
         $this->err($e);
         View::assign('error', $this->error);
         return 'error.tpl';
     }
 }
Пример #4
0
/**
 * show a list of study links
 */
function smarty_function_studies($params, &$smarty)
{
    $s = new Study();
    $smarty->assign('studies', $s->studies($_SESSION['user']['researcher_id'], $params['all'] ? 1 : 0));
}
Пример #5
0
 /**
  * calculate profile completion for member
  * 
  * @author EL GUENNUNI Sohaib s.elguennuni@gmail.com
  * @param [int] 
  * @return [int]
  */
 public function calculateProfileCompletion($idMember, $regulate = 25)
 {
     $completion = 25;
     $experience = new Experience();
     $skills = new MemberSkill();
     $study = new Study();
     if (count($experience->getExperienceByMember($idMember)) > 0) {
         $completion += $regulate;
     }
     if (count($skills->getSkillsByMember($idMember)) > 0) {
         $completion += $regulate;
     }
     if (count($study->getStudyByMember($idMember)) > 0) {
         $completion += $regulate;
     }
     return $completion;
 }