Пример #1
0
 public function parseGlobalOptions(stdClass $a_options, ilChart $a_chart)
 {
     $spider = new stdClass();
     $spider->active = true;
     $spider->highlight = new stdClass();
     $spider->highlight->mode = "line";
     $spider->legs = new stdClass();
     $spider->legs->fillStyle = ilChart::renderColor("#000", "0.7");
     switch (count($a_chart->getLegLabels())) {
         case 4:
         case 6:
             $spider->legs->legStartAngle = 10;
             break;
         default:
             $spider->legs->legStartAngle = 0;
             break;
     }
     $spider->legs->data = array();
     $max_str_len = 0;
     foreach ($a_chart->getLegLabels() as $l) {
         $l = ilUtil::shortenText($l, 80, true);
         $label = new stdClass();
         $label->label = $l;
         $spider->legs->data[] = $label;
         $max_str_len = max($max_str_len, strlen($l));
     }
     // depending on caption length
     if ($max_str_len > 60) {
         $font_size = 10;
     } else {
         if ($max_str_len > 30) {
             $font_size = 12;
         } else {
             $font_size = 15;
         }
     }
     $spider->legs->font = $font_size . "px Arial";
     $spider->spiderSize = 0.7;
     $spider->lineWidth = 1;
     $spider->pointSize = 0;
     $spider->connection = new StdClass();
     $spider->connection->width = 2;
     $spider->legMin = 1.0E-7;
     $spider->legMax = $a_chart->getYAxisMax();
     $a_options->series->spider = $spider;
 }
Пример #2
0
 public function parseGlobalOptions(stdClass $a_options)
 {
     $a_options->grid = new stdClass();
     $a_options->grid->hoverable = false;
     $a_options->grid->clickable = false;
     $a_options->grid->ticks = $this->getYAxisMax();
     $a_options->grid->tickColor = ilChart::renderColor("#000", "0.1");
     $a_options->grid->mode = "spider";
 }
Пример #3
0
 protected function __construct($a_id)
 {
     parent::__construct($a_id);
     $this->setXAxisToInteger(false);
     $this->setYAxisToInteger(false);
 }
Пример #4
0
 protected function renderChart($a_id, $a_variables)
 {
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = ilChart::getInstanceByType(ilChart::TYPE_GRID, $a_id);
     $chart->setsize(700, 400);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     $chart->setYAxisToInteger(true);
     $data = $chart->getDataInstance(ilChartGrid::DATA_BARS);
     $data->setLabel($this->lng->txt("users_answered"));
     $data->setBarOptions(0.5, "center");
     $max = 5;
     if (sizeof($a_variables) <= $max) {
         if ($a_variables) {
             $labels = array();
             foreach ($a_variables as $idx => $points) {
                 $data->addPoint($idx, $points["selected"]);
                 $labels[$idx] = $idx + 1 . ". " . ilUtil::prepareFormOutput($points["title"]);
             }
             $chart->addData($data);
             $chart->setTicks($labels, false, true);
         }
         return "<div style=\"margin:10px\">" . $chart->getHTML() . "</div>";
     } else {
         $chart_legend = array();
         $labels = array();
         foreach ($a_variables as $idx => $points) {
             $data->addPoint($idx, $points["selected"]);
             $labels[$idx] = $idx + 1 . ".";
             $chart_legend[$idx + 1] = ilUtil::prepareFormOutput($points["title"]);
         }
         $chart->addData($data);
         $chart->setTicks($labels, false, true);
         $legend = "<table>";
         foreach ($chart_legend as $number => $caption) {
             $legend .= "<tr valign=\"top\"><td>" . $number . ".</td><td>" . $caption . "</td></tr>";
         }
         $legend .= "</table>";
         return "<div style=\"margin:10px\"><table><tr valign=\"bottom\"><td>" . $chart->getHTML() . "</td><td class=\"small\" style=\"padding-left:15px\">" . $legend . "</td></tr></table></div>";
     }
 }
