This repository has been archived by the owner on Feb 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from studer-raimann/develop
Develop
- Loading branch information
Showing
15 changed files
with
755 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.