コード例 #1
0
ファイル: lib.php プロジェクト: kai707/ITSA-backup
function get_analysed_dropdown($item, $groupid = false)
{
    $analysedItem = array();
    $analysedItem[] = $item->typ;
    $analysedItem[] = $item->name;
    //die moeglichen Antworten extrahieren
    $answers = null;
    $answers = explode("|", stripslashes_safe($item->presentation));
    if (!is_array($answers)) {
        return null;
    }
    //die Werte holen
    //$values = get_records('feedback_value', 'item', $item->id);
    $values = get_feedback_group_values($item, $groupid);
    if (!$values) {
        return null;
    }
    //schleife ueber den Werten und ueber die Antwortmoeglichkeiten
    $analysedAnswer = array();
    for ($i = 1; $i <= sizeof($answers); $i++) {
        $ans = null;
        $ans->answertext = $answers[$i - 1];
        $ans->answercount = 0;
        foreach ($values as $value) {
            //ist die Antwort gleich dem index der Antworten + 1?
            if ($value->value == $i) {
                $ans->answercount++;
            }
        }
        $ans->quotient = $ans->answercount / sizeof($values);
        $analysedAnswer[] = $ans;
    }
    $analysedItem[] = $analysedAnswer;
    return $analysedItem;
}
コード例 #2
0
ファイル: lib.php プロジェクト: stokekld/TemasMoodleMineria
function print_analysed_textfield($item, $itemnr = 0, $groupid = false)
{
    $values = get_feedback_group_values($item, $groupid);
    if ($values) {
        //echo '<table>';2
        $itemnr++;
        echo '<tr><th colspan="2">' . $itemnr . '.)&nbsp;' . stripslashes_safe($item->name) . '</th></tr>';
        foreach ($values as $value) {
            echo '<tr><td valign="top" align="right">-</td>';
            echo '<td>' . str_replace("\n", '<br />', $value->value) . '</td></tr>';
        }
        //echo '</table>';
    }
    return $itemnr;
}
コード例 #3
0
ファイル: lib.php プロジェクト: stokekld/TemasMoodleMineria
/**
 * counts the answers to a given picture item
 * 
 * Goes through all submitted answers to a 
 * given feedback item, counts the occurrances of each answer
 * and calculates a quotient showing 
 * (received answers per pic)/(all received answers)
 * 
 * @param object $item contains the item data (a record from prefix_feedback_item table)
 * @param boolean $groupid 
 * @return array returned array will contain something like this <pre>
 * Array
 * (
 *           [0] => picture
 *           [1] => What is the flag of Andorra?
 *           [2] => Array
 *               (
 *                   [0] => stdClass Object
 *                       (
 *                           [answertext] => angola.png
 *                           [answercount] => 1
 *                           [quotient] => 0.5
 *                       )
 *                   [1] => stdClass Object
 *                       (
 *                           [answertext] => antiguabarbuda.png
 *                           [answercount] => 0
 *                           [quotient] => 0
 *                       )
 *                   [2] => stdClass Object
 *                       (
 *                           [answertext] => andorra.png
 *                           [answercount] => 1
 *                           [quotient] => 0.5
 *                       )
 *               )
 * )</pre>
 */
function get_analysed_picture($item, $groupid = false)
{
    // for the beginning first only the radiobadges
    $analysedItem = array();
    $analysedItem[] = $item->typ;
    $analysedItem[] = $item->name;
    // the possible answers extract
    $answers = null;
    $answers = explode("|", $item->presentation);
    if (!is_array($answers)) {
        return null;
    }
    // the values get
    $values = get_feedback_group_values($item, $groupid);
    if (!$values) {
        return null;
    }
    // trail about the values and about the answer possibilities
    $analysedAnswer = array();
    for ($i = 1; $i <= sizeof($answers); $i++) {
        $ans = null;
        $ans->answertext = $answers[$i - 1];
        $ans->answercount = 0;
        foreach ($values as $value) {
            // if the answer is immediately index of the answers + 1?
            if ($value->value == $i) {
                $ans->answercount++;
            }
        }
        $ans->quotient = $ans->answercount / sizeof($values);
        $analysedAnswer[] = $ans;
    }
    $analysedItem[] = $analysedAnswer;
    return $analysedItem;
}