complete survey for teachers

parent c5933dbd
...@@ -32,6 +32,7 @@ return [ ...@@ -32,6 +32,7 @@ return [
['/application-form', ['school'], ['get', 'post'], 'GrEduLabs\ApplicationForm\Acl\Assertion\CanSubmit'], ['/application-form', ['school'], ['get', 'post'], 'GrEduLabs\ApplicationForm\Acl\Assertion\CanSubmit'],
['/application-form/submit-success', ['school'], ['get']], ['/application-form/submit-success', ['school'], ['get']],
['/tpe_survey', ['school'], ['get', 'post']], ['/tpe_survey', ['school'], ['get', 'post']],
['/tpe_survey/total-teachers', ['school'], ['post']],
], ],
], ],
], ],
......
data/db/er.png

191 KB | W: | H:

data/db/er.png

228 KB | W: | H:

data/db/er.png
data/db/er.png
data/db/er.png
data/db/er.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -278,7 +278,7 @@ CREATE TABLE `lesson` ( ...@@ -278,7 +278,7 @@ CREATE TABLE `lesson` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
...@@ -287,7 +287,7 @@ CREATE TABLE `lesson` ( ...@@ -287,7 +287,7 @@ CREATE TABLE `lesson` (
LOCK TABLES `lesson` WRITE; LOCK TABLES `lesson` WRITE;
/*!40000 ALTER TABLE `lesson` DISABLE KEYS */; /*!40000 ALTER TABLE `lesson` DISABLE KEYS */;
INSERT INTO `lesson` VALUES (1,'ΠΛΗΡΟΦΟΡΙΚΗ'),(2,'ΦΥΣΙΚΗ'); INSERT INTO `lesson` VALUES (1,'ΠΛΗΡΟΦΟΡΙΚΗ'),(2,'ΦΥΣΙΚΩΝ ΕΠΙΣΤΗΜΩΝ'),(3,'ΤΕΧΝΟΛΟΓΙΑΣ'),(4,'ΦΙΛΟΛΟΓΙΚΑ'),(5,'ΑΙΣΘΗΤΙΚΗ ΑΓΩΓΗ'),(6,'ΕΘΝΙΚΑ Ή ΕΥΡΩΠΑΪΚΑ ΕΚΠΑΙΔΕΥΤΙΚΑ ΠΡΟΓΡΑΜΜΑΤΑ'),(7,'ΔΡΑΣΤΗΡΙΟΤΗΤΕΣ ΕΚΤΟΣ ΩΡΑΡΙΟΥ ΛΕΙΤΟΥΡΓΙΑΣ ΣΧΟΛΕΙΟΥ'),(8,'ΜΑΘΗΜΑΤΑ ΕΙΔΙΚΟΤΗΤΑΣ (ΕΠΑΛ)');
/*!40000 ALTER TABLE `lesson` ENABLE KEYS */; /*!40000 ALTER TABLE `lesson` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;
...@@ -345,6 +345,9 @@ UNLOCK TABLES; ...@@ -345,6 +345,9 @@ UNLOCK TABLES;
-- Table structure for table `school` -- Table structure for table `school`
-- --
DROP TABLE IF EXISTS `school`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
DROP TABLE IF EXISTS `school`; DROP TABLE IF EXISTS `school`;
/*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */; /*!40101 SET character_set_client = utf8 */;
...@@ -352,7 +355,7 @@ CREATE TABLE `school` ( ...@@ -352,7 +355,7 @@ CREATE TABLE `school` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`street_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `street_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`postal_code` int(11) unsigned DEFAULT NULL, `postal_code` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`phone_number` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `phone_number` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`fax_number` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `fax_number` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
...@@ -364,16 +367,17 @@ CREATE TABLE `school` ( ...@@ -364,16 +367,17 @@ CREATE TABLE `school` (
`created` int(11) unsigned NOT NULL, `created` int(11) unsigned NOT NULL,
`creator` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `creator` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`registry_no` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, `registry_no` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`teachers_count` int(11) unsigned DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `registry_no_UNIQUE` (`registry_no`), UNIQUE KEY `registry_no_UNIQUE` (`registry_no`),
KEY `index_foreignkey_school_schooltype` (`schooltype_id`), KEY `index_foreignkey_school_schooltype` (`schooltype_id`),
KEY `index_foreignkey_school_prefecture` (`prefecture_id`), KEY `index_foreignkey_school_prefecture` (`prefecture_id`),
KEY `index_foreignkey_school_educationlevel` (`educationlevel_id`), KEY `index_foreignkey_school_educationlevel` (`educationlevel_id`),
KEY `index_foreignkey_school_eduadmin` (`eduadmin_id`), KEY `index_foreignkey_school_eduadmin` (`eduadmin_id`),
CONSTRAINT `c_fk_school_schooltype_id` FOREIGN KEY (`schooltype_id`) REFERENCES `schooltype` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT `c_fk_school_eduadmin_id` FOREIGN KEY (`eduadmin_id`) REFERENCES `eduadmin` (`id`) ON UPDATE CASCADE,
CONSTRAINT `c_fk_school_prefecture_id` FOREIGN KEY (`prefecture_id`) REFERENCES `prefecture` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT `c_fk_school_educationlevel_id` FOREIGN KEY (`educationlevel_id`) REFERENCES `educationlevel` (`id`) ON UPDATE CASCADE,
CONSTRAINT `c_fk_school_educationlevel_id` FOREIGN KEY (`educationlevel_id`) REFERENCES `educationlevel` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT `c_fk_school_prefecture_id` FOREIGN KEY (`prefecture_id`) REFERENCES `prefecture` (`id`) ON UPDATE CASCADE,
CONSTRAINT `c_fk_school_eduadmin_id` FOREIGN KEY (`eduadmin_id`) REFERENCES `eduadmin` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE CONSTRAINT `c_fk_school_schooltype_id` FOREIGN KEY (`schooltype_id`) REFERENCES `schooltype` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
...@@ -574,6 +578,44 @@ LOCK TABLES `software` WRITE; ...@@ -574,6 +578,44 @@ LOCK TABLES `software` WRITE;
/*!40000 ALTER TABLE `software` ENABLE KEYS */; /*!40000 ALTER TABLE `software` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;
--
-- Table structure for table `tpesurvey`
--
DROP TABLE IF EXISTS `tpesurvey`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tpesurvey` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`teacher_id` int(11) unsigned NOT NULL,
`already_using_tpe` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`knowledge_level` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`assets_in_use` text COLLATE utf8mb4_unicode_ci,
`sw_web2` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`sw_packages` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`sw_digitalschool` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`sw_other` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`uc_eduprograms` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`uc_digitaldesign` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`uc_asyncedu` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`uc_other` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`extra_needs` text COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
UNIQUE KEY `teacher_id_UNIQUE` (`teacher_id`),
KEY `index_foreignkey_tpesurvey_teacher` (`teacher_id`),
CONSTRAINT `c_fk_tpesurvey_teacher_id` FOREIGN KEY (`teacher_id`) REFERENCES `teacher` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tpesurvey`
--
LOCK TABLES `tpesurvey` WRITE;
/*!40000 ALTER TABLE `tpesurvey` DISABLE KEYS */;
/*!40000 ALTER TABLE `tpesurvey` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
......
...@@ -215,7 +215,7 @@ CREATE TABLE `lesson` ( ...@@ -215,7 +215,7 @@ CREATE TABLE `lesson` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
...@@ -224,7 +224,7 @@ CREATE TABLE `lesson` ( ...@@ -224,7 +224,7 @@ CREATE TABLE `lesson` (
LOCK TABLES `lesson` WRITE; LOCK TABLES `lesson` WRITE;
/*!40000 ALTER TABLE `lesson` DISABLE KEYS */; /*!40000 ALTER TABLE `lesson` DISABLE KEYS */;
INSERT INTO `lesson` VALUES (1,'ΠΛΗΡΟΦΟΡΙΚΗ'),(2,'ΦΥΣΙΚΗ'); INSERT INTO `lesson` VALUES (1,'ΠΛΗΡΟΦΟΡΙΚΗ'),(2,'ΦΥΣΙΚΩΝ ΕΠΙΣΤΗΜΩΝ'),(3,'ΤΕΧΝΟΛΟΓΙΑΣ'),(4,'ΦΙΛΟΛΟΓΙΚΑ'),(5,'ΑΙΣΘΗΤΙΚΗ ΑΓΩΓΗ'),(6,'ΕΘΝΙΚΑ Ή ΕΥΡΩΠΑΪΚΑ ΕΚΠΑΙΔΕΥΤΙΚΑ ΠΡΟΓΡΑΜΜΑΤΑ'),(7,'ΔΡΑΣΤΗΡΙΟΤΗΤΕΣ ΕΚΤΟΣ ΩΡΑΡΙΟΥ ΛΕΙΤΟΥΡΓΙΑΣ ΣΧΟΛΕΙΟΥ'),(8,'ΜΑΘΗΜΑΤΑ ΕΙΔΙΚΟΤΗΤΑΣ (ΕΠΑΛ)');
/*!40000 ALTER TABLE `lesson` ENABLE KEYS */; /*!40000 ALTER TABLE `lesson` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;
...@@ -289,7 +289,7 @@ CREATE TABLE `school` ( ...@@ -289,7 +289,7 @@ CREATE TABLE `school` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`street_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `street_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`postal_code` int(11) unsigned DEFAULT NULL, `postal_code` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`phone_number` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `phone_number` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`fax_number` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `fax_number` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
...@@ -307,10 +307,10 @@ CREATE TABLE `school` ( ...@@ -307,10 +307,10 @@ CREATE TABLE `school` (
KEY `index_foreignkey_school_prefecture` (`prefecture_id`), KEY `index_foreignkey_school_prefecture` (`prefecture_id`),
KEY `index_foreignkey_school_educationlevel` (`educationlevel_id`), KEY `index_foreignkey_school_educationlevel` (`educationlevel_id`),
KEY `index_foreignkey_school_eduadmin` (`eduadmin_id`), KEY `index_foreignkey_school_eduadmin` (`eduadmin_id`),
CONSTRAINT `c_fk_school_schooltype_id` FOREIGN KEY (`schooltype_id`) REFERENCES `schooltype` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT `c_fk_school_eduadmin_id` FOREIGN KEY (`eduadmin_id`) REFERENCES `eduadmin` (`id`) ON UPDATE CASCADE,
CONSTRAINT `c_fk_school_prefecture_id` FOREIGN KEY (`prefecture_id`) REFERENCES `prefecture` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT `c_fk_school_educationlevel_id` FOREIGN KEY (`educationlevel_id`) REFERENCES `educationlevel` (`id`) ON UPDATE CASCADE,
CONSTRAINT `c_fk_school_educationlevel_id` FOREIGN KEY (`educationlevel_id`) REFERENCES `educationlevel` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT `c_fk_school_prefecture_id` FOREIGN KEY (`prefecture_id`) REFERENCES `prefecture` (`id`) ON UPDATE CASCADE,
CONSTRAINT `c_fk_school_eduadmin_id` FOREIGN KEY (`eduadmin_id`) REFERENCES `eduadmin` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE CONSTRAINT `c_fk_school_schooltype_id` FOREIGN KEY (`schooltype_id`) REFERENCES `schooltype` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
......
<?php <?php
use GrEduLabs\Schools\Middleware\FetchSchoolFromIdentity;
use GrEduLabs\Schools\Service\StaffServiceInterface;
use GrEduLabs\TpeSurvey\Action\SubmitTeachersCount;
use GrEduLabs\TpeSurvey\Action\SurveyForm; use GrEduLabs\TpeSurvey\Action\SurveyForm;
use GrEduLabs\TpeSurvey\InputFilter\Survey;
use GrEduLabs\TpeSurvey\Middleware\SurveyFormDefaults; use GrEduLabs\TpeSurvey\Middleware\SurveyFormDefaults;
use GrEduLabs\TpeSurvey\Service\SurveyService; use GrEduLabs\TpeSurvey\Service\SurveyService;
use GrEduLabs\TpeSurvey\Service\SurveyServiceInterface; use GrEduLabs\TpeSurvey\Service\SurveyServiceInterface;
...@@ -35,7 +39,21 @@ return function (App $app) { ...@@ -35,7 +39,21 @@ return function (App $app) {
}; };
$c[SurveyForm::class] = function ($c) { $c[SurveyForm::class] = function ($c) {
return new SurveyForm($c->get(SurveyServiceInterface::class)); return new SurveyForm(
$c->get(SurveyServiceInterface::class),
$c->get(Survey::class),
$c->get(StaffServiceInterface::class)
);
};
$c[SubmitTeachersCount::class] = function ($c) {
return new SubmitTeachersCount(
$c->get(SurveyServiceInterface::class)
);
};
$c[Survey::class] = function ($c) {
return new Survey();
}; };
}); });
...@@ -44,7 +62,8 @@ return function (App $app) { ...@@ -44,7 +62,8 @@ return function (App $app) {
$app->group('/tpe_survey', function () { $app->group('/tpe_survey', function () {
$this->map(['GET', 'POST'], '', SurveyForm::class)->setName('tpe_survey'); $this->map(['GET', 'POST'], '', SurveyForm::class)->setName('tpe_survey');
}); $this->post('/total-teachers', SubmitTeachersCount::class)->setName('tpe_survey.total_teachers');
})->add(FetchSchoolFromIdentity::class);
}); });
$events('on', 'app.bootstrap', function (App $app, Container $c) { $events('on', 'app.bootstrap', function (App $app, Container $c) {
......
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `tpesurvey`
--
DROP TABLE IF EXISTS `tpesurvey`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tpesurvey` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`teacher_id` int(11) unsigned NOT NULL,
`already_using_tpe` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`knowledge_level` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`assets_in_use` text COLLATE utf8mb4_unicode_ci,
`sw_web2` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`sw_packages` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`sw_digitalschool` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`sw_other` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`uc_eduprograms` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`uc_digitaldesign` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`uc_asyncedu` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`uc_other` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`extra_needs` text COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
UNIQUE KEY `teacher_id_UNIQUE` (`teacher_id`),
KEY `index_foreignkey_tpesurvey_teacher` (`teacher_id`),
CONSTRAINT `c_fk_tpesurvey_teacher_id` FOREIGN KEY (`teacher_id`) REFERENCES `teacher` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tpesurvey`
--
LOCK TABLES `tpesurvey` WRITE;
/*!40000 ALTER TABLE `tpesurvey` DISABLE KEYS */;
/*!40000 ALTER TABLE `tpesurvey` ENABLE KEYS */;
UNLOCK TABLES;
ALTER TABLE `school`
ADD COLUMN `teachers_count` INT(11) UNSIGNED NULL DEFAULT NULL AFTER `registry_no`;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
...@@ -86,7 +86,14 @@ ...@@ -86,7 +86,14 @@
}).done(function (response) { }).done(function (response) {
that.hide(); that.hide();
}).fail(function (xhr, err) { }).fail(function (xhr, err) {
alert('Προέκυψε κάποιο σφάλμα'); var messages;
if (422 === xhr.status) {
messages = JSON.parse(xhr.responseText).messages || {};
utils.formMessages.render(form, messages);
} else {
alert('Προέκυψε κάποιο σφάλμα');
}
}); });
return false; return false;
...@@ -109,4 +116,24 @@ ...@@ -109,4 +116,24 @@
modal.render(); modal.render();
}); });
$('#form-total-teachers').on('submit', function (evt) {
var that = $(this);
$.ajax({
url: that.attr('action'),
type: 'post',
dataType: 'json',
data: utils.serializeObject(that)
}).fail(function (xhr, err) {
var messages;
if (422 === xhr.status) {
messages = JSON.parse(xhr.responseText).messages || {};
utils.formMessages.render(that, messages);
} else {
alert('Προέκυψε κάποιο σφάλμα');
}
});
evt.preventDefault();
});
}(jQuery, _, window.EDULABS.utils)); }(jQuery, _, window.EDULABS.utils));
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace GrEduLabs\TpeSurvey\Action;
use GrEduLabs\TpeSurvey\Service\SurveyServiceInterface;
use Slim\Http\Request;
use Slim\Http\Response;
/**
* Description of SubmitTeachersCount
*
* @author kanellov
*/
class SubmitTeachersCount
{
/**
*
* @var SurveyServiceInterface
*/
private $service;
public function __construct(SurveyServiceInterface $service)
{
$this->service = $service;
}
public function __invoke(Request $req, Response $res)
{
$school = $req->getAttribute('school', false);
if (!$school) {
return $res->withStatus(403, 'No school');
}
$this->service->setTotalTeachers($school->id, (int) $req->getParam('total_teachers', 0));
return $res->withStatus(204);
}
}
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
namespace GrEduLabs\TpeSurvey\Action; namespace GrEduLabs\TpeSurvey\Action;
use GrEduLabs\Schools\Service\StaffService;
use GrEduLabs\Schools\Service\StaffServiceInterface;
use GrEduLabs\TpeSurvey\Service\SurveyServiceInterface; use GrEduLabs\TpeSurvey\Service\SurveyServiceInterface;
use Slim\Http\Request; use Slim\Http\Request;
use Slim\Http\Response; use Slim\Http\Response;
...@@ -23,16 +25,50 @@ class SurveyForm ...@@ -23,16 +25,50 @@ class SurveyForm
*/ */
private $service; private $service;
public function __construct(SurveyServiceInterface $service) /**
{ *
$this->service = $service; * @var callable
*/
private $inputFilter;
/**
*
* @var StaffService
*/
private $staffService;
public function __construct(
SurveyServiceInterface $service,
callable $inputFilter,
StaffServiceInterface $staffService
) {
$this->service = $service;
$this->inputFilter = $inputFilter;
$this->staffService = $staffService;
} }
public function __invoke(Request $req, Response $res) public function __invoke(Request $req, Response $res)
{ {
$school = $req->getAttribute('school', false);
if (!$school) {
return $res->withStatus(403, 'No school');
}
$teacherId = $req->getParam('teacher_id'); $teacherId = $req->getParam('teacher_id');
$teacher = $this->staffService->getTeacherById($teacherId);
if ($teacher['school_id'] !== $school->id) {
return $res->withStatus(403, 'No school');
}
if ($req->isPost()) { if ($req->isPost()) {
$this->service->saveAnswers($teacherId, $req->getParams()); $inputFilter = $this->inputFilter;
$result = $inputFilter($req->getParams());
if (!$result['is_valid']) {
$res = $res->withStatus(422);
$res = $res->withJson($result);
return $res;
}
$this->service->saveAnswers($teacherId, $result['values']);
} }
$data = $this->service->getAnswers($teacherId); $data = $this->service->getAnswers($teacherId);
$res = $res->withJson($data); $res = $res->withJson($data);
......
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace GrEduLabs\TpeSurvey\InputFilter;
use GrEduLabs\Schools\InputFilter\InputFilterTrait;
use Zend\Filter;
use Zend\InputFilter\Input;
use Zend\InputFilter\InputFilter;
use Zend\Validator;
class Survey
{
use InputFilterTrait;
public function __construct()
{
$id = new Input('id');
$id->setRequired(false)
->getValidatorChain()
->attach(new Validator\Digits());
$alreadyUsing_tpe = new Input('already_using_tpe');
$alreadyUsing_tpe->setRequired(true)
->getFilterChain()
->attach(new Filter\StripTags())
->attach(new Filter\StringTrim());
$alreadyUsing_tpe->getValidatorChain()
->attach(new Validator\NotEmpty());
$knowledgeLevel = new Input('knowledge_level');
$knowledgeLevel->setRequired(true)
->getFilterChain()
->attach(new Filter\StripTags())
->attach(new Filter\StringTrim());
$knowledgeLevel->getValidatorChain()
->attach(new Validator\NotEmpty());
$assetsInUse = new Input('assets_in_use');
$assetsInUse->setRequired(false)
->getFilterChain()
->attach(new Filter\StripTags())
->attach(new Filter\StringTrim());
$swWeb2 = new Input('sw_web2');
$swWeb2->setRequired(false)
->getFilterChain()
->attach(new Filter\StripTags())
->attach(new Filter\StringTrim());
$swWeb2->getValidatorChain()
->attach(new Validator\StringLength([
'max' => '191',
]));
$swPackages = new Input('sw_packages');
$swPackages->setRequired(false)
->getFilterChain()
->attach(new Filter\StripTags())
->attach(new Filter\StringTrim());
$swPackages->getValidatorChain()
->attach(new Validator\StringLength([
'max' => '191',
]));
$swDigitalschool = new Input('sw_digitalschool');
$swDigitalschool->setRequired(false)
->getFilterChain()
->attach(new Filter\StripTags())
->attach(new Filter\StringTrim());
$swDigitalschool->getValidatorChain()
->attach(new Validator\StringLength([
'max' => '191',
]));
$swOther = new Input('sw_other');
$swOther->setRequired(false)
->getFilterChain()
->attach(new Filter\StripTags())
->attach(new Filter\StringTrim());
$swOther->getValidatorChain()
->attach(new Validator\StringLength([
'max' => '191',
]));
$ucEduprograms = new Input('uc_eduprograms');
$ucEduprograms->setRequired(false)
->getFilterChain()
->attach(new Filter\StripTags())
->attach(new Filter\StringTrim());
$ucEduprograms->getValidatorChain()
->attach(new Validator\StringLength([
'max' => '191',
]));
$ucDigitaldesign = new Input('uc_digitaldesign');
$ucDigitaldesign->setRequired(false)
->getFilterChain()
->attach(new Filter\StripTags())
->attach(new Filter\StringTrim());
$ucDigitaldesign->getValidatorChain()
->attach(new Validator\StringLength([
'max' => '191',
]));
$ucAsyncedu = new Input('uc_asyncedu');
$ucAsyncedu->setRequired(false)
->getFilterChain()
->attach(new Filter\StripTags())
->attach(new Filter\StringTrim());
$ucAsyncedu->getValidatorChain()
->attach(new Validator\StringLength([
'max' => '191',
]));
$ucOther = new Input('uc_other');
$ucOther->setRequired(false)
->getFilterChain()
->attach(new Filter\StripTags())
->attach(new Filter\StringTrim());
$ucOther->getValidatorChain()
->attach(new Validator\StringLength([
'max' => '191',
]));
$extraNeeds = new Input('extra_needs');
$extraNeeds->setRequired(false)
->getFilterChain()
->attach(new Filter\StripTags())
->attach(new Filter\StringTrim());
$extraNeeds->getValidatorChain()
->attach(new Validator\StringLength([
'max' => '191',
]));
$this->inputFilter = new InputFilter();
$this->inputFilter
->add($id)
->add($alreadyUsing_tpe)
->add($knowledgeLevel)
->add($assetsInUse)
->add($swWeb2)
->add($swPackages)
->add($swDigitalschool)
->add($swOther)
->add($ucEduprograms)