コード例 #1
0
function draw_chart($data_values, $data_values_label, $chart_data_label, $section_name, $draw_sql_explain, $dir)
{
    $tmp1 = base64_encode(serialize(array_reverse($data_values)));
    $tmp2 = base64_encode(serialize(array_reverse($data_values_label)));
    // There is a problem with URI beeing too long: Request-URI Too Large, which can prevent
    // some images from appearing. Default is: LimitRequestLine 8190
    // I will try to detect the size of a strig passed.
    //show_array($data_values);
    //show_array($data_values_label);
    //echo "<BR> Ala ma kota:" . (strlen($tmp2) + strlen($tmp1) + strlen($chart_data_label) + strlen($section_name)) . " <BR>";
    if (strlen($tmp2) + strlen($tmp1) + strlen($chart_data_label) + strlen($section_name) > 8190) {
        //There is more data that I can transmit using URI parameter. I will shred some data.
        echo "<BR> There is more data that I can reasonably display. I will shred some data. <BR>";
        $filtered_data_values = rem_array_filter($data_values);
        $filtered_data_values_label = rem_array_filter($data_values_label);
        //show_array($filtered_data_values);
        //show_array($filtered_data_values_label);
        draw_chart($filtered_data_values, $filtered_data_values_label, $chart_data_label, $section_name, $draw_sql_explain, $dir);
    } else {
        // Description of draw_chart.php
        // chart_data - values like 2500 PIO
        // chart_leg - legent to values like timestamp
        // chart_data_label - Subtitle
        echo "<img src=\"draw_chart.php?chart_data={$tmp1}&chart_leg={$tmp2}&chart_data_label={$chart_data_label}&chart_title={$section_name}\" border=0 align=center width= height=>";
        // For troubleschooting
        //echo "<a href=\"draw_chart.php?data_values=$tmp1&chart_leg=$tmp2&data_values_label=$data_values_label&chart_title=$section_name\" >aaa </a>";
        // Create a table with SQL explain plan for every day.
        // I will not create a separate function because all the same parameters should be passed to decide
        // when to shred data
        // I use here only:
        // $data_values_label - array - timestamp, already shreded if needed
        // $draw_sql_explain - string - hash_value
        if ($draw_sql_explain) {
            echo "<BR> Explain plan and full SQL text of selected days <BR><table border = 0><tr>";
            $tmp_array = array_reverse($data_values_label);
            for ($j = 0; $j < count($tmp_array); $j++) {
                $row = each($tmp_array);
                //echo "<td>" . $row["value"] . "</td>";
                //echo "<td>" . "a <BR>" . "b" . "</td>";
                // To obtain text rotated 90 degrees I print every character divided by <BR> :)
                $tmp = chunk_split($row["value"], 1, "<BR>");
                //echo "<td>" . $tmp . "</td>";
                // If file exists I print a link
                if (is_file($dir . "hash_history/hash_" . $draw_sql_explain . "_" . $row["value"] . ".lst")) {
                    echo "<td>" . "<a href=\"show_file.php?filename=" . $dir . "hash_history/hash_" . $draw_sql_explain . "_" . $row["value"] . ".lst" . "\" > " . $tmp . "</a></td>";
                } else {
                    echo "<td>" . $tmp . "</td>";
                }
                //if (is_file
            }
            // for($j=0;
            echo "</tr></table>";
        }
        // if ( $draw_sql_explain )
    }
    // ...ection_name) ) > 8190)
}
/**
 * Implements hook_analytics_dashboard().
 */
