Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6 from studer-raimann/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
chfsx committed Mar 3, 2015
2 parents 27b017e + cedd426 commit c7a723c
Show file tree
Hide file tree
Showing 15 changed files with 755 additions and 256 deletions.
82 changes: 82 additions & 0 deletions classes/Config/class.xlvoConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
require_once('./include/inc.ilias_version.php');
require_once('./Services/Component/classes/class.ilComponent.php');

/**
* Class xlvoConfig
*
* @author Fabian Schmid <[email protected]>
* @version 1.0.0
*/
class xlvoConfig {

const ILIAS_44 = 44;
const ILIAS_50 = 50;
const ILIAS_51 = 51;
const MIN_ILIAS_VERSION = self::ILIAS_44;


/**
* @return int
*/
public static function getILIASVersion() {
if (ilComponent::isVersionGreaterString(ILIAS_VERSION_NUMERIC, '5.0.999')) {
return self::ILIAS_51;
}
if (ilComponent::isVersionGreaterString(ILIAS_VERSION_NUMERIC, '4.9.999')) {
return self::ILIAS_50;
}
if (ilComponent::isVersionGreaterString(ILIAS_VERSION_NUMERIC, '4.3.999')) {
return self::ILIAS_44;
}

return 0;
}


/**
* @return bool
*/
public static function isILIASSupported() {
return self::getILIASVersion() >= self::MIN_ILIAS_VERSION;
}


/**
* @return bool
*/
public static function is44() {
return self::getILIASVersion() >= self::ILIAS_44;
}


/**
* @return bool
*/
public static function is50() {
return self::getILIASVersion() >= self::ILIAS_50;
}


/**
* @return bool
*/
public static function isGlobalCacheActive() {
static $has_global_cache;
if (!isset($has_global_cache)) {
$has_global_cache = ilCtrlMainMenuConfig::get('activate_cache') AND self::hasGlobalCache();
}

return $has_global_cache;
}


/**
* @return bool
*/
public static function hasGlobalCache() {
return is_file('./Services/GlobalCache/classes/class.ilGlobalCache.php');
}
}

?>
78 changes: 78 additions & 0 deletions classes/Display/class.xlvoBarGUI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

/**
* Class xlvoBarGUI
*
* @author Fabian Schmid <[email protected]>
* @version 1.0.0
* @ilCtrl_IsCalledBy xlvoBarGUI: ilObjLiveVotingGUI
*/
class xlvoBarGUI {

/**
* @var ilTemplate
*/
protected $tpl;
/**
* @var ilLiveVotingOption
*/
protected $ilLiveVotingOption;
/**
* @var ilObjLiveVoting
*/
protected $ilObjLiveVoting;


/**
* @param ilObjLiveVoting $ilObjLiveVoting
* @param ilLiveVotingOption $ilLiveVotingOption
*/
public function __construct(ilObjLiveVoting $ilObjLiveVoting, ilLiveVotingOption $ilLiveVotingOption) {
global $tpl;
/**
* @var $tpl ilTemplate
*/
$tpl->addJavaScript('./Customizing/global/plugins/Services/Repository/RepositoryObject/LiveVoting/templates/Display/bar.js');

$this->ilObjLiveVoting = $ilObjLiveVoting;
$this->ilLiveVotingOption = $ilLiveVotingOption;
$this->tpl = new ilTemplate('./Customizing/global/plugins/Services/Repository/RepositoryObject/LiveVoting/templates/Display/tpl.bar.html', false, false);
}


protected function render() {
$this->tpl->setVariable('PERCENT', $this->ilObjLiveVoting->getPercentageForOption($this->ilLiveVotingOption->getId()));
$this->tpl->setVariable('ID', $this->ilLiveVotingOption->getId());
$this->tpl->setVariable('CIPHER', $this->ilLiveVotingOption->countVotes());
$this->tpl->setVariable('COUNT', $this->ilLiveVotingOption->countVotes());
$this->tpl->setVariable('AJAX_LINK', $this->ilLiveVotingOption->getId());
}


/**
* @return string
*/
public function getHTML() {
$this->render();

return $this->tpl->get();
}


/**
* @param ilObjLiveVoting $ilObjLiveVoting
*
* @return string
*/
public function getAjaxData(ilObjLiveVoting $ilObjLiveVoting) {
$data = array(
'percentage' => $ilObjLiveVoting->getPercentageForOption($this->ilLiveVotingOption->getId()),
'percentage_relative' => $ilObjLiveVoting->getRelativePercentageForOption($this->ilLiveVotingOption->getId()),
'votes' => $this->ilLiveVotingOption->countVotes(),
);

return json_encode($data);
}
}

