New view for form and admin
continuous-integration/drone/push Build is passing Details

interestingProfiles
Alexis 2 years ago
parent 0c9fa8e0ec
commit 9f728edf8a

@ -26,17 +26,17 @@ class CheckBoxQuestion extends BoxQuestion
$categories = $this->getCategories();
$html = "\t\t\t<div data-id='$id' class='question'>
<label>$content</label>\n";
<label><strong>$content</strong></label>\n";
for ($i = 0; $i < count($possibleResponses); $i++) {
$categoriesSplit = $possibleResponses[$i]."||";
foreach ($categories[$i] as $category) {
$categoriesSplit.= $category."_";
}
$html.= "\t\t\t\t<input type='checkbox' name='answers[]' value='$categoriesSplit' />
$html.= "\t\t\t\t<br><li><input type='checkbox' name='answers[]' value='$categoriesSplit' />
<label>$possibleResponses[$i]</label>\n";
}
$html.= "\t\t\t</div>\n";
$html.= "\t\t\t</div><br>\n";
return $html;
}

@ -26,8 +26,8 @@ class ListBoxQuestion extends BoxQuestion
$categories = $this->getCategories();
$html = "\t\t\t<div data-id='$id' class='question'>
<label>$content</label>
<select name='answers[]'>\n";
<label><strong>$content</strong></label>
<br><select name='answers[]'>\n";
for ($i = 0; $i < count($possibleResponses); $i++) {
$categoriesSplit = $possibleResponses[$i]."||";
@ -37,7 +37,7 @@ class ListBoxQuestion extends BoxQuestion
$html.= "\t\t\t\t\t<option value='$categoriesSplit'>$possibleResponses[$i]</option>\n";
}
$html.= "\t\t\t\t</select>
</div>\n";
</div><br>\n";
return $html;
}

@ -18,8 +18,8 @@ class TextQuestion extends Question
$id = $this->getId();
return "\t\t\t<div class='question'>
<label>$content</label>
<input data-id='$id' type='text' name='answers[]' />
</div>\n";
<label><strong>$content</strong></label>
<br><input data-id='$id' type='text' name='answers[]' />
</div><br>\n";
}
}

@ -20,8 +20,8 @@ class ModelCandidate
public function submitForm(): void
{
$answersAndCategories = $_POST['answers'];
$dataIds = null;
$dataIds = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'submitForm') {
$dataIdsJson = $_POST['data_ids'];
$dataIds = json_decode($dataIdsJson);
@ -61,11 +61,17 @@ class ModelCandidate
$description = $form[0]['description'];
$questionsTab = (new GatewayQuestion())->getAllQuestions($form[0]['id']);
$questions = Factory::getBuiltObjects($questionsTab, "Question");
$nbQuestions = count($questions);
$time = round(($nbQuestions * 20)/60);
$html = "
<h1>$title</h1>\n
<br>
<h3>$description</h3>\n
<br>
<h4><i>Temps estimé</i> : $time minutes</h4>
<div id='container_form'>\n
<form method='post'>\n";
@ -74,11 +80,11 @@ class ModelCandidate
}
if (count($questions) > 0) {
$html.= "\t\t\t<input type='submit'>\n
$html.= "\t\t\t<input type='submit' value='Envoyer' id='button' style='margin-left: 45%'>\n
\t\t\t<input type='hidden' name='data_ids' value=''>
\t\t\t<input type='hidden' name='action' value='submitForm'>
\t\t</form>\n
\t</div>\n";
\t</div><br><br><br>\n";
} else {
$html.= "\t\t</form>\n
\t</div>\n";

@ -1,18 +1,27 @@
h3 {
text-align: center;
}
h4 {
text-align: center;
font-weight: normal;
}
#container_form {
display: flex;
flex-direction: row;
justify-content: center;
margin-top: 5%;
margin-top: 3%;
}
#container_form h2{
padding-top: 1%;
}
#container_form #button {
#button {
margin-top: 5%;
width: 20%;
height: 5%;
width: 15%;
height: 3%;
margin-left: 79%;
margin-bottom: 10%;
cursor: pointer;
@ -21,8 +30,8 @@
border-radius: 20px;
}
#container_form #button:hover {
background-color: rgb(23,143,150);
#button:hover {
background-color: rgba(23, 143, 150, 0.7);
}
#container_testimony, #container_personalInfos {

@ -36,7 +36,7 @@
<?php
foreach ($categories as $category) {
?>
<label for="category"><?php echo $category ?></label>
<li><label for="category"><?php echo $category ?></label>
<input id="category" type="checkbox" name="categories[]" value="<?php echo $category ?>">
<?php
}

@ -1,9 +1,9 @@
let dataIds = [];
let elements = document.querySelectorAll('[data-id]');
elements.forEach(function(element) {
dataIds.push(element.getAttribute('data-id'));
});
let dataIdsInput = document.querySelector('input[name="data_ids"]');
dataIdsInput.value = JSON.stringify(dataIds);

Loading…
Cancel
Save