예제 #1
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;
}
예제 #2
0
function showRecommendationTable($requirements, $listaSkills, $listaQualifications, $jrecommendation, $showAssessments = FALSE)
{
    /**
     * Genera una tabla con length(requirements) filas y length(recommendation) columnas
     */
    global $moodle, $courseid;
    // Retrieve list of skills and qualifications
    $sysSkills = objectToArray(requestER('er/skills'));
    $sysQualif = objectToArray(requestER('er/' . STRING_SUBSKILLS));
    $content = '';
    //echo '<pre>'.print_r($requirements, TRUE).'</pre>';
    $rec = objectToArray(json_decode($jrecommendation));
    //echo '<pre>'.print_r($rec, TRUE).'</pre>';
    // Generamos la cabecera en funcion de los requirements
    $content .= '<p>These are the candidates recommended by CER according to your requirements. A <span class="bueno">dark-coloured</span> cell indicates the maximum agreement of the candidate\'s profile to each individual requirement, while <span class="nulo">a light colour</span> states for non-covered requirements.</p>';
    if ($moodle) {
        // Span for showing the messages from moodle.php when enroling users
        $content .= '
    <div id="mensaje">
    </div>
    ';
    }
    $content .= '<table class="recommendation"><thead><tr><th rowspan="2">Candidate</th>';
    $content .= '<th colspan="' . count($requirements['skills']) . '">Skills</th>';
    $contentRow2 = '';
    foreach ($requirements['skills'] as $item) {
        $contentRow2 .= '<th>' . may1a(int2txt($item['id'], $listaSkills)) . '<br />(' . $item['level'] . ')</th>' . "\n";
    }
    if (count($requirements[STRING_SUBSKILLS]) > 0) {
        $content .= '<th colspan="' . count($requirements[STRING_SUBSKILLS]) . '">' . may1a(STRING_SUBSKILLS) . '</th>';
        foreach ($requirements[STRING_SUBSKILLS] as $item) {
            $contentRow2 .= '<th>' . may1a(int2txt($item['id'], $listaQualifications)) . '</th>' . "\n";
        }
    }
    if ($requirements['proximity']['level'] != 'disable') {
        // Proximity a que department?
        $content .= '<th>Proximity to ' . $requirements['proximity']['id'] . '</th>';
        $contentRow2 .= '<th>' . may1a($requirements['proximity']['level']) . '</th>' . "\n";
    }
    $content .= '<th>Availability</th>' . "\n";
    $contentRow2 .= '<th>' . may1a($requirements['availability']['level']) . '</th>' . "\n";
    //$content .= '<th rowspan="2">Adequacy<br />Degree</th></tr><tr>'.$contentRow2;
    $content .= '<th rowspan="2">Relevance</th></tr><tr>' . $contentRow2;
    $content .= '</tr></thead>';
    // Recorremos las recomendaciones y las escribimos en forma de fila
    $content .= '<tbody>';
    $i = 1;
    $lastAssess = -1;
    foreach ($rec as $expert) {
        //echo 'Expert '.$i.': <pre>'.print_r($expert, TRUE).'</pre>';
        if ($i % 2 == 0) {
            $content .= '<tr class="par">';
        } else {
            $content .= '<tr class="impar">';
        }
        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 .= '  <td class="candidate"><strong>' . $iiAnt . '. ' . $expert['firstname'] . ' ' . $expert['lastname'] . '</strong> (' . int2dept($expert['profile']['department']) . ')';
        if ($moodle) {
            require_once 'moodle_functions.php';
            // Obtenemos el ID Moodle del candidato
            $userid_moodle = Moodle_GetUserId($expert['username']);
            if ($userid_moodle != NULL) {
                // Comprobamos si el candidato esta ya enrolado
                $enroled = Moodle_CheckEnrolment($userid_moodle, $courseid);
                if (!$enroled) {
                    // Enrol button
                    //$content .= ' (<a href="#" title="Enrol candidate to course '.$courseid.'">enrol</a>)'."\n";
                    $content .= ' <input type="button" id="btnEnrolment' . $expert['userid'] . '" href="javascript:;" onclick="Moodle_enrolUser(' . $userid_moodle . ', ' . $courseid . ');return false;" value="Enrol" />' . "\n";
                } else {
                    // Unenrol button
                    $content .= ' <input type="button" id="btnEnrolment' . $expert['userid'] . '" href="javascript:;" onclick="Moodle_unenrolUser(' . $userid_moodle . ', ' . $courseid . ');return false;" value="Unenrol" />' . "\n";
                }
            }
        }
        $content .= '     <br />&nbsp;&nbsp;&nbsp;&nbsp;' . $expert['email'] . '' . "\n";
        list($contentAux, $assessments) = showProfile($expert, $requirements, $sysSkills, $sysQualif, TRUE);
        $content .= $contentAux . '</td>' . "\n";
        foreach ($assessments as $ass) {
            if ($ass == 1) {
                $clase = 'bueno';
                $txt = 'The candidate totally fulfills this requirement';
            } else {
                if ($ass >= 0.666) {
                    $clase = 'regular';
                    $txt = 'The candidate partially fulfills this requirement';
                } else {
                    if ($ass >= 0.333) {
                        $clase = 'malo';
                        $txt = 'The candidate slightly fulfills this requirement';
                    } else {
                        $clase = 'nulo';
                        $txt = 'The candidate does not fulfill this requirement';
                    }
                }
            }
            $txtA = '<a href="" class="tooltip ' . $clase . ' animate recommendationCell" data-tool="' . $txt . '">';
            if ($showAssessments) {
                $txtCell = $txtA . round($ass, 3) . '</a>';
            } else {
                $txtCell = $txtA . '</a>';
            }
            $content .= '<td class="assessment ' . $clase . '">' . $txtCell . '</td>' . "\n";
        }
        # End foreach
        $content .= '<td class="assessment"><strong>' . round($expert['assess'], 3) . '</strong></td>' . "\n";
        // Mostramos sus habilidades
        //$content .= '  Skills:';
        $content .= '  </tr>' . "\n";
        $i = $i + 1;
    }
    $content .= '</tbody></table>';
    return $content;
}