Пример #5
0
 /**
  * Set fill
  *
  * @param float $a_value
  * @param string $a_color
  */
 public function setFill($a_value, $a_color = null)
 {
     $this->fill = $a_value;
     if (ilChart::isValidColor($a_color)) {
         $this->fill_color = $a_color;
     }
 }
 /**
  * Build chart for active sessions
  * 
  * @param array $a_data
  * @param string $a_title
  * @param int $a_scale
  * @param array $a_measure
  * @return string 
  */
 protected function getChart($a_data, $a_title, $a_scale = self::SCALE_DAY, $a_measure = null)
 {
     global $lng;
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = new ilChart("objstacc", 700, 500);
     $chart->setYAxisToInteger(true);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     if (!$a_measure) {
         $a_measure = array("min", "avg", "max");
     } else {
         if (!is_array($a_measure)) {
             $a_measure = array($a_measure);
         }
     }
     $colors_map = array("min" => "#00cc00", "avg" => "#0000cc", "max" => "#cc00cc");
     $colors = $act_line = array();
     foreach ($a_measure as $measure) {
         $act_line[$measure] = new ilChartData("lines");
         $act_line[$measure]->setLineSteps(true);
         $act_line[$measure]->setLabel($lng->txt("trac_session_active_" . $measure));
         $colors[] = $colors_map[$measure];
     }
     if ($a_scale != self::SCALE_PERIODIC_WEEK) {
         $max_line = new ilChartData("lines");
         $max_line->setLabel($lng->txt("session_max_count"));
         $colors[] = "#cc0000";
     }
     $chart->setColors($colors);
     $chart_data = $this->adaptDataToScale($a_scale, $a_data, 700);
     unset($a_data);
     $scale = ceil(sizeof($chart_data) / 5);
     $labels = array();
     foreach ($chart_data as $idx => $item) {
         $date = $item["slot_begin"];
         if ($a_scale == self::SCALE_PERIODIC_WEEK || !($idx % ceil($scale))) {
             switch ($a_scale) {
                 case self::SCALE_DAY:
                     $labels[$date] = date("H:i", $date);
                     break;
                 case self::SCALE_WEEK:
                     $labels[$date] = date("d.m. H", $date) . "h";
                     break;
                 case self::SCALE_MONTH:
                     $labels[$date] = date("d.m.", $date);
                     break;
                 case self::SCALE_YEAR:
                     $labels[$date] = date("Y-m", $date);
                     break;
                 case self::SCALE_PERIODIC_WEEK:
                     $day = substr($date, 0, 1);
                     $hour = substr($date, 1, 2);
                     $min = substr($date, 3, 2);
                     // build ascending scale from day values
                     $day_value = ($day - 1) * 60 * 60 * 24;
                     $date = $day_value + $hour * 60 * 60 + $min * 60;
                     // 6-hour interval labels
                     if ($hour != $old_hour && $hour && $hour % 6 == 0) {
                         $labels[$date] = $hour;
                         $old_hour = $hour;
                     }
                     // day label
                     if ($day != $old_day) {
                         $labels[$date] = ilCalendarUtil::_numericDayToString($day, false);
                         $old_day = $day;
                     }
                     break;
             }
         }
         foreach ($a_measure as $measure) {
             $value = (int) $item["active_" . $measure];
             $act_line[$measure]->addPoint($date, $value);
         }
         if ($a_scale != self::SCALE_PERIODIC_WEEK) {
             $max_line->addPoint($date, (int) $item["max_sessions"]);
         }
     }
     foreach ($act_line as $line) {
         $chart->addData($line);
     }
     if ($a_scale != self::SCALE_PERIODIC_WEEK) {
         $chart->addData($max_line);
     }
     $chart->setTicks($labels, null, true);
     return $chart->getHTML();
 }
Пример #7
0
 /**
  * Convert (global) properties to flot config
  * 
  * @param object $a_options	 
  */
 public function parseOptions(stdClass $a_options)
 {
     $a_options->show = true;
     $a_options->noColumns = $this->getColumns();
     $a_options->position = $this->getPosition();
     $margin = $this->getMargin();
     $a_options->margin = array($margin["x"], $margin["y"]);
     $a_options->backgroundColor = ilChart::renderColor($this->getBackground());
     $a_options->backgroundOpacity = str_replace(",", ".", $this->getOpacity());
     $a_options->labelBoxBorderColor = ilChart::renderColor($this->getLabelBorder());
     $container = $this->getContainer();
     if ($container) {
         $a_options->container = '#' . $container;
     }
 }
