complete survey for teachers

parent c5933dbd
......@@ -32,6 +32,7 @@ return [
['/application-form', ['school'], ['get', 'post'], 'GrEduLabs\ApplicationForm\Acl\Assertion\CanSubmit'],
['/application-form/submit-success', ['school'], ['get']],
['/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` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
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 */;
--
......@@ -287,7 +287,7 @@ CREATE TABLE `lesson` (
LOCK TABLES `lesson` WRITE;
/*!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 */;
UNLOCK TABLES;
......@@ -345,6 +345,9 @@ UNLOCK TABLES;
-- 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`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
......@@ -352,7 +355,7 @@ CREATE TABLE `school` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT 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,
`fax_number` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
......@@ -364,16 +367,17 @@ CREATE TABLE `school` (
`created` int(11) unsigned NOT NULL,
`creator` varchar(255) 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`),
UNIQUE KEY `registry_no_UNIQUE` (`registry_no`),
KEY `index_foreignkey_school_schooltype` (`schooltype_id`),
KEY `index_foreignkey_school_prefecture` (`prefecture_id`),
KEY `index_foreignkey_school_educationlevel` (`educationlevel_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_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 DELETE RESTRICT 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_eduadmin_id` FOREIGN KEY (`eduadmin_id`) REFERENCES `eduadmin` (`id`) ON UPDATE CASCADE,
CONSTRAINT `c_fk_school_educationlevel_id` FOREIGN KEY (`educationlevel_id`) REFERENCES `educationlevel` (`id`) ON UPDATE CASCADE,
CONSTRAINT `c_fk_school_prefecture_id` FOREIGN KEY (`prefecture_id`) REFERENCES `prefecture` (`id`) 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;
/*!40101 SET character_set_client = @saved_cs_client */;
......@@ -574,6 +578,44 @@ LOCK TABLES `software` WRITE;
/*!40000 ALTER TABLE `software` ENABLE KEYS */;
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 */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
......
......@@ -215,7 +215,7 @@ CREATE TABLE `lesson` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
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 */;
--
......@@ -224,7 +224,7 @@ CREATE TABLE `lesson` (
LOCK TABLES `lesson` WRITE;
/*!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 */;
UNLOCK TABLES;
......@@ -289,7 +289,7 @@ CREATE TABLE `school` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT 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,
`fax_number` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
......@@ -307,10 +307,10 @@ CREATE TABLE `school` (
KEY `index_foreignkey_school_prefecture` (`prefecture_id`),
KEY `index_foreignkey_school_educationlevel` (`educationlevel_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_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 DELETE RESTRICT 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_eduadmin_id` FOREIGN KEY (`eduadmin_id`) REFERENCES `eduadmin` (`id`) ON UPDATE CASCADE,
CONSTRAINT `c_fk_school_educationlevel_id` FOREIGN KEY (`educationlevel_id`) REFERENCES `educationlevel` (`id`) ON UPDATE CASCADE,
CONSTRAINT `c_fk_school_prefecture_id` FOREIGN KEY (`prefecture_id`) REFERENCES `prefecture` (`id`) 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;
/*!40101 SET character_set_client = @saved_cs_client */;
......
<?php
use GrEduLabs\Schools\Middleware\FetchSchoolFromIdentity;
use GrEduLabs\Schools\Service\StaffServiceInterface;
use GrEduLabs\TpeSurvey\Action\SubmitTeachersCount;
use GrEduLabs\TpeSurvey\Action\SurveyForm;
use GrEduLabs\TpeSurvey\InputFilter\Survey;
use GrEduLabs\TpeSurvey\Middleware\SurveyFormDefaults;
use GrEduLabs\TpeSurvey\Service\SurveyService;
use GrEduLabs\TpeSurvey\Service\SurveyServiceInterface;
......@@ -35,7 +39,21 @@ return function (App $app) {
};
$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) {
$app->group('/tpe_survey', function () {
$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) {
......
/*!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 @@
}).done(function (response) {
that.hide();
}).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;
......@@ -109,4 +116,24 @@
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));
<?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 @@
namespace GrEduLabs\TpeSurvey\Action;
use GrEduLabs\Schools\Service\StaffService;
use GrEduLabs\Schools\Service\StaffServiceInterface;
use GrEduLabs\TpeSurvey\Service\SurveyServiceInterface;
use Slim\Http\Request;
use Slim\Http\Response;
......@@ -23,16 +25,50 @@ class SurveyForm
*/
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)
{
$school = $req->getAttribute('school', false);
if (!$school) {
return $res->withStatus(403, 'No school');
}
$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()) {
$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);
$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)
->add($ucDigitaldesign)
->add($ucAsyncedu)
->add($ucOther)
->add($extraNeeds);
}
}
......@@ -17,6 +17,16 @@ use Slim\Views\Twig;
class SurveyFormDefaults
{
private static $alreadyUsingTpe = [
[
'value' => 'ΝΑΙ',
'label' => 'Ναι',
],
[
'value' => 'ΟΧΙ',
'label' => 'Όχι, αλλά θα χρησιμοποιούσε αν είχε τα κατάλληλα εργαλεία',
],
];
private static $knowledgeLevels = ['ΜΕΤΡΙΑ', 'ΚΑΛΑ', 'ΠΟΛΥ ΚΑΛΑ', 'ΑΡΙΣΤΑ'];
private static $assetsInUse = ['Η/Υ', 'TABLET', 'ΔΣΔ (Διαδραστικό Σύστημα Διδασκαλίας)', 'ΒΙΝΤΕΟΠΡΟΒΟΛΕΑΣ', 'ΚΙΤ ΡΟΜΠΟΤΙΚΗΣ'];
private static $softwareInUse = [
......@@ -74,10 +84,11 @@ class SurveyFormDefaults
if ($req->isGet()) {
$this->view['tpe_survey'] = [
'knowledge_levels' => array_map($map, self::$knowledgeLevels),
'assets_in_use' => array_map($map, self::$assetsInUse),
'software_in_use' => self::$softwareInUse,
'use_case' => self::$useCase,
'already_using_tpe' => self::$alreadyUsingTpe,
'knowledge_levels' => array_map($map, self::$knowledgeLevels),
'assets_in_use' => array_map($map, self::$assetsInUse),
'software_in_use' => self::$softwareInUse,
'use_case' => self::$useCase,
];
}
......
......@@ -20,13 +20,16 @@ class SurveyService implements SurveyServiceInterface
$bean = R::findOne('tpesurvey', 'teacher_id = ?', [$teacherId]);
$data = $bean->export();
$data['assets_in_use'] = explode('|', $data['assets_in_use']);
if (!$data['assets_in_use']) {
$data['assets_in_use'] = [];
}
return $data;
}
public function saveAnswers($teacherId, array $data)
{
if (isset($data['assets_in_use'])) {
if (isset($data['assets_in_use']) && is_array($data['assets_in_use'])) {
$data['assets_in_use'] = implode('|', $data['assets_in_use']);
}
$bean = R::findOne('tpesurvey', 'teacher_id = ?', [$teacherId]);
......@@ -35,6 +38,7 @@ class SurveyService implements SurveyServiceInterface
}
$bean->teacher_id = (int) $teacherId;
$bean->import($data, [
'already_using_tpe',
'knowledge_level',
'assets_in_use',
'sw_web2',
......@@ -45,7 +49,15 @@ class SurveyService implements SurveyServiceInterface
'uc_digitaldesign',
'uc_asyncedu',
'uc_other',
'extra_needs',
]);
R::store($bean);
}
public function setTotalTeachers($school_id, $teachersCount)
{
$school = R::load('school', $school_id);
$school->teachers_count = (int) $teachersCount;
R::store($school);
}
}
......@@ -26,4 +26,11 @@ interface SurveyServiceInterface
* @param array $data
*/
public function saveAnswers($teacherId, array $data);
/**
*
* @param int $school_id
* @param int $teachersCount
*/
public function setTotalTeachers($school_id, $teachersCount);
}
......@@ -11,7 +11,8 @@
<h4 class="modal-title"><%= teacher.fullname %>: Χρήση ΤΠΕ </h4>
</div>
<div class="modal-body">
{{ macros.select('knowledge_level', 'Γνώση ΤΠΕ', tpe_survey.knowledge_levels, '', {'required': ''}) }}
{{ macros.select('already_using_tpe', 'Χρησιμοποιεί ήδη ΤΠΕ', tpe_survey.already_using_tpe, '', {'required': ''}) }}
{{ macros.select('knowledge_level', 'Επίπεδο γνώσης ΤΠΕ', tpe_survey.knowledge_levels, '', {'required': ''}) }}
{{ form.multicheckbox('assets_in_use', 'Υλικό που χρησιμοποιεί', tpe_survey.assets_in_use, '', {freeText: true, required: ''}) }}
<div class="form-group">
<label class="control-label hidden-xs hidden-sm col-md-3">Λογισμικό που χρησιμοποιεί</label>
......@@ -31,6 +32,18 @@
{% endfor %}
</div>
</div>
<div class="form-group">
<div class="col-lg-12">
<strong>Περιγράψτε
με σύντομο τρόπο ποια ψηφιακά εργαλεία υλικού ή/και λογισμικού
θα σας ήταν χρήσιμα στην καθημερινή διδακτική σας πρακτική
διδακτική σας πρακτική</strong>
</div>
<label class="sr-only col-md-3"></label>
<div class="col-lg-12">
<textarea name="extra_needs" class="form-control"></textarea>
</div>
</div>
<input type="hidden" name="teacher_id" value="<%= teacher.id %>">
<input type="hidden" name="id" value="">
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment