Ejemplo n.º 1
0
function getFeasibleCandidates($reqs = NULL)
{
    /**
     * Gets initial list of feasible candidates. Requirements are needed?
     * It also returns the profile of each initial candidate
     */
    global $conn, $token, $debugar, $moodle;
    if (FALSE) {
        // Check if "user" is inside $reqs
        if ($reqs['userRequest'] != null) {
            //$sql = 'SELECT * FROM zer_users WHERE username != \''.$reqs['userRequest'].'\'';
            $sql = 'SELECT * FROM ' . TABLE_USERS;
        } else {
            //$userCred = checkTokenESB($token);
            //$sql = 'SELECT * FROM zer_users WHERE username != "'.$userCred['username'].'"';
        }
    }
    $sql = 'SELECT * FROM ' . TABLE_USERS;
    if ($moodle) {
        // If we are in Moodle environment, the feasible candidates are the ones registered in moodle.
        // Obtain list of users (core_user_get_users)
        // Add them the the select or filter the results according them
        $url = 'http://moodle.projectcollage.eu/webservice/rest/server.php';
        if ($debugar) {
            echo 'getFeasibleCandidates: getting ' . $url . '<br />' . "\n";
        }
        $param = 'wstoken=e85ad37a66710486d3ced2fab08de5da&moodlewsrestformat=json&wsfunction=core_user_get_users&criteria[0][key]=auth&criteria[0][value]=cas';
        $candidates = requestER($url, $param);
        if ($debugar) {
            echo 'getFeasibleCandidates: List of CAS users: ' . $candidates . '<br />' . "\n";
        }
    }
    $result = consulta($sql, $conn);
    $out = array();
    while ($obj = pg_fetch_object($result)) {
        // Convert stdClass to array
        //$candidate = objectToArray(json_decode(json_encode($obj), true));
        $candidate = json_decode(json_encode($obj), true);
        $candidate['profile'] = getCandidateProfile($candidate['username']);
        //($candidate['userid']);
        $out[] = $candidate;
    }
    return $out;
}
Ejemplo n.º 2
0
function translateRequestToRequirements_OLD($userid)
{
    /**
     * Translates the preferences ($_REQUEST) of the user to requirements.
     * If mainskills == 'implicit', set skills requirements according to the own
     * data of the $userid
     * @author  Germán Sánchez (GREC-ESADE), Collage
     * @version 11.03.2014
     */
    global $debugar;
    $mainSkills = $_REQUEST['mainskills'];
    $skills = $_REQUEST['skills'];
    $skillsLevels = $_REQUEST['skills_levels'];
    $qualifications = $_REQUEST[STRING_SUBSKILLS];
    $qualificationsLevels = $_REQUEST['qualifications_levels'];
    $proximity = $_REQUEST['proximity'];
    $content = '<h2>Parameters:</h2>';
    $requirements = array();
    // Skills
    if ($mainSkills == 'implicit') {
        // Implicit skills: same as users'.
        $userSkills = getCandidateProfile($userid)['skills'];
        $skills = array();
        $skillsLevels = array();
        foreach ($userSkills as $userSkill) {
            $skills[] = $userSkill['id'];
            $skillsLevels[] = $userSkill['level'];
        }
    }
    // Explicit skills
    if (!isset($skills)) {
        $content .= '<p>No expertise skills selected</p>';
    } else {
        $content .= '
      <p>Skills: 
    ';
        //var_dump($_REQUEST);
        //echo '<pre>'.print_r($_REQUEST).'</pre>';
        $requirements['skills'] = array();
        $i = 0;
        foreach ($skills as $selectedOption) {
            $content .= $selectedOption . '-' . $skillsLevels[$i] . ' ';
            if ($selectedOption > 0) {
                // Set the variable at maximum requirement
                $requirements['skills'][] = array('id' => $selectedOption, 'level' => $skillsLevels[$i]);
            }
            $i++;
        }
        $content .= '</p>' . "\n";
    }
    // Subskills
    if (!isset($qualifications)) {
        $content .= '<p>No ' . STRING_SUBSKILLS . ' selected</p>';
    } else {
        $content .= '
      <p>' . may1a(STRING_SUBSKILLS) . ':
    ';
        $requirements[STRING_SUBSKILLS] = array();
        $i = 0;
        foreach ($qualifications as $selectedOption) {
            $content .= $selectedOption . ' ';
            if ($selectedOption > 0) {
                // Set the variable at maximum requirement
                //$requirements['qualifications'][] = array('id' => $selectedOption, 'level' => $qualificationsLevels[$i]);
                $requirements[STRING_SUBSKILLS][] = array('id' => $selectedOption);
            }
            $i++;
        }
        $content .= '</p>' . "\n";
    }
    // Proximity
    if (isset($proximity)) {
        // Ensure that the proximity required is valid
        if ($proximity != 'high' and $proximity != 'low' and $proximity != 'disable') {
            $proximity = 'disable';
        }
        $content .= '
      <p>Proximity: ' . $proximity . '</p>
    ';
        $requirements['proximity'] = array('level' => $proximity);
    }
    // Availability (by now, always high)
    $requirements['availability'] = array('level' => 'high');
    if ($debugar) {
        echo $content;
    }
    return $requirements;
}