ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilSurveySkill Class Reference

Skill/Competence handling in surveys. More...

+ Collaboration diagram for ilSurveySkill:

Public Member Functions

 __construct (ilObjSurvey $a_survey)
 Constructor.
 read ()
 Read.
 getSkillForQuestion ($a_question_id)
 Get skill for question.
 getQuestionsForSkill ($a_base_skill_id, $a_tref_id)
 Get questions for skill.
 addQuestionSkillAssignment ($a_question_id, $a_base_skill_id, $a_tref_id)
 Add survey question to skill assignment.
 removeQuestionSkillAssignment ($a_question_id)
 Remove question skill assignment.
 removeUsagesOfSkills ($a_skills)
 Remove usages of skills.
 isSkillAssignedToQuestion ($a_skill_id, $a_tref_id)
 Is skill assigned to any question?
 getAllAssignedSkillsAsOptions ()
 Get skill for question.
 determineSkillLevelsForAppraisee ($a_appraisee_id, $a_self_eval=false)
 Determine skill levels for appraisee.
 determineMaxScale ($a_base_skill, $a_tref_id=0)
 Determine max scales and questions.
 writeAppraiseeSkills ($a_app_id)
 Write appraisee skills.

Static Public Member Functions

static handleQuestionDeletion ($a_question_id, $a_obj_id)
 Remove question skill assignment.

Protected Attributes

 $q_skill = array()

Detailed Description

Skill/Competence handling in surveys.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilSurveySkill.php.

Constructor & Destructor Documentation

ilSurveySkill::__construct ( ilObjSurvey  $a_survey)

Constructor.

Parameters
@return

Definition at line 23 of file class.ilSurveySkill.php.

References read().

