Skip to content

Commit

Permalink
Merge pull request #3 from dkloepfer/4_4_gev_ta
Browse files Browse the repository at this point in the history
ILIAS-eLearning#2392 svg and pdf creation
  • Loading branch information
shecken authored Sep 15, 2016
2 parents 20eac44 + ad07e9a commit 6b0147a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class ReportSVGRenderer {

const MAX_WIDTH = 500;
const MAX_WIDTH = 1000;

protected $categories = array();
protected $scale = array();
Expand Down Expand Up @@ -172,7 +172,7 @@ protected function renderLegend(\ilTemplate $tpl) {

$insufficient_width = $sufficient * $inner_width / $max_score - $legend_delimiter_width;
$sufficient_position = $insufficient_width + $legend_delimiter_width;
$sufficient_width = ($excellent - $sufficient) * $inner_width / $max_score - $legend_delimiter_width;
$sufficient_width = max(($excellent - $sufficient) * $inner_width / $max_score - $legend_delimiter_width,0);
$excellent_position = $sufficient_position + $sufficient_width + $legend_delimiter_width;
$excellent_width = ($max_score - $excellent) * $inner_width / $max_score;

Expand Down Expand Up @@ -221,7 +221,7 @@ protected function renderCategory(\ilTemplate $tpl, $category_title, $category_s
$inner_width = $this->inner_width;

$score_width = $inner_width * $category_score / $this->max_score;
$fill_width = $inner_width - $score_width - $delimiter_width;
$fill_width = max($inner_width - $score_width - $delimiter_width,0);
$fill_position = $score_width + $delimiter_width;

$tpl->setVariable('GRAPH_WIDTH_ACHIEVED',$score_width);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
namespace CaT\Plugins\TalentAssessment\Observations;
require_once 'Services/Utilities/classes/class.ilUtil.php';

class SVGConverter {
public function __construct($img_markup_string) {
$this->img = $img_markup_string;
}

public function ConvertAndReturnPath($format = 'png24') {
$svg_file_h = tmpfile();
$png_file_h = tmpfile();
fwrite($svg_file_h, $this->img);
$svg_filename = stream_get_meta_data($svg_file_h)['uri'];
rename($svg_filename, $svg_filename.'.svg');
$png_filename = stream_get_meta_data($png_file_h)['uri'];
\ilUtil::convertImage($svg_filename.'.svg', $png_filename, $format);
rename($svg_filename.'.svg', $svg_filename);
rename($png_filename, $png_filename.'.png');
$png_filename .= '.png';
return $png_filename;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6b0147a

Please sign in to comment.