Пример #8
0
 function fillRow($a_poll)
 {
     global $ilCtrl, $lng, $ilUser, $tpl;
     // handle messages
     $mess = $this->poll_block->getMessage($ilUser->getId());
     if ($mess) {
         $this->tpl->setVariable("TXT_QUESTION", $mess);
         return;
     }
     // nested form problem
     if (!$_SESSION["il_cont_admin_panel"]) {
         // vote
         if ($this->poll_block->mayVote($ilUser->getId())) {
             $this->tpl->setCurrentBlock("mode_info_bl");
             if ($this->poll_block->getPoll()->getNonAnonymous()) {
                 $mode_info = $lng->txt("poll_non_anonymous_warning");
             } else {
                 $mode_info = $lng->txt("poll_anonymous_warning");
             }
             $this->tpl->setVariable("MODE_INFO", $mode_info);
             $this->tpl->parseCurrentBlock();
             $is_multi_answer = $this->poll_block->getPoll()->getMaxNumberOfAnswers() > 1;
             if (isset($_SESSION["last_poll_vote"][$this->poll_block->getPoll()->getId()])) {
                 $last_vote = $_SESSION["last_poll_vote"][$this->poll_block->getPoll()->getId()];
                 unset($_SESSION["last_poll_vote"][$this->poll_block->getPoll()->getId()]);
                 if ($is_multi_answer) {
                     $error = sprintf($lng->txt("poll_vote_error_multi"), $this->poll_block->getPoll()->getMaxNumberOfAnswers());
                 } else {
                     $error = $lng->txt("poll_vote_error_single");
                 }
                 $this->tpl->setCurrentBlock("error_bl");
                 $this->tpl->setVariable("FORM_ERROR", $error);
                 $this->tpl->parseCurrentBlock();
             }
             $this->tpl->setCurrentBlock("answer");
             foreach ($a_poll->getAnswers() as $item) {
                 if (!$is_multi_answer) {
                     $this->tpl->setVariable("ANSWER_INPUT", "radio");
                     $this->tpl->setVariable("ANSWER_NAME", "aw");
                 } else {
                     $this->tpl->setVariable("ANSWER_INPUT", "checkbox");
                     $this->tpl->setVariable("ANSWER_NAME", "aw[]");
                     if (is_array($last_vote) && in_array($item["id"], $last_vote)) {
                         $this->tpl->setVariable("ANSWER_STATUS", 'checked="checked"');
                     }
                 }
                 $this->tpl->setVariable("VALUE_ANSWER", $item["id"]);
                 $this->tpl->setVariable("TXT_ANSWER_VOTE", nl2br($item["answer"]));
                 $this->tpl->parseCurrentBlock();
             }
             $ilCtrl->setParameterByClass($this->getRepositoryObjectGUIName(), "ref_id", $this->getRefId());
             $url = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", $this->getRepositoryObjectGUIName()), "vote");
             $ilCtrl->clearParametersByClass($this->getRepositoryObjectGUIName());
             $url .= "#poll" . $a_poll->getID();
             $this->tpl->setVariable("URL_FORM", $url);
             $this->tpl->setVariable("CMD_FORM", "vote");
             $this->tpl->setVariable("TXT_SUBMIT", $lng->txt("poll_vote"));
             if ($this->poll_block->getPoll()->getVotingPeriod()) {
                 $this->tpl->setVariable("TXT_VOTING_PERIOD", sprintf($lng->txt("poll_voting_period_info"), ilDatePresentation::formatDate(new ilDateTime($this->poll_block->getPoll()->getVotingPeriodEnd(), IL_CAL_UNIX))));
             }
         }
         // result
         if ($this->poll_block->maySeeResults($ilUser->getId())) {
             if (!$this->poll_block->mayNotResultsYet($ilUser->getId())) {
                 $answers = array();
                 foreach ($a_poll->getAnswers() as $item) {
                     $answers[$item["id"]] = $item["answer"];
                 }
                 $perc = $this->poll_block->getPoll()->getVotePercentages();
                 $total = $perc["total"];
                 $perc = $perc["perc"];
                 $this->tpl->setVariable("TOTAL_ANSWERS", sprintf($lng->txt("poll_population"), $total));
                 if ($total) {
                     // sort results by votes / original position
                     if ($this->poll_block->getPoll()->getSortResultByVotes()) {
                         $order = array_keys(ilUtil::sortArray($perc, "abs", "desc", true, true));
                         foreach (array_keys($answers) as $answer_id) {
                             if (!in_array($answer_id, $order)) {
                                 $order[] = $answer_id;
                             }
                         }
                     } else {
                         $order = array_keys($answers);
                     }
                     // pie chart
                     if ($this->poll_block->showResultsAs() == ilObjPoll::SHOW_RESULTS_AS_PIECHART) {
                         include_once "./Services/Chart/classes/class.ilChart.php";
                         $chart = ilChart::getInstanceByType(ilCHart::TYPE_PIE, "poll_results_pie_" . $this->getRefId());
                         $chart->setSize("100%", 200);
                         $chart->setAutoResize(true);
                         $chart_data = $chart->getDataInstance();
                         foreach ($order as $answer_id) {
                             $chart_data->addPoint(round($perc[$answer_id]["perc"]), nl2br($answers[$answer_id]));
                         }
                         // disable legend, use inner labels - currently not preferred
                         // $chart_data->setLabelRadius(0.8);
                         $chart->addData($chart_data);
                         $pie_legend_id = "poll_legend_" . $this->getRefId();
                         $legend = new ilChartLegend();
                         $legend->setContainer($pie_legend_id);
                         $chart->setLegend($legend);
                         $this->tpl->setVariable("PIE_LEGEND_ID", $pie_legend_id);
                         $this->tpl->setVariable("PIE_CHART", $chart->getHTML());
                     } else {
                         include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
                         $this->tpl->setCurrentBlock("answer_result");
                         foreach ($order as $answer_id) {
                             $pbar = ilProgressBar::getInstance();
                             $pbar->setCurrent(round($perc[$answer_id]["perc"]));
                             $this->tpl->setVariable("PERC_ANSWER_RESULT", $pbar->render());
                             $this->tpl->setVariable("TXT_ANSWER_RESULT", nl2br($answers[$answer_id]));
                             $this->tpl->parseCurrentBlock();
                         }
                     }
                 }
             } else {
                 $rel = ilDatePresentation::useRelativeDates();
                 ilDatePresentation::setUseRelativeDates(false);
                 $end = $this->poll_block->getPoll()->getVotingPeriodEnd();
                 $end = ilDatePresentation::formatDate(new ilDateTime($end, IL_CAL_UNIX));
                 ilDatePresentation::setUseRelativeDates($rel);
                 // #14607
                 $info = "";
                 if ($this->poll_block->getPoll()->hasUserVoted($ilUser->getId())) {
                     $info .= $lng->txt("poll_block_message_already_voted") . " ";
                 }
                 $this->tpl->setVariable("TOTAL_ANSWERS", $info . sprintf($lng->txt("poll_block_results_available_on"), $end));
             }
         } else {
             if ($this->poll_block->getPoll()->hasUserVoted($ilUser->getId())) {
                 $this->tpl->setVariable("TOTAL_ANSWERS", $lng->txt("poll_block_message_already_voted"));
             }
         }
     }
     $this->tpl->setVariable("ANCHOR_ID", $a_poll->getID());
     $this->tpl->setVariable("TXT_QUESTION", nl2br(trim($a_poll->getQuestion())));
     $desc = trim($a_poll->getDescription());
     if ($desc) {
         $this->tpl->setVariable("TXT_DESC", nl2br($desc));
     }
     $img = $a_poll->getImageFullPath();
     if ($img) {
         $this->tpl->setVariable("URL_IMAGE", $img);
     }
     if ($this->poll_block->showComments()) {
         $this->tpl->setCurrentBlock("comment_link");
         $this->tpl->setVariable("LANG_COMMENTS", $lng->txt('poll_comments'));
         $this->tpl->setVariable("COMMENT_JSCALL", $this->commentJSCall());
         $this->tpl->setVariable("COMMENTS_COUNT_ID", $this->getRefId());
         $comments_count = $this->getNumberOfComments($this->getRefId());
         if ($comments_count > 0) {
             $this->tpl->setVariable("COMMENTS_COUNT", "(" . $comments_count . ")");
         }
         if (!self::$js_init) {
             $redraw_url = $ilCtrl->getLinkTarget($this, "getNumberOfCommentsForRedraw", "", true, false);
             $this->tpl->setVariable("COMMENTS_REDRAW_URL", $redraw_url);
             $tpl->addJavaScript("Modules/Poll/js/ilPoll.js");
             self::$js_init = true;
         }
     }
 }
 function getGraph(array $a_graph_items)
 {
     global $lng;
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = new ilChart("objstdly", 700, 500);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     $max_value = 0;
     foreach ($this->getData() as $object) {
         if (in_array($object["obj_id"], $a_graph_items)) {
             $series = new ilChartData("lines");
             $series->setLabel(ilObject::_lookupTitle($object["obj_id"]));
             for ($loop = 0; $loop < 24; $loop++) {
                 $value = (int) $object["graph"]["hour" . $loop];
                 $max_value = max($max_value, $value);
                 if ($this->filter["measure"] != "spent_seconds") {
                     $value = $this->anonymizeValue($value, true);
                 }
                 $series->addPoint($loop, $value);
             }
             $chart->addData($series);
         }
     }
     $value_ticks = $this->buildValueScale($max_value, $this->filter["measure"] != "spent_seconds", $this->filter["measure"] == "spent_seconds");
     $labels = array();
     for ($loop = 0; $loop < 24; $loop++) {
         $labels[$loop] = str_pad($loop, 2, "0", STR_PAD_LEFT);
     }
     $chart->setTicks($labels, $value_ticks, true);
     return $chart->getHTML();
 }
Пример #10
0
 /**
  * Convert data to flot config
  * 
  * @param array $a_data
  * @return object
  */
 public function parseData(array &$a_data)
 {
     $series = new stdClass();
     $series->label = str_replace("\"", "\\\"", $this->getLabel());
     $series->data = array();
     foreach ($this->getData() as $point) {
         $series->data[] = array($point[0], $point[1]);
     }
     $options = array("show" => $this->isHidden() ? false : true);
     $fill = $this->getFill();
     if ($fill["fill"]) {
         $options["fill"] = $fill["fill"];
         if ($fill["color"]) {
             $options["fillColor"] = ilChart::renderColor($fill["color"], $fill["fill"]);
         }
     }
     $this->parseDataOptions($options);
     $series->{$this->getTypeString()} = $options;
     $a_data[] = $series;
 }
 function getGraph(array $a_graph_items)
 {
     global $lng;
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = ilChart::getInstanceByType(ilChart::TYPE_GRID, "objstacc");
     $chart->setSize(700, 500);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     $max_value = 0;
     foreach ($this->getData() as $object) {
         if (in_array($object["obj_id"], $a_graph_items)) {
             $series = $chart->getDataInstance(ilChartGrid::DATA_LINES);
             $series->setLabel(ilObject::_lookupTitle($object["obj_id"]));
             if (strpos($this->filter["yearmonth"], "-") === false) {
                 foreach (array_keys($this->getMonthsYear($this->filter["yearmonth"])) as $idx => $num) {
                     $value = (int) $object["month_" . $num];
                     $max_value = max($max_value, $value);
                     if ($this->filter["measure"] != "spent_seconds") {
                         $value = $this->anonymizeValue($value, true);
                     }
                     $series->addPoint($idx, $value);
                 }
             } else {
                 for ($loop = 1; $loop < 32; $loop++) {
                     $value = (int) $object["day_" . $loop];
                     $max_value = max($max_value, $value);
                     if ($this->filter["measure"] != "spent_seconds") {
                         $value = $this->anonymizeValue($value, true);
                     }
                     $series->addPoint($loop, $value);
                 }
             }
             $chart->addData($series);
         }
     }
     $value_ticks = $this->buildValueScale($max_value, $this->filter["measure"] != "spent_seconds", $this->filter["measure"] == "spent_seconds");
     $labels = array();
     if (strpos($this->filter["yearmonth"], "-") === false) {
         foreach (array_values($this->getMonthsYear($this->filter["yearmonth"], true)) as $idx => $caption) {
             $labels[$idx] = $caption;
         }
     } else {
         for ($loop = 1; $loop < 32; $loop++) {
             $labels[$loop] = $loop . ".";
         }
     }
     $chart->setTicks($labels, $value_ticks, true);
     return $chart->getHTML();
 }
 protected function renderChart($a_id, $a_values)
 {
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = ilChart::getInstanceByType(ilChart::TYPE_GRID, $a_id);
     $chart->setsize(700, 400);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     $data = $chart->getDataInstance(ilChartGrid::DATA_BARS);
     $data->setLabel($this->lng->txt("users_answered"));
     $data->setBarOptions(0.1, "center");
     if ($a_values) {
         $labels = array();
         foreach ($a_values as $idx => $answer) {
             $data->addPoint($answer["value"], $answer["selected"]);
             $labels[$answer["value"]] = $answer["value"];
         }
         $chart->addData($data);
         $chart->setTicks($labels, false, true);
     }
     return "<div style=\"margin:10px\">" . $chart->getHTML() . "</div>";
 }
 function getGraph(array $a_graph_items)
 {
     global $lng;
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = ilChart::getInstanceByType(ilChart::TYPE_GRID, "objsttp");
     $chart->setsize(700, 500);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     $types = array();
     foreach ($this->getData() as $id => $item) {
         $types[$id] = $item["title"];
     }
     foreach (array_values($this->getMonthsYear($this->filter["year"], true)) as $idx => $caption) {
         $labels[$idx + 1] = $caption;
     }
     $chart->setTicks($labels, false, true);
     foreach ($this->getData() as $type => $object) {
         if (in_array($type, $a_graph_items)) {
             $series = $chart->getDataInstance(ilChartGrid::DATA_LINES);
             $series->setLabel($types[$type]);
             foreach (array_keys($this->getMonthsYear($this->filter["year"])) as $idx => $month) {
                 $series->addPoint($idx + 1, (int) $object["month_" . $month]);
             }
             $chart->addData($series);
         }
     }
     return $chart->getHTML();
 }