{
$this->survey = $a_survey;
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilSurveySkill::addQuestionSkillAssignment (   $a_question_id,
  $a_base_skill_id,
  $a_tref_id 
)

Add survey question to skill assignment.

Parameters
int$a_question_idquestion id
int$a_base_skill_idbase skill id
int$a_tref_idskill template reference id (0, if no template involved)

Definition at line 99 of file class.ilSurveySkill.php.

References $ilDB, and ilSkillUsage\setUsage().

{
global $ilDB;
$ilDB->replace("svy_quest_skill",
array("q_id" => array("integer", $a_question_id)),
array(
"survey_id" => array("integer", $this->survey->getId()),
"base_skill_id" => array("integer", $a_base_skill_id),
"tref_id" => array("integer", $a_tref_id)
)
);
$this->q_skill[$a_question_id] = array("q_id" => $a_question_id,
"base_skill_id" => $a_base_skill_id,
"tref_id" => $a_tref_id);
// add usage
include_once("./Services/Skill/classes/class.ilSkillUsage.php");
ilSkillUsage::setUsage($this->survey->getId(), $a_base_skill_id, $a_tref_id);
}

+ Here is the call graph for this function:

ilSurveySkill::determineMaxScale (   $a_base_skill,
  $a_tref_id = 0 
)

Determine max scales and questions.

Parameters
@return

Definition at line 338 of file class.ilSurveySkill.php.

References $n, and SurveyQuestion\_instanciateQuestion().

{
include_once("./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php");
include_once("./Modules/Survey/classes/class.ilSurveySkill.php");
$ssk = new ilSurveySkill($this->survey);
$question_ids = $ssk->getQuestionsForSkill($a_base_skill, $a_tref_id);
$scale_sum = 0;
foreach ($question_ids as $q_id)
{
if(!is_object($q))
{
continue;
}
$cats = $q->getCategories();
$max_scale = 0;
for($i = 0; $i<= $cats->getCategoryCount(); $i++)
{
$c = $cats->getCategory($i);
$n = $c->neutral;
$s = $c->scale;
if (!$c->neutral)
{
if ($c->scale > $max_scale)
{
$max_scale = $c->scale;
}
}
}
$scale_sum+= $max_scale;
}
return $scale_sum;
}

+ Here is the call graph for this function:

ilSurveySkill::determineSkillLevelsForAppraisee (   $a_appraisee_id,
  $a_self_eval = false 
)

Determine skill levels for appraisee.

Parameters
$a_appraisee_idint user id of appraisee
Returns
array array with lots of information

Definition at line 246 of file class.ilSurveySkill.php.

References $results, $t, getAllAssignedSkillsAsOptions(), and getQuestionsForSkill().

Referenced by writeAppraiseeSkills().

{
$skills = array();
// get all skills
foreach ($opts as $k => $title)
{
$k = explode(":", $k);
$bs = new ilBasicSkill((int) $k[0]);
$ld = $bs->getLevelData();
$skills[] = array(
"base_skill_id" => (int) $k[0],
"tref_id" => (int) $k[1],
"skill_title" => $title,
"level_data" => $ld
);
}
if (!$a_self_eval)
{
$finished_ids = $this->survey->getFinishedIdsForAppraiseeId($a_appraisee_id, true);
}
else
{
$finished_id = $this->survey->getFinishedIdForAppraiseeIdAndRaterId($a_appraisee_id, $a_appraisee_id);
if ($finished_id > 0)
{
$finished_ids = array($finished_id);
}
}
if(!sizeof($finished_ids))
{
$finished_ids = array(-1);
}
$results = $this->survey->getUserSpecificResults($finished_ids);
foreach ($skills as $k => $s)
{
$q_ids = $this->getQuestionsForSkill($s["base_skill_id"], $s["tref_id"]);
$mean_sum = 0;
foreach ($q_ids as $q_id)
{
$qmean = 0;
if (is_array($results[$q_id]))
{
$cnt = 0;
$sum = 0;
foreach ($results[$q_id] as $r)
{
// this is a workaround, since we only get arrays from
// getUserSpecificResults()
$r = explode(" - ", $r);
$sum+= (int) $r[0];
$cnt++;
}
if ($cnt > 0)
{
$qmean = $sum/$cnt;
}
}
$mean_sum+= $qmean;
}
$skills[$k]["mean_sum"] = $mean_sum;
include_once("./Modules/Survey/classes/class.ilSurveySkillThresholds.php");
$skthr = new ilSurveySkillThresholds($this->survey);
$thresholds = $skthr->getThresholds();
foreach ($skills[$k]["level_data"] as $l)
{
$t = $thresholds[$l["id"]][$s["tref_id"]];
if ($t > 0 && $mean_sum >= $t)
{
$skills[$k]["new_level"] = $l["title"];
$skills[$k]["new_level_id"] = $l["id"];
}
}
}
return $skills;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSurveySkill::getAllAssignedSkillsAsOptions ( )

Get skill for question.

Parameters
int$a_question_idquestion id
Returns
array skill array

Definition at line 228 of file class.ilSurveySkill.php.

References ilSkillTreeNode\_lookupTitle().

Referenced by determineSkillLevelsForAppraisee().

{
$skills = array();
include_once("./Services/Skill/classes/class.ilBasicSkill.php");
foreach ($this->q_skill as $sk)
{
$skills[$sk["base_skill_id"].":".$sk["tref_id"]] =
ilBasicSkill::_lookupTitle($sk["base_skill_id"]);
}
return $skills;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSurveySkill::getQuestionsForSkill (   $a_base_skill_id,
  $a_tref_id 
)

Get questions for skill.

Parameters
@return

Definition at line 77 of file class.ilSurveySkill.php.

Referenced by determineSkillLevelsForAppraisee().

{
$q_ids = array();
foreach ($this->q_skill as $q_id => $s)
{
if ($s["base_skill_id"] == $a_base_skill_id &&
$s["tref_id"] == $a_tref_id)
{
$q_ids[] = $q_id;
}
}
return $q_ids;
}

+ Here is the caller graph for this function:

ilSurveySkill::getSkillForQuestion (   $a_question_id)

Get skill for question.

Parameters
int$a_question_idquestion id
Returns
array skill array

Definition at line 62 of file class.ilSurveySkill.php.

{
if (isset($this->q_skill[$a_question_id]))
{
return $this->q_skill[$a_question_id];
}
return false;
}
static ilSurveySkill::handleQuestionDeletion (   $a_question_id,
  $a_obj_id 
)
static

Remove question skill assignment.

Parameters
int$a_question_idquestion id

Definition at line 155 of file class.ilSurveySkill.php.

References $ilDB, and ilObject\_lookupType().

Referenced by SurveyQuestion\delete().

{
global $ilDB;
if (ilObject::_lookupType($a_obj_id) == "svy")
{
// mantis 11691
include_once './Modules/Survey/classes/class.ilObjSurvey.php';
$svy = new ilObjSurvey($a_obj_id, false);
$svy_skill = new ilSurveySkill($svy);
$svy_skill->removeQuestionSkillAssignment($a_question_id);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSurveySkill::isSkillAssignedToQuestion (   $a_skill_id,
  $a_tref_id 
)

Is skill assigned to any question?

Parameters
@return

Definition at line 205 of file class.ilSurveySkill.php.

References $ilDB.

Referenced by removeUsagesOfSkills().

{
global $ilDB;
$set = $ilDB->query("SELECT * FROM svy_quest_skill ".
" WHERE base_skill_id = ".$ilDB->quote($a_skill_id, "integer").
" AND tref_id = ".$ilDB->quote($a_tref_id, "integer").
" AND survey_id = ".$ilDB->quote($this->survey->getId(), "integer")
);
if ($rec = $ilDB->fetchAssoc($set))
{
return true;
}
return false;
}

+ Here is the caller graph for this function:

ilSurveySkill::read ( )

Read.

Parameters
@return

Definition at line 35 of file class.ilSurveySkill.php.

References $ilDB, and SurveyQuestion\_questionExists().

Referenced by __construct().

{
global $ilDB;
$set = $ilDB->query("SELECT * FROM svy_quest_skill ".
" WHERE survey_id = ".$ilDB->quote($this->survey->getId(), "integer")
);
include_once("./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php");
while ($rec = $ilDB->fetchAssoc($set))
{
{
$this->q_skill[$rec["q_id"]] = array("q_id" => $rec["q_id"],
"base_skill_id" => $rec["base_skill_id"],
"tref_id" => $rec["tref_id"]);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSurveySkill::removeQuestionSkillAssignment (   $a_question_id)

Remove question skill assignment.

Parameters
int$a_question_idquestion id

Definition at line 126 of file class.ilSurveySkill.php.

References $ilDB, and removeUsagesOfSkills().

{
global $ilDB;
// read skills that are assigned to the quesiton
$set = $ilDB->query("SELECT * FROM svy_quest_skill ".
" WHERE q_id = ".$ilDB->quote($a_question_id, "integer")
);
$skills = array();
while ($rec = $ilDB->fetchAssoc($set))
{
$skills[] = array("skill_id" => $rec["base_skill_id"],
"tref_id" => $rec["tref_id"]);
}
// remove assignment of question
$ilDB->manipulate("DELETE FROM svy_quest_skill WHERE ".
" q_id = ".$ilDB->quote($a_question_id, "integer")
);
unset($this->q_skill[$a_question_id]);
$this->removeUsagesOfSkills($skills);
}

+ Here is the call graph for this function:

ilSurveySkill::removeUsagesOfSkills (   $a_skills)

Remove usages of skills.

This function checks, if the skills are really not in use anymore

Parameters
arrayarray of arrays with keys "skill_id" and "tref_id"

Definition at line 174 of file class.ilSurveySkill.php.

References isSkillAssignedToQuestion(), and ilSkillUsage\setUsage().

Referenced by removeQuestionSkillAssignment().

{
$used_skills = array();
foreach ($a_skills as $skill)
{
if ($this->isSkillAssignedToQuestion($skill["skill_id"], $skill["tref_id"]))
{
$used_skills[] = $skill["skill_id"].":".$skill["tref_id"];
}
}
reset($a_skills);
// now remove all usages that have been confirmed
include_once("./Services/Skill/classes/class.ilSkillUsage.php");
//var_dump($a_skills);
//var_dump($used_skills); exit;
foreach ($a_skills as $skill)
{
if (!in_array($skill["skill_id"].":".$skill["tref_id"], $used_skills))
{
ilSkillUsage::setUsage($this->survey->getId(), $skill["skill_id"], $skill["tref_id"], false);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSurveySkill::writeAppraiseeSkills (   $a_app_id)

Write appraisee skills.

Parameters
@return

Definition at line 379 of file class.ilSurveySkill.php.

References ilBasicSkill\ACHIEVED, determineSkillLevelsForAppraisee(), and ilBasicSkill\writeUserSkillLevelStatus().

{
// write raters evaluation
$new_levels = $this->determineSkillLevelsForAppraisee($a_app_id);
foreach ($new_levels as $nl)
{
if ($nl["new_level_id"] > 0)
{
$a_app_id, $this->survey->getRefId(), $nl["tref_id"], ilBasicSkill::ACHIEVED, true);
}
}
// patch optes start
// write self evaluation,
/*
$new_levels = $this->determineSkillLevelsForAppraisee($a_app_id, true);
foreach ($new_levels as $nl)
{
if ($nl["new_level_id"] > 0)
{
ilBasicSkill::writeUserSkillLevelStatus($nl["new_level_id"],
$a_app_id, $this->survey->getRefId(), $nl["tref_id"], ilBasicSkill::ACHIEVED, true, 1);
}
}*/
// patch optes end
}

+ Here is the call graph for this function:

Field Documentation

ilSurveySkill::$q_skill = array()
protected

Definition at line 14 of file class.ilSurveySkill.php.


The documentation for this class was generated from the following file: