Success threshold: 15 points
You get 1 point for each question answered correctly. For any incorrectly answered question you get nothing. If the answer is only partial (and it would not be possible to program the thing based on it), the question counts as incorrect (it is not possible to get half a point). If the solution contains a security bug, or a typo in the code, or a typo in the code, the answer is considered incorrect because it would not run.
1 Explain the difference between the for
, while
, and foreach
loops. For each, give 1 specific example of its use that clearly shows its main advantage.
We have a variable about which we know almost nothing (we only know its name). How can we see its contents? For example, it is called $data
.
Write the following commands below to work with the Git repository:
Statistic.php
filecron
directoryLet's have a text string in the variable. Give an example of a function to calculate the checksum.
Write a code snippet that creates a delete
action in Presenter
that accepts the item ID as an integer and deletes a row from the question
table according to the specified ID. After a successful deletion, it will print the message "Question deleted" and redirect to the list
action.
Under question for an extra point: If the deletion fails for some reason, it does not throw a fatal error, but also informs the user about it with a message (flash message).
When I create a Nette form, it becomes a component. What is a Nette component?
I need to create a simple Nette form to insert a record into a question
table that contains a list of questions. The structure of the table is:
Column | Properties |
---|---|
id | int(8), unsigned, auto increment |
question | varchar(255) |
is_active | tinyint(1), unsigned, default value: 1 |
Create the appropriate form fields to insert a new row into this table. After inserting the record, a FlashMessage must be fired informing about successful inserting of the record + redirection to editing the record (edit
action).
group
table that will contain information about the groups. When creating a question, it will then be possible to determine which group the question belongs to. You will need to set up a session between the tables (describe how this is done and how it will be set up).Presenter
which is created as a component. We want to pass in default values from what is in the database, i.e. we need to get the data from the table in some convenient way.9 Consider the following data retrieved from a database (using a regular Nette Database):
$questions = $this->db->questions()->fetchAll();
How do we output the text of all questions as a bulleted list?
How do we pass the data from the table to the Latte template?
What Latte macros will we need to list the items? Give a specific implementation of listing the id
and name
columns in the format:
*1024: How are you ? *1025: What did you have for lunch today?
$form->add(here will be an example);
and for each one, explain what it does and what output it returns (data type + example).
question
.1 > 0
1 == 1
1 == "1"
1 === "1"
1 == true
1 === true
1 === false
1 == "1" && 1=== true
==
(two equals) and ===
(three equals)?==
in conditions and how specifically ==
solves this problem (example where ==
may fail and ==
saves the situation)Let's have a coordination table (coordinations table) that lists all coordinations between 2 people. One of them organizes the coordination and the other is a guest. Write a database selection that returns all the rows with coordinations that involve me (am I the organizer of the coordination, or am I the guest of the coordination). The table has columns id
, id_user_organizer
(organizer id), id_user_quest
(guest id). My ID is stored in the usual way in Presenter
.
Group of questions about Latte:
variable
, macro
, filter
and n:attribute
? What is used where?DashboardPresenter
reference to a default
action?QuestionPresenter
, edit
action) of a question to pass the ID of the currently listed question? Write specific Latte code.Symbolically written (sample in PHP, translate to Latte):
foreach ($questions as $question) {echo $question->id; // question idecho $question->question; // question text}
StatisticManager
service, which has a public method getStatistics()
that accepts no parameters. How do I load this service in Presenter and call the public method getStatistics()
in the default action and pass the result to the template?object
, class
, service
?model
, entity
and value object
?$imageGenerator = ["points" => [480: [910, 30, 1845, 1150],600: [875, 95, 1710, 910],768: [975, 130, 1743, 660]]];
imageGenerator
parameter that we registered in the previous task, so that the service receives it in the constructor and can use it in the service (in the sense of configuration). For the service, provide a sample implementation of the constructor so that the first input parameter is treated as the data type for the array.method
, properties
and constants
? What is the difference between them?public
, private
, protected
), explain the difference and a specific example of usage and who can see what and when.course
in which there is a private property currentCourse
in which the current course is stored. How to make the property read only and not write from the outside?OOP design pattern
)?DI
and DIC
?Jan Barášek Více o autorovi
Autor článku pracuje jako seniorní vývojář a software architekt v Praze. Navrhuje a spravuje velké webové aplikace, které znáte a používáte. Od roku 2009 nabral bohaté zkušenosti, které tímto webem předává dál.
Rád vám pomůžu:
Články píše Jan Barášek © 2009-2024 | Kontakt | Mapa webu
Status | Aktualizováno: ... | en