diff --git a/assets/css/app.scss b/assets/css/app.scss index f955fad8f..b4a73bdb7 100644 --- a/assets/css/app.scss +++ b/assets/css/app.scss @@ -1,3 +1,4 @@ +$body-bg: #ff622b; // customize some Bootstrap variables $primary: darken(#428bca, 20%); diff --git a/public/students.json b/public/students.json new file mode 100644 index 000000000..c06cff4d5 --- /dev/null +++ b/public/students.json @@ -0,0 +1,181 @@ +{ + "team1": { + "name": "Team1", + "mentors": [ + "Mantas" + ], + "students": [ + "Tadas", + "Gytis", + "Ričardas" + ] + }, + "baltichalatai": { + "name": "BaltiChalatai", + "mentors": [ + "Lukas" + ], + "students": [ + "Vytas", + "Lukas", + "Diana" + ] + }, + "nnizer": { + "name": "ePacientas", + "mentors": [ + "Tadas" + ], + "students": [ + "Kornelijus", + "Dominykas", + "Miglė" + ] + }, + "activegen": { + "name": "ActiveGen", + "mentors": [ + "Arnoldas" + ], + "students": [ + "Andrius", + "Nojus", + "Martynas", + "Edvinas" + ] + }, + "mms": { + "name": "Membership-management-system", + "mentors": [ + "Mindaugas" + ], + "students": [ + "Erika", + "Rokas", + "Valentinas", + "Eligijus" + ] + }, + "pamainos": { + "name": "NFQ pamainu sistema", + "mentors": [ + "Paulius" + ], + "students": [ + "Liudas", + "Justina", + "Andrius" + ] + }, + "receptai": { + "name": "Receptai", + "mentors": [ + "Mantas" + ], + "students": [ + "Arnoldas", + "Arentas", + "Tautvydas" + ] + }, + "pulse": { + "name": "NFQ pulse", + "mentors": [ + "Lorenas" + ], + "students": [ + "Arvydas", + "Titas", + "Kristijonas", + "Andrius" + ] + }, + "lita": { + "name": "NFQ Petro atrankos problema akademijai", + "mentors": [ + "Paulius" + ], + "students": [ + "Kristina", + "Indrė", + "Dmitri" + ] + }, + "myfleet": { + "name": "MyFleet", + "mentors": [ + "Laurynas" + ], + "students": [ + "Artūras", + "Ignas", + "Jonas" + ] + }, + "career": { + "name": "NFQ Career Criteria Assessment", + "mentors": [ + "Erikas" + ], + "students": [ + "Matas", + "Andrius", + "Ainis" + ] + }, + "carparking": { + "name": "NFQ Car parking", + "mentors": [ + "Andrejus" + ], + "students": [ + "Kęstas", + "Lukas", + "Lukas" + ] + }, + "podcast": { + "name": "Krepšinio podcastai", + "mentors": [ + "Eligijus" + ], + "students": [ + "Edvardas", + "Nerijus", + "Kazimieras" + ] + }, + "Barakas": { + "name": "barakas", + "mentors": [ + "Armandas" + ], + "students": [ + "Raimondas", + "Mantas", + "Tomas" + ] + }, + "devcollab": { + "name": "Education sharing platform", + "mentors": [ + "Viktoras" + ], + "students": [ + "Karolis", + "Arnas", + "Evaldas", + "Algirdas" + ] + }, + "hacker'is po .mySubdomain &project=123": { + "name": "' OR 1 -- DROP DATABASE", + "mentors": [ + "Ponas Programišius" + ], + "students": [ + "Aurelijus", + "Ir jo \"geras\" draug'as" + ] + } +} \ No newline at end of file diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index 90484f11f..3ae4b419e 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -3,17 +3,35 @@ namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Routing\Annotation\Route; class HomeController extends AbstractController { /** * @Route("/", name="home") + * @param KernelInterface $kernel + * @return \Symfony\Component\HttpFoundation\Response */ - public function index() + public function index(KernelInterface $kernel) { + $projects = json_decode(file_get_contents($kernel->getProjectDir() . '/public/students.json'), true); + + $students = $this->groupByStudents($projects); return $this->render('home/index.html.twig', [ - 'someVariable' => 'NFQ Akademija', + 'someVariable' => $students, + 'projects' => $projects ]); } + + private function groupByStudents(array $projects) + { + $result = []; + foreach ($projects as $projectName => $project) { + foreach ($project['students'] as $student) { + $result[] = ['student' => $student, 'project' => $projectName, 'mentor' => $project['mentors'][0]]; + } + } + return $result; + } } diff --git a/src/Controller/StudentController.php b/src/Controller/StudentController.php new file mode 100644 index 000000000..148dd4f93 --- /dev/null +++ b/src/Controller/StudentController.php @@ -0,0 +1,27 @@ +get('name'); + $project = $request->get('project'); + + return $this->render('student/index.html.twig', [ + 'name' => $name, + 'project' => $project, + ]); + } +} diff --git a/templates/home/index.html.twig b/templates/home/index.html.twig index b1bd0115c..1be8b4aca 100644 --- a/templates/home/index.html.twig +++ b/templates/home/index.html.twig @@ -1,7 +1,59 @@ {% extends 'base.html.twig' %} -{% block title %}{{ someVariable }}{% endblock %} +{% block title %}Student{% endblock %} + + {% block body %} + + +
+
+ +
+ +
+
+ +
+ + +
+
+ + +
+ Duomenų failas +
+ {% endblock %} + + + -{% block body %} -
{{ someVariable }}
-{% endblock %} diff --git a/templates/student/index.html.twig b/templates/student/index.html.twig new file mode 100644 index 000000000..06437e23e --- /dev/null +++ b/templates/student/index.html.twig @@ -0,0 +1,32 @@ +{% extends 'base.html.twig' %} + +{% block body %} +
+ + + + + + + + + + + +
ProjektasStudentas
{{ project|escape }}{{ name|escape }}
+ + {% if name == 'Indrė' %} + + {% else %} + + {% endif %} +
+ +
+ Visi studentai +
+{% endblock %} diff --git a/tests/e2e/cypress/integration/symfony-hw1.js b/tests/e2e/cypress/integration/symfony-hw1.js new file mode 100644 index 000000000..480d7cc79 --- /dev/null +++ b/tests/e2e/cypress/integration/symfony-hw1.js @@ -0,0 +1,141 @@ +const basePath = Cypress.env('BASE_URL') ? Cypress.env('BASE_URL') : 'http://127.0.0.1:8000/'; + +const d = async (message) => { + console.info('D', message); + await cy.ciDebug(message); +}; +const dd = async (message) => { + console.log('DD', message); + await cy.ciLog(message); +}; + +describe('First homework', function() { + it('Have students block', () => { + cy.visit(basePath); + cy.contains("Studentai") + .parent() + .children('.list-group-item:not(.list-group-item-info)') + .then(data => data.map((index, element) => element.innerText).get()) + .then(students => { + cy.wrap(students).each(student => dd(`Student: ${student}`)); + }).then( students => { + assert.equal(students.length, 51, "Expected 51 elements of students"); + }).then( students => { + cy.wrap(students).each(e => { + expect(e).contain("Mentorius"); + }) + }); + + cy.contains("Studentai").parent().screenshot(); + }); + it('Have correct students-mentor data', () => { + cy.visit(basePath); + cy.contains("Studentai") + .parent() + .children('.list-group-item:not(.list-group-item-info)') + .first() + .contains("Tadas") + .parent() + .contains("Mantas"); + }); + + it('Have project block', () => { + cy.visit(basePath); + cy.contains("Projektai").parent().screenshot(); + }); + + it('Have form block', () => { + cy.visit(basePath); + cy.contains("Sužinoti vertinimą").parent().screenshot(); + }); + + it('Whole page', () => { + cy.visit(basePath); + cy.screenshot(); + }); + + it('Click on first student', () => { + cy.visit(basePath); + cy.contains("Studentai") + .parent() + .children('.list-group-item:not(.list-group-item-info)') + .first().children('a').click(); + + d("Expected inner page"); + cy.contains("Studentas"); + cy.contains("Projektas"); + cy.screenshot(); + + cy.contains("Visi studentai").click() + }); + + it('Click on Data file', () => { + cy.visit(basePath); + cy.contains("Duomenų failas").then( a => { + const link = a.attr('href'); + cy.wrap([link]).each(link => dd(`Data file link: ${link}`)) + }).then( links => { + const link = links[0]; + expect(link).to.eq("students.json"); + }) + }); + + it('Have properly escaped student', () => { + cy.visit(basePath); + cy.contains("Studentai") + .parent() + .children() + .last() + .contains(`Ir jo "geras" draug'as`) + .then( element => { + const link = element.get(0).href; + assert( + link.endsWith('?name=%3Cb%3EIr%3C/b%3E%20jo%20%22geras%22%20draug%27as&project=hack%3Cb%3Eer%3C/b%3E%27is%20po%20.mySubdomain%20%26project%3D123'), + 'Expected urlencoded Twig filter' + ); + }) + }); + + it('Have properly escaped Projektai', () => { + cy.visit(basePath); + cy.contains("Projektai") + .parent() + .children() + .last(). + contains(`' OR 1 -- DROP DATABASE`) + .parent() + .contains(`github.com/nfqakademija/hacker'is po .mySubdomain &project=123`) + .parent() + .parent() + .contains(`hacker'is po .mySubdomain &project=123.projektai.nfqakademija.lt/`) + .then( element => { + const link = element.get(0).href; + expect(link).to.eq(`http://hack%3Cb%3Eer%3C%2Fb%3E%27is%20po%20.mysubdomain%20%26project%3D123.projektai.nfqakademija.lt/`); + }) + .parent() + .parent() + .contains(`ssh hacker'is po .mySubdomain &project=123@deploy.nfqakademija.lt -p 2222`) + }); + + it('Have correct person with good evaluation', () => { + cy.visit(basePath); + cy.contains("Studentai") + .parent() + .children('.list-group-item:not(.list-group-item-info)') + .children("a") + .then( elements => { + cy.wrap(elements).each(element => { + let path = element.get(0).href; + cy.visit(path).get('.alert, .success').then( data => { + if (data.get(0).innerText === 'Dešimt balų') { + cy.screenshot(); + cy.wrap([path]).each( path => { + dd(`Įvertinti: ${path}`); + }); + + } + }); + }); + }); + }); +});