Тестовое задание для разработчика
Пусть в г. Санкт-Петербург имеется 5 пунктов выдачи с заданными географическими координатами.
имя | широта | долгота | |
---|---|---|---|
1 | Альдераан | 59.9573 | 30.3485 |
2 | Беспин | 60.0025 | 30.3113 |
3 | Дагоба | 59.9485 | 30.3857 |
4 | Корусант | 59.9894 | 30.2587 |
5 | Мустафар | 59.8836 | 30.3575 |
Требуется создать веб-сервис, который предлагает пользователю ввести его ФИО, телефон и адрес, и по введенному адресу определяет ближайший пункт выдачи и расстояние до него. Пользователю выводится его имя, форматированный телефон и информация о пункте выдачи.
Файлы в архиве:
Toolkit.php
- вспомогательный класс, содержащий метод для форматирования номера телефона, а также метод для опеределения географических координат введенного адреса.CandidateAbstract.php
- абстрактный класс.ajax.php
- файл для AJAX-запроса.
Требуется создать файл Candidate.php
и объявить в нем класс Candidate
, который будет наследовать CandidateAbstract
.
Также требуется создать файл, в котором будет находится форма ввода ФИО, телефона, адреса,
а также кнопка, при нажатии на которую запускается процесс определения ближайшего пункта выдачи.
После успешного выполнения определения ближайшего пункта в div
на странице должен выводится результат в виде
"[ФИО] ([форматированный телефон]): ближайший пункт выдачи [название пункта] находится на расстоянии [расстояние до пункта]км"
Предполагаемая последовательность процессов:
- Пользователь заходит на страницу и видит поля для ввода ФИО, телефона, адреса, а также кнопку "Найти пункт выдачи"
- Пользователь вводит данные и нажимает на кнопку. Необходимо произвести валидацию введенных данных. Если поля ФИО,
телефон и адрес заполнены корректно, средствами
javascript
отправляется AJAX-запрос, обрабатываемый файломajax.php
ajax.php
создает экземпляр класса Candidate и передает управление методу run- Методы класса Candidate обрабатывают полученные данные и определяют название ближайшего пункта выдачи и расстояние до него
- Полученные результаты добавляются в ответ
AJAX
-запроса и средствамиjavascript
выводятся вdiv
на странице
Требования:
- Информация о пунктах выдачи хранится исключительно в базе данных
- Изменять содержимое исходных файлов запрещено
- Отправка и обработка
AJAX
-запроса, а также вывод результатов вdiv
должны производится средствами "чистого"javascript
(библиотекуjQuery
не использовать) - Расстояние выводится в километрах с округлением до 1 знака после запятой.
Все необходимые файлы добавлены в проект
Запустите контейнер
docker-compose up -d
Вы можете получить доступ к приложению по указанному URL-адресу:
http://localhost
translation for foreigners:
Test task for the developer
Let's assume that there are 5 pick-up points with the specified geographical coordinates in Saint Petersburg.
name | latitude | longitude | |
---|---|---|---|
1 | Alderaan | 59.9573 | 30.3485 |
2 | Bespin | 60.0025 | 30.3113 |
3 | Dagobah | 59.9485 | 30.3857 |
4 | Coruscant | 59.9894 | 30.2587 |
5 | Mustafar | 59.8836 | 30.3575 |
You need to create a web service prompts the user to enter their full name, phone number, and address, and uses the entered address to determine the nearest pick-up point and the distance to it. The user is shown their name, formatted phone number, and information about the pick-up point.
Files in archive:
Toolkit.php
- an auxiliary class contains a method for formatting the phone number, as well as a method for determining the geographical coordinates of the entered address.CandidateAbstract.php
- an abstract class.ajax.php
- file for the AJAX request.
You need to create a file Candidate.php
and declare the Candidate
class in it, which will inherit 'CandidateAbstract'.
You also need to create a file that contains a form for entering your full name, phone number, and address,
as well as a button that starts the process of determining the nearest pick-up point.
After successfully determining the nearest item in the div
the page should display the result in the form
"[full name] ([formatted phone number]): the nearest pick-up point [name of the point] is located at a distance of [distance to the point]km"
Expected sequence of processes:
- The user goes to the page and sees the fields for entering full name, phone, address, as well as the "Find pick-up point button".
- The user enters data and clicks on the button. The entered data must be validated. If the full name,
phone, and address fields are filled in correctly, an AJAX request is sent using javascript, which is processed by the file
ajax.php
. ajax.php
creates an instance of the Candidate class and passes control to the run method.- methods of the Candidate class process the received data and determine the name of the nearest delivery point and the distance to it
- the Results obtained are added to the response of the 'AJAX' request and output to the
div
usingjavascript
on page.
Requirements:
- Information about the outlets should be stored exclusively in the database.
- It is forbidden to Change the contents of the source files.
- Sending and processing of the
AJAX
request, as well as output of the results to thediv
must be performed using pure javascript (without usage ofjQuery
). - The distance should be displayed in kilometers rounded to 1 decimal place.
All necessary files added to the project
Start the container
docker-compose up -d
You can then access the application through the following URL:
http://localhost