Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/img/mastercard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
115 changes: 114 additions & 1 deletion src/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,119 @@
/**
* Class for the exercise.
*/
class TestController extends EUFFetcher {

class TestController extends EUFFetcher
{

public function RetrieveCountries()
{
$json = $this->api->apiGetRequest("getCountries", null);

$array = json_decode($json, true);

return $array['CountryName'];
}

public function RetrieveCountryRecords()
{
$json = $this->api->apiGetRequest("getCountries", null);

$array = json_decode($json, true);

return $array;
}

public function RetrieveUniversities($countryID)
{
$params['CountryID'] = $countryID;

$json = $this->api->apiGetRequest("getInstitutions", $params);

$array = json_decode($json, true);

return array_column($array, 'NameInLatinCharacterSet');
}

private function NationalFlag($cid)
{
$flagmap['2'] = "aw";
$flagmap['1'] = "at";
$flagmap['3'] = "be";
$flagmap['4'] = "bg";
$flagmap['18'] = "hr";
$flagmap['6'] = "cy";
$flagmap['39'] = "cw";
$flagmap['7'] = "cz";
$flagmap['9'] = "dk";
$flagmap['10'] = "ee";
$flagmap['12'] = "fi";
$flagmap['27'] = "mk";
$flagmap['13'] = "fr";
$flagmap['15'] = "gi";
$flagmap['17'] = "gr";
$flagmap['16'] = "gl";
$flagmap['19'] = "hu";
$flagmap['21'] = "is";
$flagmap['20'] = "ir";
$flagmap['22'] = "it";
$flagmap['26'] = "lv";
$flagmap['23'] = "li";
$flagmap['24'] = "lt";
$flagmap['25'] = "lu";
$flagmap['28'] = "mt";
$flagmap['30'] = "nl";
$flagmap['29'] = "nc";
$flagmap['31'] = "no";
$flagmap['32'] = "pl";
$flagmap['33'] = "pt";
$flagmap['34'] = "ro";
$flagmap['40'] = "sb";
$flagmap['37'] = "sk";
$flagmap['36'] = "si";
$flagmap['11'] = "es";
$flagmap['35'] = "se";
$flagmap['5'] = "ch";
$flagmap['38'] = "tr";
$flagmap['14'] = "gb";
$flagmap['8'] = "de";

return $flagmap[$cid] ?? 'xx';
}

public function render()
{
$html = '<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">';

$crecords = $this->RetrieveCountryRecords();

foreach($crecords as $record)
{
$country = $record['CountryName'];
$cid = $record['ID'];
$universities = $this->RetrieveUniversities($cid);
$flag = $this->NationalFlag($cid);

$html .= '<div class="panel panel-default">';
$html .= '<div class="panel-heading" role="tab" id="heading'.$cid.'">';
$html .= '<h4 class="panel-title">';
$html .= '<span class="flag-icon flag-icon-'.$flag.'"></span>';

$html .= '<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse'.$cid.'" aria-expanded="false" aria-controls="collapse'.$cid.'">';
$html .= $country.' ('.count($universities).' Universities)';
$html .= '</a></h4></div>';

foreach($universities as $univ)
{
$html .= '<div id="collapse'.$cid.'" class="panel-collapse collapse " role="tabpanel" aria-labelledby="heading'.$cid.'">';
$html .= '<div class="panel-body">';
$html .= $univ;
$html .='</div></div></div>';
}
}

$html .= '</div>';

return $html;
}

}
24 changes: 20 additions & 4 deletions templates/card.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
<div>
<!-- Your code goes here -->
I want to be a card...
<!-- End of your code -->
<div id="card">
<title>Revolut MasterCard</title>
<img src="./assets/img/mastercard.png" alt="Revolut" />
<footer style="color:darksalmon;">
Sample footer
</footer>
</div>

<script type="text/javascript">
(function() {

var img = document.getElementById('card').firstChild;
img.onload = function() {
if(img.height > img.width) {
img.height = '100%';
img.width = 'auto';
}
};

}());
</script>