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; }
function showRecommendations($jrec, $req) { global $debugar; $content = ''; $rec = objectToArray(json_decode($jrec)); // Retrieve list of skills and qualifications $sysSkills = objectToArray(requestER('er/skills')); $sysQualif = objectToArray(requestER('er/' . STRING_SUBSKILLS)); // Analyse the recommendations $content .= '<h2>Recommended experts:</h2>'; // RAW if ($debugar) { $content .= '<p>Raw recommendation:<pre>' . print_r($rec, TRUE) . '</pre>'; } // HTML $i = 1; $content .= '<ol id="recommendations">'; $lastAssess = -1; foreach ($rec as $expert) { if ($lastAssess == $expert['assess']) { // Mantenemos el numero $ii = $iiAnt; } else { $ii = $i; $iiAnt = $ii; $lastAssess = $expert['assess']; } $txtClass = ''; if ($i == count($rec)) { //$txtClass = ' class="clear"'; } $content .= ' <li class="candidate" value="' . $iiAnt . '"' . $txtClass . '><strong>' . $expert['firstname'] . ' ' . $expert['lastname'] . '</strong> (' . $expert['department'] . ')<br />Assessment: ' . $expert['assess'] . '.'; $content .= showProfile($expert, $req, $sysSkills, $sysQualif); // Mostramos sus habilidades //$content .= ' Skills:'; $content .= ' </li>' . "\n"; $i = $i + 1; } $content .= '</ol>'; if (FALSE) { // Test: show the objects $content .= '<div class="debugInfo"><h2>Debug information:</h2>'; //$content .= '<h3>Skills list</h3><pre>'.print_r($sysSkills, TRUE). '</pre>'; //$content .= '<h3>Qualifications list</h3><pre>'.print_r($sysQualif, TRUE). '</pre>'; $content .= '<h3 class="float">Raw requirements</h3><pre>' . print_r($req, TRUE) . '</pre>'; $content .= '<h3 class="float">Raw recommendation</h3><pre>' . print_r($rec, TRUE) . '</pre>'; $content .= '</div>'; } return $content; }