Пример #14
0
 /**
  * Set label border
  *
  * @param string $a_color
  */
 public function setLabelBorder($a_color)
 {
     if (ilChart::isValidColor($a_color)) {
         $this->border = $a_color;
     }
 }
 /**
  * Get gap analysis html
  *
  * @param
  * @return
  */
 function getGapAnalysisHTML($a_user_id = 0, $a_skills = null)
 {
     global $ilUser, $lng;
     //		$this->setTabs("list_skills");
     if ($a_user_id == 0) {
         $user_id = $ilUser->getId();
     } else {
         $user_id = $a_user_id;
     }
     $skills = array();
     if ($this->getProfileId() > 0) {
         $profile = new ilSkillProfile($this->getProfileId());
         $this->profile_levels = $profile->getSkillLevels();
         foreach ($this->profile_levels as $l) {
             $skills[] = array("base_skill_id" => $l["base_skill_id"], "tref_id" => $l["tref_id"], "level_id" => $l["level_id"]);
         }
     } else {
         if (is_array($a_skills)) {
             $skills = $a_skills;
         }
     }
     // get actual levels for gap analysis
     $this->actual_levels = array();
     include_once "./Services/Skill/classes/class.ilBasicSkill.php";
     foreach ($skills as $sk) {
         $bs = new ilBasicSkill($sk["base_skill_id"]);
         if ($this->gap_mode == "max_per_type") {
             $max = $bs->getMaxLevelPerType($sk["tref_id"], $this->gap_mode_type, $user_id);
             $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
         } else {
             if ($this->gap_mode == "max_per_object") {
                 $max = $bs->getMaxLevelPerObject($sk["tref_id"], $this->gap_mode_obj_id, $user_id);
                 $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
             }
         }
     }
     $incl_self_eval = false;
     if (count($this->getGapAnalysisSelfEvalLevels() > 0)) {
         $incl_self_eval = true;
         $self_vals = $this->getGapAnalysisSelfEvalLevels();
     }
     // output spider stuff
     if (count($skills) >= 3) {
         $max_cnt = 0;
         $leg_labels = array();
         //var_dump($this->profile_levels);
         //foreach ($this->profile_levels as $k => $l)
         // write target, actual and self counter to skill array
         foreach ($skills as $k => $l) {
             //$bs = new ilBasicSkill($l["base_skill_id"]);
             $bs = new ilBasicSkill($l["base_skill_id"]);
             $leg_labels[] = $bs->getTitle();
             $levels = $bs->getLevelData();
             $cnt = 0;
             foreach ($levels as $lv) {
                 $cnt++;
                 if ($l["level_id"] == $lv["id"]) {
                     $skills[$k]["target_cnt"] = $cnt;
                 }
                 if ($this->actual_levels[$l["base_skill_id"]][$l["tref_id"]] == $lv["id"]) {
                     $skills[$k]["actual_cnt"] = $cnt;
                 }
                 if ($incl_self_eval) {
                     if ($self_vals[$l["base_skill_id"]][$l["tref_id"]] == $lv["id"]) {
                         $skills[$k]["self_cnt"] = $cnt;
                     }
                 }
                 $max_cnt = max($max_cnt, $cnt);
             }
         }
         //			$leg_labels = array("AAAAA", "BBBBB", "CCCCC");
         //var_dump($this->profile_levels);
         //var_dump($this->actual_levels);
         include_once "./Services/Chart/classes/class.ilChart.php";
         $chart = new ilChart("gap_chart", 600, 300);
         $chart->setYAxisMax($max_cnt);
         $chart->setLegLabels($leg_labels);
         // target level
         $cd = new ilChartData("spider");
         $cd->setLabel($lng->txt("skmg_target_level"));
         $cd->setFill("true", "#A0A0A0");
         // other users
         $cd2 = new ilChartData("spider");
         if ($this->gap_cat_title != "") {
             $cd2->setLabel($this->gap_cat_title);
         } else {
             if ($this->gap_mode == "max_per_type") {
                 $cd2->setLabel($lng->txt("objs_" . $this->gap_mode_type));
             } else {
                 if ($this->gap_mode == "max_per_object") {
                     $cd2->setLabel(ilObject::_lookupTitle($this->gap_mode_obj_id));
                 }
             }
         }
         $cd2->setFill("true", "#8080FF");
         // self evaluation
         if ($incl_self_eval) {
             $cd3 = new ilChartData("spider");
             $cd3->setLabel($lng->txt("skmg_self_evaluation"));
             $cd3->setFill("true", "#FF8080");
         }
         // fill in data
         $cnt = 0;
         foreach ($skills as $pl) {
             $cd->addPoint($cnt, (int) $pl["target_cnt"]);
             $cd2->addPoint($cnt, (int) $pl["actual_cnt"]);
             if ($incl_self_eval) {
                 $cd3->addPoint($cnt, (int) $pl["self_cnt"]);
             }
             $cnt++;
         }
         // add data to chart
         if ($this->getProfileId() > 0) {
             $chart->addData($cd);
         }
         $chart->addData($cd2);
         if ($incl_self_eval && count($this->getGapAnalysisSelfEvalLevels()) > 0) {
             $chart->addData($cd3);
         }
         $lg = new ilChartLegend();
         $chart->setLegend($lg);
         $chart_html = $chart->getHTML();
     }
     $stree = new ilSkillTree();
     $html = "";
     foreach ($skills as $s) {
         $path = $stree->getSkillTreePath($s["base_skill_id"]);
         // check draft
         foreach ($path as $p) {
             if ($p["draft"]) {
                 continue 2;
             }
         }
         $html .= $this->getSkillHTML($s["base_skill_id"], $user_id, false, $s["tref_id"]);
     }
     // list skills
     //		include_once("./Services/Skill/classes/class.ilPersonalSkillTableGUI.php");
     //		$sktab = new ilPersonalSkillTableGUI($this, "listSkills");
     return $chart_html . $html;
 }
 function getGraph(array $a_graph_items)
 {
     global $lng;
     $a_graph_items = array(array_pop($a_graph_items));
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = new ilChart("objstlp", 700, 500);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     // needed for correct stacking
     $custom_order = array(ilLPStatus::LP_STATUS_IN_PROGRESS_NUM => array("#f7d408", "#fffa00"), ilLPStatus::LP_STATUS_FAILED_NUM => array("#cf0202", "#f15b5b"), ilLPStatus::LP_STATUS_COMPLETED_NUM => array("#17aa0e", "#6ce148"), ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM => array("#a4a4a4", "#c4c4c4"));
     $chart->setColors(array());
     $max_value = 0;
     foreach ($this->chart_data as $object_id => $days) {
         if (in_array($object_id, $a_graph_items)) {
             $series = array();
             foreach ($custom_order as $status => $colors) {
                 /*
                 if(strpos($this->filter["yearmonth"], "-") === false)
                 {
                 	$series[$status] = new ilChartData("lines");
                 	$series[$status]->setLineSteps(true);
                 }
                 else
                 {						
                 	$series[$status] = new ilChartData("bars");
                 	$series[$status]->setBarOptions(0.75);
                 	$series[$status]->setFill(true, $colors[1]);
                 }										
                 $series[$status]->setStackingId($object_id);					
                 */
                 $series[$status] = new ilChartData("lines");
                 $series[$status]->setLabel(ilLearningProgressBaseGUI::_getStatusText($status));
                 $chart_colors[] = $colors[0];
             }
             $chart->setColors($chart_colors);
             if (strpos($this->filter["yearmonth"], "-") === false) {
                 $x_axis = $this->lng->txt("month");
                 $counter = 0;
                 foreach (array_keys($this->getMonthsYear($this->filter["yearmonth"])) as $month) {
                     for ($loop = 1; $loop < 32; $loop++) {
                         $item_day = $month . "-" . str_pad($loop, 2, "0", STR_PAD_LEFT);
                         foreach (array_keys($custom_order) as $status) {
                             if (isset($days[$item_day])) {
                                 // as there is only 1 entry per day, avg == sum
                                 $value = (int) $days[$item_day][$this->status_map[$status] . "_avg"];
                             } else {
                                 $value = 0;
                             }
                             $max_value = max($max_value, $value);
                             $value = $this->anonymizeValue($value, true);
                             $series[$status]->addPoint($counter, $value);
                         }
                         $counter++;
                     }
                 }
             } else {
                 $x_axis = $this->lng->txt("day");
                 for ($loop = 1; $loop < 32; $loop++) {
                     foreach (array_keys($custom_order) as $status) {
                         if (isset($days[$loop])) {
                             // as there is only 1 entry per day, avg == sum
                             $value = (int) $days[$loop][$this->status_map[$status] . "_avg"];
                         } else {
                             $value = 0;
                         }
                         $max_value = max($max_value, $value);
                         $value = $this->anonymizeValue($value, true);
                         $series[$status]->addPoint($loop, $value);
                     }
                 }
             }
             foreach (array_keys($custom_order) as $status) {
                 $chart->addData($series[$status]);
             }
         }
     }
     $value_ticks = $this->buildValueScale($max_value, true);
     $labels = array();
     if (strpos($this->filter["yearmonth"], "-") === false) {
         $counter = 0;
         foreach ($this->getMonthsYear($this->filter["yearmonth"], true) as $caption) {
             $labels[$counter] = $caption;
             $counter += 31;
         }
     } else {
         for ($loop = 1; $loop < 32; $loop++) {
             $labels[$loop] = $loop . ".";
         }
     }
     $chart->setTicks($labels, $value_ticks, true);
     return $chart->getHTML();
 }
 function getGraph(array $a_graph_items)
 {
     global $lng;
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = new ilChart("objsttp", 700, 500);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     $types = array();
     foreach ($this->getData() as $id => $item) {
         $types[$id] = $item["title"];
     }
     foreach (array_values($this->getMonthsYear(null, true)) as $idx => $caption) {
         $labels[$idx + 1] = $caption;
     }
     $chart->setTicks($labels, false, true);
     foreach ($this->getData() as $type => $object) {
         if (in_array($type, $a_graph_items)) {
             $series = new ilChartData("lines");
             $series->setLabel($types[$type]);
             foreach (array_keys($this->getMonthsYear()) as $idx => $month) {
                 $series->addPoint($idx + 1, (int) $object["month_" . $month]);
             }
             $chart->addData($series);
         }
     }
     return $chart->getHTML();
 }