function hook_analytics_dashboard()
{
    $voc = taxonomy_vocabulary_machine_name_load('categories');
    $tree = taxonomy_get_tree($voc->vid);
    $header = array();
    foreach ($tree as $term) {
        $header[] = $term->name;
        $query = db_select('taxonomy_index', 'ti');
        $query->condition('ti.tid', $term->tid, '=')->fields('ti', array('nid'));
        $terms[] = $query->countQuery()->execute()->fetchField();
    }
    $columns = array('Ideas in category');
    $rows = array($terms);
    $settings = array();
    $settings['chart']['chartCategory'] = array('header' => $header, 'rows' => $rows, 'columns' => $columns, 'weight' => -10, 'chartType' => 'PieChart', 'options' => array('curveType' => "function", 'is3D' => TRUE, 'forceIFrame' => FALSE, 'title' => 'Ideas per category', 'width' => 500, 'height' => 300));
    return draw_chart($settings);
}
コード例 #3
0
 public function response_analysis($rid, $resps, $compare, $isgroupmember, $allresponses, $currentgroupid)
 {
     global $DB, $CFG, $OUTPUT, $SESSION, $USER;
     $action = optional_param('action', 'vall', PARAM_ALPHA);
     require_once $CFG->libdir . '/tablelib.php';
     require_once $CFG->dirroot . '/mod/questionnaire/drawchart.php';
     if ($resp = $DB->get_record('questionnaire_response', array('id' => $rid))) {
         $userid = $resp->username;
         if ($user = $DB->get_record('user', array('id' => $userid))) {
             $ruser = fullname($user);
         }
     }
     // Available group modes (0 = no groups; 1 = separate groups; 2 = visible groups).
     $groupmode = groups_get_activity_groupmode($this->cm, $this->course);
     $groupname = get_string('allparticipants');
     if ($groupmode > 0) {
         if ($currentgroupid > 0) {
             $groupname = groups_get_group_name($currentgroupid);
         } else {
             $groupname = get_string('allparticipants');
         }
     }
     if ($this->survey->feedbackscores) {
         $table = new html_table();
         $table->size = array(null, null);
         $table->align = array('left', 'right', 'right');
         $table->head = array();
         $table->wrap = array();
         if ($compare) {
             $table->head = array(get_string('feedbacksection', 'questionnaire'), $ruser, $groupname);
         } else {
             $table->head = array(get_string('feedbacksection', 'questionnaire'), $groupname);
         }
     }
     $feedbacksections = $this->survey->feedbacksections;
     $feedbackscores = $this->survey->feedbackscores;
     $sid = $this->survey->id;
     $questions = $this->questions;
     // Find if there are any feedbacks in this questionnaire.
     $sql = "SELECT * FROM {questionnaire_fb_sections} WHERE survey_id = {$sid} AND section IS NOT NULL";
     if (!($fbsections = $DB->get_records_sql($sql))) {
         return null;
     }
     $fbsectionsnb = array_keys($fbsections);
     // Calculate max score per question in questionnaire.
     $qmax = array();
     $totalscore = 0;
     $maxtotalscore = 0;
     foreach ($questions as $question) {
         $qid = $question->id;
         $qtype = $question->type_id;
         $required = $question->required;
         if (($qtype == QUESRADIO || $qtype == QUESDROP || $qtype == QUESRATE) && $required == 'y') {
             if (!isset($qmax[$qid])) {
                 $qmax[$qid] = 0;
             }
             $nbchoices = 1;
             if ($qtype == QUESRATE) {
                 $nbchoices = 0;
             }
             foreach ($question->choices as $choice) {
                 // Testing NULL and 'NULL' because I changed the automatic null value, must be fixed later... TODO.
                 if (isset($choice->value) && $choice->value != null && $choice->value != 'NULL') {
                     if ($choice->value > $qmax[$qid]) {
                         $qmax[$qid] = $choice->value;
                     }
                 } else {
                     $nbchoices++;
                 }
             }
             $qmax[$qid] = $qmax[$qid] * $nbchoices;
             $maxtotalscore += $qmax[$qid];
         }
         if ($qtype == QUESYESNO && $required == 'y') {
             $qmax[$qid] = 1;
             $maxtotalscore += 1;
         }
     }
     // Just in case no values have been entered in the various questions possible answers field.
     if ($maxtotalscore === 0) {
         return;
     }
     $feedbackmessages = array();
     // Get individual scores for each question in this responses set.
     $qscore = array();
     $allqscore = array();
     // Get all response ids for all respondents.
     $castsql = $DB->sql_cast_char2int('r.username');
     $rids = array();
     foreach ($resps as $key => $resp) {
         $rids[] = $key;
     }
     $nbparticipants = count($rids);
     if (!$allresponses && $groupmode != 0) {
         $nbparticipants = max(1, $nbparticipants - !$isgroupmember);
     }
     foreach ($rids as $rrid) {
         // Get responses for bool (Yes/No).
         $sql = 'SELECT q.id, q.type_id as q_type, a.choice_id as cid ' . 'FROM {questionnaire_response_bool} a, {questionnaire_question} q ' . 'WHERE a.response_id = ? AND a.question_id=q.id ';
         if ($responses = $DB->get_records_sql($sql, array($rrid))) {
             foreach ($responses as $qid => $response) {
                 $responsescore = $response->cid == 'y' ? 1 : 0;
                 // Individual score.
                 // If this is current user's response OR if current user is viewing another group's results.
                 if ($rrid == $rid || $allresponses) {
                     if (!isset($qscore[$qid])) {
                         $qscore[$qid] = 0;
                     }
                     $qscore[$qid] = $responsescore;
                 }
                 // Course score.
                 if (!isset($allqscore[$qid])) {
                     $allqscore[$qid] = 0;
                 }
                 // Only add current score if conditions below are met.
                 if ($groupmode == 0 || $isgroupmember || !$isgroupmember && $rrid != $rid || $allresponses) {
                     $allqscore[$qid] += $responsescore;
                 }
             }
         }
         // Get responses for single (Radio or Dropbox).
         $sql = 'SELECT q.id, q.type_id as q_type, c.content as ccontent,c.id as cid, c.value as score  ' . 'FROM {questionnaire_resp_single} a, {questionnaire_question} q, {questionnaire_quest_choice} c ' . 'WHERE a.response_id = ? AND a.question_id=q.id AND a.choice_id=c.id ';
         if ($responses = $DB->get_records_sql($sql, array($rrid))) {
             foreach ($responses as $qid => $response) {
                 // Individual score.
                 // If this is current user's response OR if current user is viewing another group's results.
                 if ($rrid == $rid || $allresponses) {
                     if (!isset($qscore[$qid])) {
                         $qscore[$qid] = 0;
                     }
                     $qscore[$qid] = $response->score;
                 }
                 // Course score.
                 if (!isset($allqscore[$qid])) {
                     $allqscore[$qid] = 0;
                 }
                 // Only add current score if conditions below are met.
                 if ($groupmode == 0 || $isgroupmember || !$isgroupmember && $rrid != $rid || $allresponses) {
                     $allqscore[$qid] += $response->score;
                 }
             }
         }
         // Get responses for response_rank (Rate).
         $sql = 'SELECT a.id as aid, q.id AS qid, c.id AS cid, a.rank as arank ' . 'FROM {questionnaire_response_rank} a, {questionnaire_question} q, {questionnaire_quest_choice} c ' . 'WHERE a.response_id= ? AND a.question_id=q.id AND a.choice_id=c.id ' . 'ORDER BY aid, a.question_id,c.id';
         if ($responses = $DB->get_records_sql($sql, array($rrid))) {
             // We need to store the number of sub-questions for each rate questions.
             $rank = array();
             $firstcid = array();
             foreach ($responses as $response) {
                 $qid = $response->qid;
                 $rank = $response->arank;
                 if (!isset($qscore[$qid])) {
                     $qscore[$qid] = 0;
                     $allqscore[$qid] = 0;
                 }
                 $firstcid[$qid] = $DB->get_record('questionnaire_quest_choice', array('question_id' => $qid), 'id', IGNORE_MULTIPLE);
                 $firstcidid = $firstcid[$qid]->id;
                 $cidvalue = $firstcidid + $rank;
                 $sql = "SELECT * FROM {questionnaire_quest_choice} WHERE id = {$cidvalue}";
                 if ($value = $DB->get_record_sql($sql)) {
                     // Individual score.
                     // If this is current user's response OR if current user is viewing another group's results.
                     if ($rrid == $rid || $allresponses) {
                         $qscore[$qid] += $value->value;
                     }
                     // Only add current score if conditions below are met.
                     if ($groupmode == 0 || $isgroupmember || !$isgroupmember && $rrid != $rid || $allresponses) {
                         $allqscore[$qid] += $value->value;
                     }
                 }
             }
         }
     }
     $totalscore = array_sum($qscore);
     $scorepercent = round($totalscore / $maxtotalscore * 100);
     $oppositescorepercent = 100 - $scorepercent;
     $alltotalscore = array_sum($allqscore);
     $allscorepercent = round($alltotalscore / $nbparticipants / $maxtotalscore * 100);
     // No need to go further if feedback is global, i.e. only relying on total score.
     if ($feedbacksections == 1) {
         $sectionid = $fbsectionsnb[0];
         $sectionlabel = $fbsections[$sectionid]->sectionlabel;
         $sectionheading = $fbsections[$sectionid]->sectionheading;
         $feedbacks = $DB->get_records('questionnaire_feedback', array('section_id' => $sectionid));
         $labels = array();
         foreach ($feedbacks as $feedback) {
             if ($feedback->feedbacklabel != '') {
                 $labels[] = $feedback->feedbacklabel;
             }
         }
         $feedback = $DB->get_record_select('questionnaire_feedback', 'section_id = ? AND minscore <= ? AND ? < maxscore', array($sectionid, $scorepercent, $scorepercent));
         // To eliminate all potential % chars in heading text (might interfere with the sprintf function).
         $sectionheading = str_replace('%', '', $sectionheading);
         // Replace section heading placeholders with their actual value (if any).
         $original = array('$scorepercent', '$oppositescorepercent');
         $result = array('%s%%', '%s%%');
         $sectionheading = str_replace($original, $result, $sectionheading);
         $sectionheading = sprintf($sectionheading, $scorepercent, $oppositescorepercent);
         $sectionheading = file_rewrite_pluginfile_urls($sectionheading, 'pluginfile.php', $this->context->id, 'mod_questionnaire', 'sectionheading', $sectionid);
         $feedbackmessages[] = $OUTPUT->box_start();
         $feedbackmessages[] = format_text($sectionheading, FORMAT_HTML);
         $feedbackmessages[] = $OUTPUT->box_end();
         if (!empty($feedback->feedbacktext)) {
             // Clean the text, ready for display.
             $formatoptions = new stdClass();
             $formatoptions->noclean = true;
             $feedbacktext = file_rewrite_pluginfile_urls($feedback->feedbacktext, 'pluginfile.php', $this->context->id, 'mod_questionnaire', 'feedback', $feedback->id);
             $feedbacktext = format_text($feedbacktext, $feedback->feedbacktextformat, $formatoptions);
             $feedbackmessages[] = $OUTPUT->box_start();
             $feedbackmessages[] = $feedbacktext;
             $feedbackmessages[] = $OUTPUT->box_end();
         }
         $score = array($scorepercent, 100 - $scorepercent);
         $allscore = null;
         if ($compare || $allresponses) {
             $allscore = array($allscorepercent, 100 - $allscorepercent);
         }
         $usergraph = get_config('questionnaire', 'usergraph');
         if ($usergraph && $this->survey->chart_type) {
             draw_chart($feedbacktype = 'global', $this->survey->chart_type, $labels, $score, $allscore, $sectionlabel, $groupname, $allresponses);
         }
         // Display class or group score. Pending chart library decision to display?
         // Find out if this feedback sectionlabel has a pipe separator.
         $lb = explode("|", $sectionlabel);
         $oppositescore = '';
         $oppositeallscore = '';
         if (count($lb) > 1) {
             $sectionlabel = $lb[0] . ' | ' . $lb[1];
             $oppositescore = ' | ' . $score[1] . '%';
             $oppositeallscore = ' | ' . $allscore[1] . '%';
         }
         if ($this->survey->feedbackscores) {
             if ($compare) {
                 $table->data[] = array($sectionlabel, $score[0] . '%' . $oppositescore, $allscore[0] . '%' . $oppositeallscore);
             } else {
                 $table->data[] = array($sectionlabel, $allscore[0] . '%' . $oppositeallscore);
             }
             echo html_writer::table($table);
         }
         return $feedbackmessages;
     }
     // Now process scores for more than one section.
     // Initialize scores and maxscores to 0.
     $score = array();
     $allscore = array();
     $maxscore = array();
     $scorepercent = array();
     $allscorepercent = array();
     $oppositescorepercent = array();
     $alloppositescorepercent = array();
     $chartlabels = array();
     $chartscore = array();
     for ($i = 1; $i <= $feedbacksections; $i++) {
         $score[$i] = 0;
         $allscore[$i] = 0;
         $maxscore[$i] = 0;
         $scorepercent[$i] = 0;
     }
     for ($section = 1; $section <= $feedbacksections; $section++) {
         foreach ($fbsections as $key => $fbsection) {
             if ($fbsection->section == $section) {
                 $feedbacksectionid = $key;
                 $scorecalculation = unserialize($fbsection->scorecalculation);
                 $sectionheading = $fbsection->sectionheading;
                 $imageid = $fbsection->id;
                 $chartlabels[$section] = $fbsection->sectionlabel;
             }
         }
         foreach ($scorecalculation as $qid => $key) {
             // Just in case a question pertaining to a section has been deleted or made not required
             // after being included in scorecalculation.
             if (isset($qscore[$qid])) {
                 $score[$section] += $qscore[$qid];
                 $maxscore[$section] += $qmax[$qid];
                 if ($compare || $allresponses) {
                     $allscore[$section] += $allqscore[$qid];
                 }
             }
         }
         $scorepercent[$section] = round($score[$section] / $maxscore[$section] * 100);
         $oppositescorepercent[$section] = 100 - $scorepercent[$section];
         if (($compare || $allresponses) && $nbparticipants != 0) {
             $allscorepercent[$section] = round($allscore[$section] / $nbparticipants / $maxscore[$section] * 100);
             $alloppositescorepercent[$section] = 100 - $allscorepercent[$section];
         }
         if (!$allresponses) {
             // To eliminate all potential % chars in heading text (might interfere with the sprintf function).
             $sectionheading = str_replace('%', '', $sectionheading);
             // Replace section heading placeholders with their actual value (if any).
             $original = array('$scorepercent', '$oppositescorepercent');
             $result = array("{$scorepercent[$section]}%", "{$oppositescorepercent[$section]}%");
             $sectionheading = str_replace($original, $result, $sectionheading);
             $formatoptions = new stdClass();
             $formatoptions->noclean = true;
             $sectionheading = file_rewrite_pluginfile_urls($sectionheading, 'pluginfile.php', $this->context->id, 'mod_questionnaire', 'sectionheading', $imageid);
             $sectionheading = format_text($sectionheading, 1, $formatoptions);
             $feedbackmessages[] = $OUTPUT->box_start('reportQuestionTitle');
             $feedbackmessages[] = format_text($sectionheading, FORMAT_HTML);
             $feedback = $DB->get_record_select('questionnaire_feedback', 'section_id = ? AND minscore <= ? AND ? < maxscore', array($feedbacksectionid, $scorepercent[$section], $scorepercent[$section]), 'id,feedbacktext,feedbacktextformat');
             $feedbackmessages[] = $OUTPUT->box_end();
             if (!empty($feedback->feedbacktext)) {
                 // Clean the text, ready for display.
                 $formatoptions = new stdClass();
                 $formatoptions->noclean = true;
                 $feedbacktext = file_rewrite_pluginfile_urls($feedback->feedbacktext, 'pluginfile.php', $this->context->id, 'mod_questionnaire', 'feedback', $feedback->id);
                 $feedbacktext = format_text($feedbacktext, $feedback->feedbacktextformat, $formatoptions);
                 $feedbackmessages[] = $OUTPUT->box_start('feedbacktext');
                 $feedbackmessages[] = $feedbacktext;
                 $feedbackmessages[] = $OUTPUT->box_end();
             }
         }
     }
     // Display class or group score.
     switch ($action) {
         case 'vallasort':
             asort($allscore);
             break;
         case 'vallarsort':
             arsort($allscore);
             break;
         default:
     }
     foreach ($allscore as $key => $sc) {
         $lb = explode("|", $chartlabels[$key]);
         $oppositescore = '';
         $oppositeallscore = '';
         if (count($lb) > 1) {
             $sectionlabel = $lb[0] . ' | ' . $lb[1];
             $oppositescore = ' | ' . $oppositescorepercent[$key] . '%';
             $oppositeallscore = ' | ' . $alloppositescorepercent[$key] . '%';
         } else {
             $sectionlabel = $chartlabels[$key];
         }
         if ($compare) {
             $table->data[] = array($sectionlabel, $scorepercent[$key] . '%' . $oppositescore, $allscorepercent[$key] . '%' . $oppositeallscore);
         } else {
             $table->data[] = array($sectionlabel, $allscorepercent[$key] . '%' . $oppositeallscore);
         }
     }
     $usergraph = get_config('questionnaire', 'usergraph');
     if ($usergraph && $this->survey->chart_type) {
         draw_chart($feedbacktype = 'sections', $this->survey->chart_type, array_values($chartlabels), array_values($scorepercent), array_values($allscorepercent), $sectionlabel, $groupname, $allresponses);
     }
     if ($this->survey->feedbackscores) {
         echo html_writer::table($table);
     }
     return $feedbackmessages;
 }
