function resultcalc($lifestyleidc, $dayparr, $dlmel)
{
    global $dlposts;
    global $feedd;
    global $dlmel;
    global $dayparr;
    global $finishtime;
    // Does any post contain top lifestyle definition word?
    $wordtopm = array();
    $unsurep = array();
    $scavgh = array();
    foreach ($dayparr as $dpost => $pfed) {
        $topmm = $dlposts[$lifestyleidc][$dpost][1];
        if ($topmm >= 1) {
            $wordtopm[$dpost] = $topmm;
        }
    }
    // closes foreach post loop
    if (is_array($wordtopm)) {
    }
    // prepare feed list minus those already in results via topword scoring.
    if ($wordtopm) {
        $unsurep = array_diff_key($dayparr, $wordtopm);
    } else {
        $unsurep = $dayparr;
    }
    // what about post that have context but not top word, include those if a. feed me top5  or b. score avg. > 0.75 lifestlyes includes that lifestyle definition being processed.
    foreach ($unsurep as $post => $pfedid) {
        $fivematch = array_search($lifestyleidc, $dlmel[$pfedid][1]);
        if ($dlmel[$pfedid][0] > 0.75) {
            $scavgh[$post] = '1';
        }
        if ($fivematch === 0) {
            $fivematch = true;
        }
        $topfive = array();
        if ($fivematch > 0) {
            $topfive[$post] = $fivematch;
        }
        // closes if match found
    }
    // closes loop of all post (minus topmatched posts)
    // create an array those that match
    if (is_array($topfive)) {
    }
    // limit to unique postids ie key index  that is if top5 and score freq. is over 75, even though context weak or low then post get included
    $lifeavginc = array_intersect_key($topfive, $scavgh);
    //echo 'top sco interse';
    //print_r($lifeavginc);
    //
    // form array with all posts the qualify and contain topmatched data, topscore50 and diffavg data  (lastone trickiest to rank/build)
    $rankdata = array_merge_keys($wordtopm, $lifeavginc);
    $lppp = $dlposts[$lifestyleidc];
    $rankexpand = array_intersect_key($dlposts[$lifestyleidc], $rankdata);
    // set sort
    $SortOrder = 0;
    // desc by default , 1- asc
    // lifestyle rank for each  post
    //  thinking here is to have two based on word context e.g. matched2 and score50   and  one/two on  lifestyleavg.  e.g diffavg/topmatched     could weight two group 2/3 word context  1/2 avg context.
    // rank for topword
    unset($indexord);
    $indexord = sortByField($rankexpand, '1', $SortOrder);
    unset($trorder);
    foreach ($indexord as $keytr => $trank) {
        $trorder[] = $keytr;
    }
    // rank for post score points
    unset($indexordsc);
    $indexordsc = sortByField($rankexpand, '2', $SortOrder);
    unset($scorder);
    foreach ($indexordsc as $keytr => $trank) {
        $scorder[] = $keytr;
    }
    // need to combine rankings to an over all ranking
    if ($trorder && $scorder) {
        unset($trordera);
        unset($scordera);
        //unset($drordera);
        unset($postaggrank);
        unset($postaggranka);
        $trordera = array_flip($trorder);
        $scordera = array_flip($scorder);
        foreach ($trorder as $keyo => $postid) {
            $aggrank = $trordera[$postid] / 2 + $scordera[$postid] / 2;
            $postaggrank[$postid] = round($aggrank, 4);
        }
        asort($postaggrank);
        $postaggranka = array_reverse($postaggrank, true);
        // OK, last stage save ranking and appropriate info. to make display results as quick as possible.
        $drposts = '';
        $rank = 0;
        foreach ($postaggranka as $key => $dayps) {
            $rank++;
            $drposts .= "( '{$rank}', '{$finishtime}', '{$lifestyleidc}', '{$key}' ), ";
        }
        $drposts = substr($drposts, 0, strLen($drposts) - 2);
        //this will eat the last comma
        if (strLen($drposts) > 0) {
            //  if no posts for that day, no need for query
            $db->query = "INSERT INTO " . RSSDATA . ".dailyposts (rank, enddate, lifestyleid, postid) VALUES ";
            $db->query .= "{$drposts}";
            //echo $db->query;
            $resultpostinsert = mysql_query($db->query) or die(mysql_error());
        }
    }
}
Example #2
0
         $punkte = $row->punkte;
     }
     $ergebnis[$row->pruefling_id]->gebiet[$row->gebiet_id]->prozent = $prozent;
     $ergebnis[$row->pruefling_id]->gebiet[$row->gebiet_id]->punkte = $punkte;
     if (isset($ergebnis[$row->pruefling_id]->gesamt)) {
         $ergebnis[$row->pruefling_id]->gesamt += $prozent * $row->gewicht;
     } else {
         $ergebnis[$row->pruefling_id]->gesamt = $prozent * $row->gewicht;
     }
     if (isset($ergebnis[$row->pruefling_id]->gesamtpunkte)) {
         $ergebnis[$row->pruefling_id]->gesamtpunkte += $punkte;
     } else {
         $ergebnis[$row->pruefling_id]->gesamtpunkte = $punkte;
     }
 }
 $ergb = sortByField($ergebnis, 'gesamt');
 // Vorkommende Kategorien laden
 $sql_query = "SELECT \n\t\t\t\t\tDISTINCT kategorie_kurzbz, \n\t\t\t\t\t(SELECT sum(punkte) FROM testtool.tbl_vorschlag JOIN testtool.tbl_frage USING(frage_id) \n\t\t\t\t\t WHERE tbl_frage.kategorie_kurzbz=vw_auswertung_kategorie_semester.kategorie_kurzbz) as gesamtpunkte \n\t\t\t\t FROM \n\t\t\t\t \ttesttool.vw_auswertung_kategorie_semester \n\t\t\t\t \tJOIN public.tbl_prestudent USING(prestudent_id)\n\t\t\t\t\tJOIN public.tbl_reihungstest ON(vw_auswertung_kategorie_semester.reihungstest_id=tbl_reihungstest.reihungstest_id)\n\t\t\t\tWHERE 1=1";
 if ($reihungstest != '') {
     $sql_query .= " AND vw_auswertung_kategorie_semester.reihungstest_id='" . addslashes($reihungstest) . "'";
 }
 if ($datum_von != '') {
     $sql_query .= " AND tbl_reihungstest.datum>='{$datum_von}'";
 }
 if ($datum_bis != '') {
     $sql_query .= " AND tbl_reihungstest.datum<='{$datum_bis}'";
 }
 if ($studiengang != '') {
     $sql_query .= " AND tbl_prestudent.studiengang_kz='" . addslashes($studiengang) . "'";
 }
 if ($prestudent_id != '') {
Example #3
0
 public function sortByField($array = array(), $field = null, $inverse = false)
 {
     return sortByField($array, $field, $inverse);
 }