Пример #18
0
 protected function renderGraph($a_figure, array $a_data)
 {
     $scope = ceil(sizeof($a_data) / 31);
     include_once "Services/Chart/classes/class.ilChartGrid.php";
     $chart = ilChart::getInstanceByType(ilChart::TYPE_GRID, "wikistat");
     $chart->setSize("100%", 400);
     $chart->setColors(array("#C0E0FF"));
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     // lines vs. bars
     if (in_array($a_figure, array(ilWikiStat::KEY_FIGURE_WIKI_NUM_PAGES, ilWikiStat::KEY_FIGURE_WIKI_INTERNAL_LINKS, ilWikiStat::KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG, ilWikiStat::KEY_FIGURE_WIKI_EXTERNAL_LINKS, ilWikiStat::KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG, ilWikiStat::KEY_FIGURE_WIKI_WORDS, ilWikiStat::KEY_FIGURE_WIKI_WORDS_AVG, ilWikiStat::KEY_FIGURE_WIKI_CHARS, ilWikiStat::KEY_FIGURE_WIKI_CHARS_AVG, ilWikiStat::KEY_FIGURE_WIKI_FOOTNOTES, ilWikiStat::KEY_FIGURE_WIKI_FOOTNOTES_AVG, ilWikiStat::KEY_FIGURE_WIKI_RATING_AVG, ilWikiStat::KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS, ilWikiStat::KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS, ilWikiStat::KEY_FIGURE_WIKI_PAGE_WORDS, ilWikiStat::KEY_FIGURE_WIKI_PAGE_CHARS, ilWikiStat::KEY_FIGURE_WIKI_PAGE_FOOTNOTES))) {
         $series = $chart->getDataInstance(ilChartGrid::DATA_LINES);
         $series->setLineSteps(true);
         $series->setFill(true, "#E0F0FF");
     } else {
         $series = $chart->getDataInstance(ilChartGrid::DATA_BARS);
         $series->setBarOptions(round(10 / ($scope * 2)) / 10);
     }
     $series->setLabel(ilWikiStat::getFigureTitle($a_figure));
     $labels = array();
     $x = 0;
     foreach ($a_data as $date => $value) {
         $series->addPoint($x, $value);
         $day = (int) substr($date, 8, 2);
         // match scale to scope
         if ($scope == 1) {
             // daily
             $labels[$x] = substr($date, 8, 2);
         } elseif ($scope == 2) {
             // weekly
             if (!($x % 7)) {
                 $labels[$x] = substr($date, 8, 2) . "." . substr($date, 5, 2) . ".";
             }
         } else {
             // 1st/15th
             if ($day == 1 || $day == 15 || $x == sizeof($a_data) - 1) {
                 $labels[$x] = substr($date, 8, 2) . "." . substr($date, 5, 2) . ".";
             }
         }
         $x++;
     }
     $chart->addData($series);
     $chart->setTicks($labels, null, true);
     // int vs. float (averages)
     if (in_array($a_figure, array(ilWikiStat::KEY_FIGURE_WIKI_NUM_PAGES, ilWikiStat::KEY_FIGURE_WIKI_NEW_PAGES, ilWikiStat::KEY_FIGURE_WIKI_EDIT_PAGES, ilWikiStat::KEY_FIGURE_WIKI_DELETED_PAGES, ilWikiStat::KEY_FIGURE_WIKI_READ_PAGES, ilWikiStat::KEY_FIGURE_WIKI_USER_EDIT_PAGES, ilWikiStat::KEY_FIGURE_WIKI_NUM_RATING, ilWikiStat::KEY_FIGURE_WIKI_INTERNAL_LINKS, ilWikiStat::KEY_FIGURE_WIKI_EXTERNAL_LINKS, ilWikiStat::KEY_FIGURE_WIKI_WORDS, ilWikiStat::KEY_FIGURE_WIKI_CHARS, ilWikiStat::KEY_FIGURE_WIKI_FOOTNOTES, ilWikiStat::KEY_FIGURE_WIKI_PAGE_CHANGES, ilWikiStat::KEY_FIGURE_WIKI_PAGE_USER_EDIT, ilWikiStat::KEY_FIGURE_WIKI_PAGE_READ, ilWikiStat::KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS, ilWikiStat::KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS, ilWikiStat::KEY_FIGURE_WIKI_PAGE_WORDS, ilWikiStat::KEY_FIGURE_WIKI_PAGE_CHARS, ilWikiStat::KEY_FIGURE_WIKI_PAGE_FOOTNOTES, ilWikiStat::KEY_FIGURE_WIKI_PAGE_RATINGS))) {
         $chart->setYAxisToInteger(true);
     }
     return $chart->getHTML();
 }
Пример #19
0
 public function parseGlobalOptions(stdClass $a_options, ilChart $a_chart)
 {
     $a_options->series->pie = new stdClass();
     $a_options->series->pie->show = true;
     // fill vs. stroke - trying to normalize data attributes
     $fill = $this->getFill();
     $width = $this->getLineWidth();
     if ($fill["fill"] || $width) {
         $a_options->series->pie->stroke = new stdClass();
         if ($width) {
             $a_options->series->pie->stroke->width = $width;
         }
         if ($fill["color"]) {
             $a_options->series->pie->stroke->color = ilChart::renderColor($fill["color"], $fill["fill"]);
         }
     }
     $radius = $this->getLabelRadius();
     if ($radius) {
         $a_options->series->pie->label = new stdClass();
         $a_options->series->pie->label->background = new stdClass();
         $a_options->series->pie->radius = 1;
         $a_options->series->pie->label->radius = $radius;
         $a_options->series->pie->label->show = true;
         $a_options->series->pie->label->background->color = "#444";
         $a_options->series->pie->label->background->opacity = 0.8;
     }
 }