Exemple #1
0
 function addskill($_post)
 {
     $user->id = $this->getuser();
     $profile = new Skill($user->id);
     $result = $profile->create($_post);
     return $result;
 }
 public function listSkills()
 {
     $db = new Skill($this->_config);
     $result = $db->getSkills();
     $encodedResult = $this->utf8_converter($result);
     $skills = json_encode($encodedResult);
     echo $skills;
 }
Exemple #3
0
 public function saveSkill(Skill $skill)
 {
     try {
         $skill->save();
     } catch (Exception $e) {
         throw new DaoException($e->getMessage(), $e->getCode(), $e);
     }
 }
 public function testAddSkill()
 {
     $skill = new Skill();
     $skill->setName('Gardening');
     $skill->setDescription('Flower arts');
     $this->skillDao->saveSkill($skill);
     $savedSkill = TestDataService::fetchLastInsertedRecord('Skill', 'id');
     $this->assertTrue($savedSkill instanceof Skill);
     $this->assertEquals('Gardening', $savedSkill->getName());
     $this->assertEquals('Flower arts', $savedSkill->getDescription());
 }
Exemple #5
0
 public function getLevelProgression(Skill $s)
 {
     if ($s->hasXp()) {
         $targetXp = self::$table[$s->level + 1];
         $startXp = self::$table[$s->level];
         $distance = $targetXp - $startXp;
         $xpLeft = $targetXp - $s->xp;
         return $distance / $xpLeft;
     }
     trigger_error('User is not ranked in this skill.');
     return 0;
 }
 public static function getSkillsArray($rows)
 {
     $skills = array();
     if (!empty($rows)) {
         foreach ($rows as $row) {
             $skill = new Skill($row);
             $skill->setSkillId($row['skillId']);
             array_push($skills, $skill);
         }
     }
     return $skills;
 }
Exemple #7
0
 function test_addData_skillCheck()
 {
     Initial::addData();
     $skill = Skill::getAll();
     $result = new Skill("Acrobatics", "Balancing and tumbling", 1);
     $this->assertEquals($skill[0], $result);
 }
 /**
  * Modify user
  */
 public function modify($id)
 {
     $user = User::find($id);
     $skills = Skill::findSkillsForUser($id);
     if (!$user) {
         return Redirect::route('members')->with('mError', 'Cet utilisateur est introuvable !');
     }
     return View::make('user.modify', array('user' => $user, 'skills' => $skills));
 }
/**
 * Save the imported data
 * @param   array   List of users
 * @return  void
 * @uses global variable $inserted_in_course, which returns the list of courses the user was inserted in
 */
function save_data($skills)
{
    if (is_array($skills)) {
        $parents = array();
        foreach ($skills as $index => $skill) {
            if (isset($parents[$skill['parent_id']])) {
                $skill['parent_id'] = $parents[$skill['parent_id']];
            } else {
                $skill['parent_id'] = 1;
            }
            $skill['a'] = 'add';
            $saved_id = $skill['id'];
            $skill['id'] = null;
            $oskill = new Skill();
            $skill_id = $oskill->add($skill);
            $parents[$saved_id] = $skill_id;
        }
    }
}
Exemple #10
0
 protected function tearDown()
 {
     CharClass::deleteAll();
     Character::deleteAll();
     Race::deleteAll();
     Skill::deleteAll();
     Stat::deleteAll();
     Description::deleteAll();
     Background::deleteAll();
 }
 public function post($resourceVals, $data, $userId)
 {
     global $logger, $warnings_payload;
     $userId = 5;
     $skillId = $resourceVals['user-skills'];
     if (isset($skillId)) {
         $warnings_payload[] = 'POST call to /user-skills must not have ' . '/skillID appended i.e. POST /user-skills';
         throw new UnsupportedResourceMethodException();
     }
     if ($data['name'] != null) {
         $nameObj = $this->collapDAO->queryByName($data['name']);
         if (empty($nameObj)) {
             $skillObj = new Skill($data['name']);
             $logger->debug("POSTed Skill Detail: " . $skillObj->toString());
             $this->collapDAO->insert($skillObj);
             $userSkillDetail = $skillObj->toArray();
             if (isset($userSkillDetail['id'])) {
                 $userSkillObj = new UserSkill($userId, $userSkillDetail['id']);
                 $logger->debug("POSTed User Skill Detail: " . $userSkillObj->toString());
                 $this->collapDAO->insertUserSkill($userSkillObj);
                 $userSkillDetail = $userSkillObj->toArray();
             }
         } else {
             $nameSkill = $nameObj[0]->toArray();
             $userSkillObj = new UserSkill($userId, $nameSkill['id']);
             $logger->debug("POSTed User Skill Detail: " . $userSkillObj->toString());
             $this->collapDAO->insertUserSkill($userSkillObj);
             $userSkillDetail = $userSkillObj->toArray();
         }
     } else {
         $userSkillObj = new UserSkill($userId, $data['skill_id']);
         $logger->debug("POSTed User Skill Detail: " . $userSkillObj->toString());
         $this->collapDAO->insertUserSkill($userSkillObj);
         $userSkillDetail = $userSkillObj->toArray();
     }
     if (!isset($userSkillDetail['id'])) {
         return array('code' => '2011');
     }
     $this->userSkillDetail[] = $userSkillDetail;
     return array('code' => '2001', 'data' => array('userSkillDetail' => $this->userSkillDetail));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $opportunity = $this->opportunity->find($id);
     $locations = Location::lists('location_name', 'id');
     $group = Opportunity::find($id);
     $skills = Skill::all();
     $assigned = $group->skills->lists('id');
     if (is_null($opportunity)) {
         return Redirect::route('opportunities.index');
     }
     return View::make('opportunities.edit', compact('opportunity', 'locations', 'group', 'skills', 'assigned'));
 }