?>
94 changes: 94 additions & 0 deletions classes/Display/class.xlvoDisplayGUI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
require_once('class.xlvoBarGUI.php');

/**
* Class xlvoDisplayGUI
*
* @author Fabian Schmid <[email protected]>
* @version 1.0.0
*/
class xlvoDisplayGUI {

/**
* @var int
*/
protected $answer_count = 64;
/**
* @var ilTemplate
*/
protected $tpl;
/**
* @var ilObjLiveVoting
*/
protected $ilObjLiveVoting;


/**
* @param ilObjLiveVoting $ilObjLiveVoting
*/
public function __construct(ilObjLiveVoting $ilObjLiveVoting) {
global $tpl;
/**
* @var $tpl ilTemplate
*/
$tpl->addCss('./Customizing/global/plugins/Services/Repository/RepositoryObject/LiveVoting/templates/bs.css');
$this->ilObjLiveVoting = $ilObjLiveVoting;
$this->tpl = new ilTemplate('./Customizing/global/plugins/Services/Repository/RepositoryObject/LiveVoting/templates/Display/tpl.display.html', false, true);
}


protected function render() {
$this->tpl->setVariable('TITLE', $this->ilObjLiveVoting->getTitle());
$this->tpl->setVariable('QUESTION', $this->ilObjLiveVoting->getQuestion());
$this->tpl->setVariable('PIN', $this->ilObjLiveVoting->getPin());
// $this->tpl->setVariable('ID', $this->ilObjLiveVoting->getId());
foreach ($this->ilObjLiveVoting->getOptions() as $option) {
if ($option instanceof ilLiveVotingOption) {
$this->addAnswer($option);
$this->addBar(new xlvoBarGUI($this->ilObjLiveVoting, $option));
}
}
}


/**
* @param ilLiveVotingOption $ilLiveVotingOption
*/
protected function addAnswer(ilLiveVotingOption $ilLiveVotingOption) {
$this->answer_count ++;
$this->tpl->setCurrentBlock('answer');
$this->tpl->setVariable('ANSWER_LETTER', (chr($this->answer_count)));
$this->tpl->setVariable('ANSWER_TEXT', $ilLiveVotingOption->getTitle());
$this->tpl->parseCurrentBlock();
}


/**
* @param xlvoBarGUI $xlvoBarGUI
*/
public function addBar(xlvoBarGUI $xlvoBarGUI) {
$this->tpl->setCurrentBlock('bar');
$this->tpl->setVariable('BAR', $xlvoBarGUI->getHTML());
$this->tpl->parseCurrentBlock();
}


/**
* @param $url
*/
public function addQRCode($url) {
$this->tpl->setVariable('QR', '<img src="http://www.reichmann-racing.de/wp-content/download/qrcode.png" width="100%" height="100%">');
}


/**
* @return string
*/
public function getHTML() {
$this->render();

return $this->tpl->get();
}
}

?>
21 changes: 18 additions & 3 deletions classes/class.ilMultipleTextInputGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */

include_once("./Services/Form/classes/class.ilCustomInputGUI.php");

require_once('./Customizing/global/plugins/Services/Repository/RepositoryObject/LiveVoting/classes/Config/class.xlvoConfig.php');
/**
* Class ilMultipleTextInputGUI
*
Expand Down Expand Up @@ -42,10 +42,25 @@ public function getHtml() {
private function buildHTML() {
$pl = ilLiveVotingPlugin::getInstance();
$tpl = $pl->getTemplate("tpl.multiple_input.html");

// if (xlvoConfig::is50()) {
// $tpl = $pl->getTemplate("tpl.multiple_input.html");
// } else {
// $tpl = $pl->getTemplate("tpl.multiple_input_50.html");
// }
//
$tpl->setCurrentBlock("title");
// $tpl->setVariable("CSS_PATH", $pl->getStyleSheetLocation("content.css"));
$tpl->setVariable("X_IMAGE_PATH", $pl->getImagePath("x_image.png"));

if (xlvoConfig::is50()) {
// ilUtil::sendInfo(ilGlyphGUI::get(ilGlyphGUI::ADD));
// $ilGlyphGUI = new ilGlyphGUI();


$tpl->setVariable("X_IMAGE_PATH", $pl->getImagePath("x_image.png"));
} else {
$tpl->setVariable("X_IMAGE_PATH", $pl->getImagePath("x_image.png"));
}

$tpl->setVariable("PLACEHOLDER", $this->placeholder);
$tpl->setVariable("POSTVAR", $this->getPostVar());
$tpl->parseCurrentBlock();
Expand Down
Loading

0 comments on commit c7a723c

Please sign in to comment.