コード例 #4
0
    //exit;
}
// for($i=0; $i<count($filenames_array
//show_array($data_values3);
echo "<br> {$filenames_array['0']}";
// Extract from the filename data time of creation
for ($i = 0; $i < count($filenames_array); $i++) {
    if ($date_with_time) {
        //echo "Preserving date with time";
        preg_match("/....-..-.._..:../", $filenames_array[$i], $match_result);
        $filenames_array_date[$i] = $match_result[0];
        //echo "<br> zebra $match_result[0] $date_with_time";
    } else {
        //echo "Standard date only to legend";
        preg_match("/....-..-../", $filenames_array[$i], $match_result);
        $filenames_array_date[$i] = $match_result[0];
        //echo "<br> zebra $match_result[0] $date_with_time";
    }
}
// for
echo "<br>";
//echo "<BR>before the draw";
//show_array($data_values1);
//echo "<BR>before the draw2";
//show_array($filenames_array_date);
draw_chart($data_values1, $filenames_array_date, "Statistik: " . $statname, "Waits", 0, $dir, "");
draw_chart($data_values3, $filenames_array_date, "Statistik: " . $statname, "Total Wait Time (s)", 0, $dir);
draw_chart($data_values4, $filenames_array_date, "Statistik: " . $statname, "Avg wait (ms)", 0, $dir);
//Include footer file with navigation links
require "footer.php";
exit;
コード例 #5
0
                }
            }
        }
        // if ( $section )
    }
    // while (!feof($fh))
    $data_values_counter++;
    fclose($fh);
    //exit;
}
// for($i=0; $i<count($filenames_array
//show_array($data_values3);
echo "<br> {$filenames_array['0']}";
// Extract from the filename data time of creation
for ($i = 0; $i < count($filenames_array); $i++) {
    preg_match("/....-..-../", $filenames_array[$i], $match_result);
    $filenames_array_date[$i] = $match_result[0];
    //echo "<br> zebra $match_result[0]";
}
// for
echo "<br>";
//echo "<BR>before the draw";
//show_array($data_values1);
//echo "<BR>before the draw2";
//show_array($filenames_array_date);
draw_chart($data_values1, $filenames_array_date, "Statistik: " . $statname, "Total", 0, "", "");
//draw_chart($data_values2, $filenames_array_date, ("Statistik: " . $statname), "per Second", 0, "");
//draw_chart($data_values3, $filenames_array_date, ("Statistik: " . $statname), "per Trans", 0, "");
//Include footer file with navigation links
require "footer.php";
exit;
コード例 #6
0
ファイル: day.inc.php プロジェクト: sitracker/sitracker_old
    $gidurl = "&amp;gid={$groupid}";
}
// skip over weekends in day view
if (date('D', mktime(0, 0, 0, $month, $day, $year)) == 'Sat') {
    $day -= 1;
}
if (date('D', mktime(0, 0, 0, $month, $day, $year)) == 'Sun') {
    $day += 1;
}
if (date('D', mktime(0, 0, 0, $month, $day, $year)) == 'Mon') {
    $pdate = mktime(0, 0, 0, $month, $day - 3, $year);
} else {
    $pdate = mktime(0, 0, 0, $month, $day - 1, $year);
}
if (date('D', mktime(0, 0, 0, $month, $day, $year)) == 'Fri') {
    $ndate = mktime(0, 0, 0, $month, $day + 3, $year);
} else {
    $ndate = mktime(0, 0, 0, $month, $day + 1, $year);
}
echo "<h2>{$strDayView}</h2>";
echo "<p align='center'>";
echo "<a href='{$_SERVER['PHP_SELF']}?display=day&amp;year=" . date('Y', $pdate) . "&amp;month=" . date('m', $pdate) . "&amp;day=" . date('d', $pdate) . "{$gidurl}'>&lt;</a> ";
echo ldate('l dS F Y', mktime(0, 0, 0, $month, $day, $year));
echo " <a href='{$_SERVER['PHP_SELF']}?display=day&amp;year=" . date('Y', $ndate) . "&amp;month=" . date('m', $ndate) . "&amp;day=" . date('d', $ndate) . "{$gidurl}'>&gt;</a>";
echo "</p>";
$numgroups = group_selector($groupid, "display={$display}&amp;year={$year}&amp;month={$month}&amp;day={$day}");
if ($groupid == 'all') {
    $groupid = '';
}
echo draw_chart('day', $year, $month, $day, $groupid, $user);
コード例 #7
0
// if (is_dir($dir))
//echo "<BR> ala ma kota";
//show_array($filenames_array);
//Get vales for selected statistic from sql_id files provied.
list($a_elapsed_time_timestamp, $a_elapsed_time, $a_elapsed_time_per_exec, $a_trash) = get_values_from_sql_id_files($dir, $filenames_array, "Elapsed Time (ms)");
list($a_cpu_time_timestamp, $a_cpu_time, $a_cpu_time_per_exec, $a_trash) = get_values_from_sql_id_files($dir, $filenames_array, "CPU Time (ms)");
list($a_executions_timestamp, $a_executions, $a_executions_per_exec, $a_trash) = get_values_from_sql_id_files($dir, $filenames_array, "Executions");
list($a_buffer_gets_timestamp, $a_buffer_gets, $a_buffer_gets_per_exec, $a_trash) = get_values_from_sql_id_files($dir, $filenames_array, "Buffer Gets");
//show_array($a_timestamp);
//show_array($a_elapsed_time);
//show_array($a_elapsed_time_per_exec);
//Draw a picture
// Create a draw
// 1 - $data_values3 - array - values eg buffergets
// 2 - $chart_leg - array - timestamp
// 3 - $data_values3_label - string
// 4 - $section_name - string
// 5 - Y/N whether to print the table with SQL explain plans through history. I provide the clean hash number if yes
// 6 - $dir - directory needed for sql explain plan in the end table
echo "<BR><HR><B>Per instance statistics</B><BR>";
draw_chart($a_elapsed_time, $a_elapsed_time_timestamp, "Sql Id: " . $hash_value, "Elapsed Time (ms)", 0, "");
draw_chart($a_cpu_time, $a_cpu_time_timestamp, "Sql Id: " . $hash_value, "CPU Time (ms)", 0, "");
draw_chart($a_executions, $a_executions_timestamp, "Sql Id: " . $hash_value, "Executions", 0, "");
draw_chart($a_buffer_gets, $a_buffer_gets_timestamp, "Sql Id: " . $hash_value, "Buffer Gets", "{$hash_value}", "{$dir}", $filenames_array);
echo "<BR><HR><B>Per execution statistics</B><BR>";
draw_chart($a_cpu_time_per_exec, $a_cpu_time_timestamp, "Sql Id: " . $hash_value, "CPU Time (ms) per execution", 0, "");
draw_chart($a_elapsed_time_per_exec, $a_elapsed_time_timestamp, "Sql Id: " . $hash_value, "Elapsed Time (ms) per execution", 0, "");
draw_chart($a_buffer_gets_per_exec, $a_buffer_gets_timestamp, "Sql Id: " . $hash_value, "Buffer Gets per execution", "{$hash_value}", "{$dir}", $filenames_array);
//Include footer file with navigation links
require "footer.php";
exit;
コード例 #8
0
                    $data_values4[$data_values_counter] = -100;
                }
            }
        }
        // if ( $section )
    }
    // while (!feof($fh))
    $data_values_counter++;
    fclose($fh);
    //exit;
}
// for($i=0; $i<count($filenames_array
//show_array($data_values3);
//echo "<br> $filenames_array[0]";
// Extract from the filename data time of creation
for ($i = 0; $i < count($filenames_array); $i++) {
    preg_match("/....-..-..--../", $filenames_array[$i], $match_result);
    //echo "<br> zebra $match_result[0]";
    //echo "<br> zebra trim " . str_replace("--", ":", ltrim($match_result[0], "20"));
    //$filenames_array_date[$i]=$match_result[0];
    $filenames_array_date[$i] = str_replace("--", ":", ltrim($match_result[0], "20"));
}
// for
echo "<br>";
draw_chart($data_values1, $filenames_array_date, "Wait Event: " . $statname . " : Waits", $db_name, 0, "");
#not interesting draw_chart($data_values2, $filenames_array_date, ("Wait Event: " . $statname . " : %Timout" ), $db_name, 0, "");
draw_chart($data_values3, $filenames_array_date, "Wait Event: " . $statname . " : Total Wait Time (s)", $db_name, 0, "");
draw_chart($data_values4, $filenames_array_date, "Wait Event: " . $statname . " : Avg wait (ms)", $db_name, 0, "");
//Include footer file with navigation links
require "footer.php";
exit;
コード例 #9
0
// 4 - $section_name - string
// 5 - Y/N whether to print the table with SQL explain plans through history. I provide the clean hash number if yes
// 6 - $dir - directory needed for sql explain plan in the end table
// For Buffer_Gets section
if (count($data_bg_values1) > 0) {
    echo "History of SQL with hash: <font color='black'> {$hash_value}</font>, Module: <font color='black'>{$module_bg_name}</font>, ";
    // The first elemnt of array $chart_leg that containst timestamp is the last data that we have statspack report
    // based on that I will present the hash history generated from the last statspacke report
    echo "<a href=\"show_file.php?filename=" . $dir . "hash_history/hash_" . $hash_value . "_" . $chart_bg_leg[0] . ".lst" . "\" >Show recent full SQL with explain plan, </a>";
    echo "SQL starts with: \"<font color='black'>{$sql_bg_text}</font>\" <BR>";
    draw_chart($data_bg_values1, $chart_bg_leg, $data_bg_values1_label . ", Hash: " . $hash_value . ", Module: " . $module_bg_name, "Buffer_Gets - Buffer Gets", 0, "");
    draw_chart($data_bg_values3, $chart_bg_leg, $data_bg_values3_label . ", Hash: " . $hash_value . ", Module: " . $module_bg_name, "Buffer_Gets - Gets per Exec", 0, "");
    draw_chart($data_bg_values6, $chart_bg_leg, $data_bg_values6_label . ", Hash: " . $hash_value . ", Module: " . $module_bg_name, "Buffer_Gets - Total Elapsed Time", 0, "");
    draw_chart($data_bg_values7, $chart_bg_leg, $data_bg_values7_label . ", Hash: " . $hash_value . ", Module: " . $module_bg_name, "Buffer_Gets - Total Elapsed Time per Exec", 0, "");
    draw_chart($data_bg_values2, $chart_bg_leg, $data_bg_values2_label . ", Hash: " . $hash_value . ", Module: " . $module_bg_name, "Buffer_Gets - Executions", $hash_value, $dir);
}
// For Physical_Reads section
if (count($data_pr_values1) > 0) {
    echo "History of SQL with hash: <font color='black'> {$hash_value}</font>, Module: <font color='black'>{$module_bg_name}</font>, ";
    // The first elemnt of array $chart_leg that containst timestamp is the last data that we have statspack report
    // based on that I will present the hash history generated from the last statspacke report
    echo "<a href=\"show_file.php?filename=" . $dir . "hash_history/hash_" . $hash_value . "_" . $chart_pr_leg[0] . ".lst" . "\" >Show recent full SQL with explain plan, </a>";
    echo "SQL starts with: \"<font color='black'>{$sql_pr_text}</font>\" <BR>";
    draw_chart($data_pr_values1, $chart_pr_leg, $data_pr_values1_label . ", Hash: " . $hash_value . ", Module: " . $module_pr_name, "Physical_Reads - Physical Reads", 0, "");
    draw_chart($data_pr_values3, $chart_pr_leg, $data_pr_values3_label . ", Hash: " . $hash_value . ", Module: " . $module_pr_name, "Physical_Reads - Reads per Exec", 0, "");
    draw_chart($data_pr_values6, $chart_pr_leg, $data_pr_values6_label . ", Hash: " . $hash_value . ", Module: " . $module_pr_name, "Physical_Reads - Total Elapsed Time", 0, "");
    draw_chart($data_pr_values7, $chart_pr_leg, $data_pr_values7_label . ", Hash: " . $hash_value . ", Module: " . $module_pr_name, "Physical_Reads - Total Elapsed Time per Exec", 0, "");
    draw_chart($data_pr_values2, $chart_pr_leg, $data_pr_values2_label . ", Hash: " . $hash_value . ", Module: " . $module_pr_name, "Physical_Reads - Executions", $hash_value, $dir);
}
//Include footer file with navigation links
require "footer.php";
コード例 #10
0
ファイル: diagram.php プロジェクト: ahviplc/judgegirl
    $oridata[0] = strtotime(mysql_result($result, 0));
    $min = $oridata[0];
    $cur = $min + 60 * 60;
    $curidx = 0;
    $data[0] = 1;
    for ($i = 1; $i < mysql_num_rows($result); $i++) {
        $oridata[$i] = strtotime(mysql_result($result, $i));
        while ($oridata[$i] > $cur) {
            $cur += 60 * 60;
            $curidx += 1;
            $data[$curidx] = 0;
        }
        $data[$curidx] += 1;
    }
}
draw_chart("Submittions", $data, 7, 1);
function draw_chart($title, $data, $colspan, $rowspan)
{
    $max = $data[0];
    for ($i = 0; $i < count($data); $i++) {
        if ($max < $data[$i]) {
            $max = $data[$i];
        }
    }
    $max += 1;
    print "<table border=0 bgcolor=#8888cc><tir><td><b><font size=2>{$title}</font><tr><td>";
    print "<table border=0 cellSpacing=0 cellPadding=0>";
    if ($max % $rowspan == 0) {
        print '<tr><td rowspan="' . $rowspan . '"><font size=2>';
        print $max;
        print '</font></td>';