Esempio n. 1
0
            $model->collectiveValoration = $method->run();
            unset($method);
            //destroys the object
        }
        if ($model->label == "todim") {
            $method = new TodimHFL($evaluation->user_guid);
            $method->setData($data, $C_weight, $E_weight, $count, $evaluation->granularity);
            $model->collectiveValoration = $method->run();
            unset($method);
            //destroys the object
        }
        //run it the last
        if ($model->label == "classic") {
            $method = new AggregationHFLTS($evaluation->user_guid);
            $method->setData($data, $C_weight, $E_weight, $count, $evaluation->granularity);
            $model->collectiveValoration = $method->run();
            unset($method);
            //destroys the object
            //set valoration on user's profile
            $user = get_user($evaluation->user_guid);
            //$user->karma=$model->collectiveValoration;
            system_message($user->username . " @ " . $model->collectiveValoration);
        }
    }
}
//To show the objects first we get the list
$method_list = elgg_list_entities_from_metadata(['type' => 'object', 'subtype' => 'mcdm', 'pagination' => false]);
if (!$method_list) {
    $method_list = '<p class="mtm">' . elgg_echo('hflts:evaluation:not:found') . '</p>';
} else {
    echo $method_list;
Esempio n. 2
0
/**
* Gather and parse assessments made about user
*	Input: set of assessments already filtered
*	Output: karma term
*/
function userKarma_decisionMaking($valorationlist)
{
    if (sizeof($valorationlist) <= 0) {
        return elgg_echo('hflts:karma:none');
    }
    $count = 0;
    $data = array('_', '_');
    $enablePesos = elgg_get_plugin_setting('weight_assessments', 'hflts');
    $C_weight = null;
    $enableExpertos = elgg_get_plugin_setting('weight_experts', 'hflts');
    $E_weight = null;
    if (is_array($valorationlist)) {
        foreach ($valorationlist as $evaluation) {
            $data[$count] = array('ref' => $evaluation->user_guid, 'co_codigo' => $evaluation->owner_guid);
            //more to come
            if (!is_array($evaluation->criterion1)) {
                $data[$count]['U1'] = $evaluation->criterion1;
                $data[$count]['L1'] = $evaluation->criterion1;
            } else {
                $n = count($evaluation->criterion1) - 1;
                $data[$count]['U1'] = $evaluation->criterion1[$n];
                $data[$count]['L1'] = $evaluation->criterion1[0];
            }
            if (!is_array($evaluation->criterion2)) {
                $data[$count]['U2'] = $evaluation->criterion2;
                $data[$count]['L2'] = $evaluation->criterion2;
            } else {
                $n = count($evaluation->criterion2) - 1;
                $data[$count]['U2'] = $evaluation->criterion2[$n];
                $data[$count]['L2'] = $evaluation->criterion2[0];
            }
            if (!is_array($evaluation->criterion3)) {
                $data[$count]['U3'] = $evaluation->criterion3;
                $data[$count]['L3'] = $evaluation->criterion3;
            } else {
                $n = count($evaluation->criterion3) - 1;
                $data[$count]['U3'] = $evaluation->criterion3[$n];
                $data[$count]['L3'] = $evaluation->criterion3[0];
            }
            if (!is_array($evaluation->criterion4)) {
                $data[$count]['U4'] = $evaluation->criterion4;
                $data[$count]['L4'] = $evaluation->criterion4;
            } else {
                $n = count($evaluation->criterion4) - 1;
                $data[$count]['U4'] = $evaluation->criterion4[$n];
                $data[$count]['L4'] = $evaluation->criterion4[0];
            }
            if ($enablePesos) {
                $C_weight[$count] = array($evaluation->weight1, $evaluation->weight2, $evaluation->weight3, $evaluation->weight4);
            }
            if ($enableExpertos) {
                $expert = get_user($evaluation->owner_guid);
                $E_weight[$count] = $expert->userpoints_points;
            }
            //$evaluation->delete();//to clean
            $count++;
        }
    }
    $computed_weight = relativeUserExpertise($E_weight);
    if ($count >= 2) {
        $method = new AggregationHFLTS($evaluation->user_guid);
        $method->setData($data, $C_weight, $E_weight, $count, $evaluation->granularity);
        $model->collectiveValoration = $method->run();
        unset($method);
        //destroys the object
        //set valoration on user's profile
        $user = get_user($evaluation->user_guid);
        //system_message($count . "# " . $user->username . " @ " . $model->collectiveValoration);
        return $model->collectiveValoration;
    } else {
        return elgg_echo("hflts:karma:none");
    }
}