Exemple #13
0
 static function find($search_id)
 {
     $found_skill = null;
     $skills = Skill::getAll();
     foreach ($skills as $skill) {
         $skill_id = $skill->getId();
         if ($skill_id == $search_id) {
             $found_skill = $skill;
         }
     }
     return $found_skill;
 }
Exemple #14
0
 /**
  * User goes gym and trains
  * 
  * @return mixed (array/boolean)
  */
 public function train()
 {
     /*
     Session 1-4	100 strength gain per day
     Session 5-14	50 strength gain per day
     Session 15-34	25 strength gain per day
     Session 35-64	10 strength gain per day
     Session 65-124	5 strength gain per day
     Session 125-199	2 strength gain per day
     Session 200+	1 strength gain per day
     */
     $r = Service::getDB()->query("SELECT uid FROM `train_historial` WHERE uid = '" . $this->id . "'");
     $trainedDays = sizeof($r);
     if ($trainedDays < 5) {
         $strengh = 100;
     } elseif ($trainedDays < 15) {
         $strengh = 50;
     } elseif ($trainedDays < 35) {
         $strengh = 25;
     } elseif ($trainedDays < 65) {
         $strengh = 10;
     } elseif ($trainedDays < 125) {
         $strengh = 5;
     } elseif ($trainedDays < 200) {
         $strengh = 2;
     } else {
         $strengh = 1;
     }
     $skill = new Skill();
     $skill->get($this->id);
     $skill->strengh += $strengh;
     if ($skill->save()) {
         Service::getDB()->insert('train_historial', array('uid' => $this->id, 'date' => $this->now()));
         $trainedDays++;
         return array('strengh' => $strengh, 'trainedDays' => $trainedDays);
     } else {
         return false;
     }
 }
 protected function envSkills()
 {
     $skill = new Skill();
     $skill->skill_title = 'PHP';
     $skill->percent = '70';
     $skill->description_title = 'My Skills';
     $skill->description = 'Are Sweet';
     $skill->template_id = 1;
     $skill->save();
     $skill11 = new Skill();
     $skill11->skill_title = 'Javascript';
     $skill11->percent = '50';
     $skill11->description_title = 'My Skills';
     $skill11->description = 'Are Sweet';
     $skill11->template_id = 1;
     $skill11->save();
     $skill12 = new Skill();
     $skill12->skill_title = 'CSS';
     $skill12->percent = '50';
     $skill12->description_title = 'My Skills';
     $skill12->description = 'Are Sweet';
     $skill12->template_id = 1;
     $skill12->save();
     $skill2 = new Skill();
     $skill2->skill_title = 'PHP';
     $skill2->percent = '20';
     $skill2->description_title = 'My Skills';
     $skill2->description = 'Are Sweet';
     $skill2->template_id = 2;
     $skill2->save();
     $skill3 = new Skill();
     $skill3->skill_title = 'PHP';
     $skill3->percent = '20';
     $skill3->description_title = 'My Skills';
     $skill3->description = 'Are Sweet';
     $skill3->template_id = 3;
     $skill3->save();
 }
 public function actionIndex()
 {
     $type = Type::model()->findAll();
     $skill = Skill::model()->findAll();
     $usr = User::model()->findbyPk(1);
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->order = 'rand()';
     $total = Portfolio::model()->count();
     $pages = new CPagination($total);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     $port = Portfolio::model()->findAll($criteria);
     $this->render('index', array('type' => $type, 'port' => $port, 'pages' => $pages, 'skill' => $skill, 'usr' => $usr));
 }
 protected function set($key, $value)
 {
     parent::set($key, $value);
     switch ($key) {
         case 'tier':
             $this->_tier = intval($value);
             break;
         case 'slot':
             $this->_slotType = $value;
             break;
         case 'skills':
             foreach ($value as $skillInfo) {
                 //TODO: This should normally be a "skills" entity set, but it doesn't exist!
                 $skill = new Skill($this->getSet(), $skillInfo['id']);
                 unset($skillInfo['id']);
                 $skill->update($skillInfo, true);
                 $this->_skills[] = $skill;
             }
             break;
         case 'specialization':
             $this->_specializationId = intval($value);
             break;
     }
 }
 /**
  * Resets all references to other model objects or collections of model objects.
  *
  * This method is a user-space workaround for PHP's inability to garbage collect
  * objects with circular references (even in PHP 5.3). This is currently necessary
  * when using Propel in certain daemon or large-volume/high-memory operations.
  *
  * @param boolean $deep Whether to also clear the references on all referrer objects.
  */
 public function clearAllReferences($deep = false)
 {
     if ($deep && !$this->alreadyInClearAllReferencesDeep) {
         $this->alreadyInClearAllReferencesDeep = true;
         if ($this->aUser instanceof Persistent) {
             $this->aUser->clearAllReferences($deep);
         }
         if ($this->aSkill instanceof Persistent) {
             $this->aSkill->clearAllReferences($deep);
         }
         $this->alreadyInClearAllReferencesDeep = false;
     }
     // if ($deep)
     $this->aUser = null;
     $this->aSkill = null;
 }
Exemple #19
0
 private function setSkillsRequired($skills = array())
 {
     $failed = array();
     foreach ($skills as $skill) {
         $skill = Skill::getById($skill);
         if ($skill == null) {
             return false;
         }
         $add = $skill->addSkillForJob($this->jobId);
         if (!$add) {
             $failed[] = $skill->skillId;
         }
     }
     if (!empty($failed)) {
         //log stuffs about error...
     }
     return true;
 }
Exemple #20
0
 public static function actionAddProject($data)
 {
     $project = Project::getEntity($data['id']);
     if ($project->getId() != null) {
         // Save skills
         $new_project = Project::fetchEntity($data);
         $skills = $new_project->getSkills();
         if (count($skills) > 0) {
             foreach ($skills as $skill) {
                 if ($skill->isActive == 1) {
                     Skill::addSkillToProject($skill->id, $new_project->getId());
                 } else {
                     Skill::deleteSkillForProject($skill->id, $new_project->getId());
                 }
             }
         }
         // Return to save the team member
         return true;
     }
     return false;
 }
 public function showWelcome()
 {
     if (Sentry::check()) {
         $user = Sentry::getUser();
         $group = User::find($user->id);
         $skills = Skill::all();
         $assigned = $group->skills->lists('id');
         $user_object = User::find($user->id);
         $locations = Location::all();
         $location_assigned = $group->locations->lists('id');
         //for an oppurtunity if and skills match then check against location
         $skillmatches = Skill::with('opportunities')->with('users')->has('opportunities')->has('users')->get();
         //if the oppurtunity and location match send email and display in Matches on feed
         $events = Community_event::all();
         //array to store docs without tags
         $usermatches = User::with('locations')->has('locations')->get();
         $opportunitymatches = Opportunity::with('location')->with('skills')->get();
         return View::make('hello', compact('skillmatches', 'opportunitymatches', 'skills', 'assigned', 'locations', 'location_assigned', 'events'));
     } else {
         return View::make('hello');
     }
 }
Exemple #22
0
        }
        $app->render('skills/delete.html', $data);
    })->via('GET', 'POST')->name('skills_delete');
    $app->map('/new', function () use($app, $data) {
        if ($app->request->isPost()) {
            $edu_level = EducationLevel::find($app->request->post('educationlevel'));
            $skill = new Skill();
            $skill->name = $app->request->post('title');
            $skill->save();
            $data['new_skill'] = $skill;
        }
        $app->render('skills/new.html', $data);
    })->via('GET', 'POST')->name('skills_new');
    $app->map('/edit/:id', function ($id) use($app, $data) {
        $data['request_method'] = $app->request->getMethod();
        $skill = Skill::find($id);
        if ($app->request->isGet()) {
            $data['skill'] = $skill->toArray();
        } else {
            if ($app->request->isPost()) {
                $skill->name = $app->request->post('title');
                $skill->save();
                $data['new_skill'] = $skill->toArray();
            }
        }
        $app->render('skills/edit.html', $data);
    })->via('GET', 'POST')->name('skills_edit');
});
$app->group('/schools', function () use($app, $data) {
    $data['request_method'] = $app->request->getMethod();
    $app->get('/', function () use($app, $data) {
Exemple #23
0
$deflect = in('deflect') ? true : NULL;
$simultaneousKill = NULL;
// *** Not simultaneous by default. ***
$stealthAttackDamage = $attacker_str;
$turns_to_take = null;
// *** Even on failure take at least one turn. ***
$attack_type = 'attack';
// *** Default attack category type is single attack. ***
if ($blaze) {
    $attack_type = 'blaze';
} elseif ($deflect) {
    $attack_type = 'deflect';
} elseif ($duel) {
    $attack_type = 'duel';
}
$skillListObj = new Skill();
$ignores_stealth = $skillListObj->getIgnoreStealth($attack_type);
$required_turns = $skillListObj->getTurnCost($attack_type);
// *** Attack Legal section ***
$attacker = $username;
$params = array('required_turns' => $required_turns, 'ignores_stealth' => $ignores_stealth);
assert($attacker != $target);
$AttackLegal = new AttackLegal($attacker, $target, $params);
// *** There's a same-domain problem with this attack-legal now that it's been modified for skills ***
// ***  MAIN BATTLE ALGORITHM  ***
if (!$AttackLegal->check()) {
    // *** Display the reason the attack failed.
    echo "<div class='ninja-error centered'>" . $AttackLegal->getError() . "</div>";
} else {
    // *** ATTACKING + STEALTHED SECTION  ***
    if (!$duel && $attacker_status['Stealth']) {
<?php

/* For licensing terms, see /license.txt */
/**
 *  @package chamilo.admin
 */
use ChamiloSession as Session;
$cidReset = true;
//require_once '../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
if (api_get_setting('skill.allow_skills_tool') != 'true') {
    api_not_allowed();
}
$interbreadcrumb[] = array('url' => 'index.php', "name" => get_lang('PlatformAdmin'));
$skill = new Skill();
$skill_profile = new SkillProfile();
$skill_rel_user = new SkillRelUser();
$url = api_get_path(WEB_AJAX_PATH) . 'skill.ajax.php';
$tpl = new Template(get_lang('Skills'));
$form = new FormValidator('profile_search');
$form->addElement('header', get_lang('SearchSkills'));
$form->addElement('select', 'skills', null, null, array('id' => 'skills'));
$form->addButtonSearch(get_lang('Search'));
$profiles = $skill_profile->get_all();
$tpl->assign('profiles', $profiles);
$total_skills_to_search = array();
if ($form->validate()) {
    $values = $form->getSubmitValues();
    $skills = $values['skills'];
    if (!empty($skills)) {
Exemple #25
0
     if (api_is_student_boss() && empty($userIdList)) {
         $count = 0;
         break;
     }
     if ($action == 'get_user_course_report') {
         $count = CourseManager::get_count_user_list_from_course_code(false, null, $courseCodeList, $userIdList, $sessionIdList);
     } else {
         $count = CourseManager::get_count_user_list_from_course_code(true, array('ruc'), $courseCodeList, $userIdList, $sessionIdList);
     }
     break;
 case 'get_course_exercise_medias':
     $course_id = api_get_course_int_id();
     $count = Question::get_count_course_medias($course_id);
     break;
 case 'get_user_skill_ranking':
     $skill = new Skill();
     $count = $skill->get_user_list_skill_ranking_count();
     break;
 case 'get_course_announcements':
     $count = AnnouncementManager::getAnnouncements(null, null, true);
     break;
 case 'get_work_teacher':
     require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php';
     $count = getWorkListTeacher(0, $limit, $sidx, $sord, $whereCondition, true);
     break;
 case 'get_work_student':
     require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php';
     $count = getWorkListStudent(0, $limit, $sidx, $sord, $whereCondition, true);
     break;
 case 'get_work_user_list_all':
     require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php';
Exemple #26
0
 public function EditResume()
 {
     if (Auth::check()) {
         $user = Auth::user();
         $id = $user->id;
         $resume = User::find($id)->resume()->first();
         if (!is_null($resume)) {
             $project = Resume::find($id)->userproject()->get();
         }
         $skills = Skill::lists('skill');
         $professions = Profession::lists('profession');
         return View::make('register.resumes', compact('user', 'resume', 'project', 'skills', 'professions'));
     } else {
         return Redirect::guest('ow_login');
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $this->skill->find($id)->delete();
     return Redirect::route('skills.index');
 }
 } else {
     if ($isDRH) {
         $selectedCourse = isset($_REQUEST['course']) ? intval($_REQUEST['course']) : null;
         $selectedSkill = isset($_REQUEST['skill']) ? intval($_REQUEST['skill']) : 0;
         $action = null;
         if (!empty($selectedCourse)) {
             $action = 'filterByCourse';
         } else {
             if (!empty($selectedSkill)) {
                 $action = 'filterBySkill';
             }
         }
         $courses = CourseManager::get_courses_list();
         $tableRows = array();
         $reportTitle = null;
         $objSkill = new Skill();
         $skills = $objSkill->get_all();
         switch ($action) {
             case 'filterByCourse':
                 $course = api_get_course_info_by_id($selectedCourse);
                 $reportTitle = sprintf(get_lang('AchievedSkillInCourseX'), $course['name']);
                 $tableRows = $objSkill->listAchievedByCourse($selectedCourse);
                 break;
             case 'filterBySkill':
                 $skill = $objSkill->get($selectedSkill);
                 $reportTitle = sprintf(get_lang('StudentsWhoAchievedTheSkillX'), $skill['name']);
                 $students = UserManager::getUsersFollowedByUser($userId, STUDENT, false, false, false, null, null, null, null, null, null, DRH);
                 $coursesFilter = array();
                 foreach ($courses as $course) {
                     $coursesFilter[] = $course['id'];
                 }
 * @package chamilo.admin
 */
$cidReset = true;
//require_once '../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
if (api_get_setting('skill.allow_skills_tool') != 'true') {
    api_not_allowed();
}
$interbreadcrumb[] = array('url' => Container::getRouter()->generate('administration'), "name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'skill_list.php', 'name' => get_lang('ManageSkills'));
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('CreateSkill'));
/* Process data */
$skillParentId = isset($_GET['parent']) ? intval($_GET['parent']) : 0;
$formDefaultValues = [];
$objSkill = new Skill();
$objGradebook = new Gradebook();
if ($skillParentId > 0) {
    $skillParentInfo = $objSkill->get_skill_info($skillParentId);
    $formDefaultValues = ['parent_id' => $skillParentInfo['id'], 'gradebook_id' => []];
    foreach ($skillParentInfo['gradebooks'] as $gradebook) {
        $formDefaultValues['gradebook_id'][] = intval($gradebook['id']);
    }
}
$allSkills = $objSkill->get_all();
$allGradebooks = $objGradebook->find('all');
$skillList = [0 => get_lang('None')];
$gradebookList = [];
foreach ($allSkills as $skill) {
    $skillList[$skill['id']] = $skill['name'];
}
<?php

/* For licensing terms, see /license.txt */
/**
 *  @package chamilo.admin
 */
$cidReset = true;
require_once '../inc/global.inc.php';
$this_section = SECTION_MYPROFILE;
api_block_anonymous_users();
if (api_get_setting('allow_skills_tool') != 'true') {
    api_not_allowed();
}
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = api_get_js('jqueryui-touch-punch/jquery.ui.touch-punch.min.js');
$htmlHeadXtra[] = api_get_js('jquery.jsPlumb.all.js');
$htmlHeadXtra[] = api_get_js('skills.js');
$skill = new Skill();
$type = 'read';
//edit
$tree = $skill->get_skills_tree(api_get_user_id(), null, true);
$skill_visualizer = new SkillVisualizer($tree, $type);
$url = api_get_path(WEB_AJAX_PATH) . 'skill.ajax.php?1=1';
$tpl = new Template(null, false, false);
$tpl->assign('url', $url);
$tpl->assign('skill_visualizer', $skill_visualizer);
$content = $tpl->fetch('default/skill/skill_tree_student.tpl');
$tpl->assign('content', $content);
$tpl->display_no_layout_template();