Skip to content

Commit

Permalink
Fix the brick
Browse files Browse the repository at this point in the history
  • Loading branch information
spotbot2k committed Jun 15, 2022
1 parent 602123a commit da2323d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 32 deletions.
6 changes: 5 additions & 1 deletion src/Document/Areabrick/Exam.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public function getName()
public function action(Info $info): ?Response
{
$examObject = $this->getDocumentEditable($info->getDocument(), 'relation', 'examObject')->getElement();
if (is_null($examObject)) {
return null;
}

$canAttend = $this->helper->canAttend($examObject);
$form = $this->formFactory->createBuilder(ExamType::class, $examObject)->getForm();

Expand All @@ -55,7 +59,7 @@ public function action(Info $info): ?Response
$result = $this->helper->process($examObject, $info->getRequest()->get(ExamType::PREFIX));

if ($result->isPassed) {
$info->setParam('result', $this->helper->validateCertificate($result->hash));
$info->setParam('result', $result);
}

$info->setParam('ratio', $result->ratio);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
"lmf_rejection_ratio";"Sie haben nicht bestanden, %ratio%% Antworten waren korrekt.";"You have not passed - only <b>%ratio%%</b> of your answers were correct."
"lmf_rejection_attempts";"Sie haben %attempts% versuche übrig.";"You have %attempts% attempt(s) left."
"lmf_success_passed";"Sie haben mit der Note %grade% bestanden, gut gemacht! %ratio%% der Antworten Waren korrekt!";"You have passed with %grade%, well done! %ratio%% of your answers were correct!"
"lmf_select_object_first";"Bitte einen Datenobjekt zuweisen";"Please select a dataobject first"
64 changes: 34 additions & 30 deletions src/Resources/views/areas/exam/view.html.twig
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
{% form_theme form 'bootstrap_4_layout.html.twig' %}
{% if form is defined %}
{% form_theme form 'bootstrap_4_layout.html.twig' %}

<div id="main-content" class="main-content mb-5">
<div class="page-header">
<h1>{{ exam.getTitle() }}</h1>
</div>

{{ exam.getDescription() | raw }}

{% if result is defined and result.isValid() %}
<div class="alert alert-success" role="alert">
{{ 'lmf_success_passed' | trans({ '%ratio%': result.get('ratio'), '%grade%': result.get('grade') }) }}
<div id="main-content" class="main-content mb-5">
<div class="page-header">
<h1>{{ exam.getTitle() }}</h1>
</div>
{% elseif canAttend.isRejected() %}
<div class="alert alert-danger" role="alert">
{{ 'lmf_rejection_custom' | trans }}: {{ canAttend.getReason() | trans }}

{% set testsLeft = canAttend.getUnfulfilledPrerequisites() %}
{% if testsLeft is not empty %}
<p>{{ 'lmf_rejection_reason_unfullfilled_prerequisite' | trans }}</p>
{% for test in testsLeft %}
<a href="/lmf/form/{{ test.getId() }}">{{ test.getTitle() }}</a><br>
{% endfor %}
{% endif %}
</div>
{% else %}
{% if ratio is not null %}
{{ exam.getDescription() | raw }}

{% if result is defined and result.isPassed %}
<div class="alert alert-success" role="alert">
{{ 'lmf_success_passed' | trans({ '%ratio%': result.get('ratio'), '%grade%': result.get('gradeAchieved') }) }}
</div>
{% elseif canAttend.isRejected() %}
<div class="alert alert-danger" role="alert">
{{ 'lmf_rejection_ratio' | trans({ '%ratio%': ratio }) }}
{% if attempts is defined %}
{{ 'lmf_rejection_attempts' | trans({ '%attempts%': attempts }) }}
{{ 'lmf_rejection_custom' | trans }}: {{ canAttend.getReason() | trans }}

{% set testsLeft = canAttend.getUnfulfilledPrerequisites() %}
{% if testsLeft is not empty %}
<p>{{ 'lmf_rejection_reason_unfullfilled_prerequisite' | trans }}</p>
{% for test in testsLeft %}
<a href="/lmf/form/{{ test.getId() }}">{{ test.getTitle() }}</a><br>
{% endfor %}
{% endif %}
</div>
{% else %}
{% if ratio is defined and ratio is not null %}
<div class="alert alert-danger" role="alert">
{{ 'lmf_rejection_ratio' | trans({ '%ratio%': ratio }) | raw }}
{% if attempts is defined %}
{{ 'lmf_rejection_attempts' | trans({ '%attempts%': attempts }) }}
{% endif %}
</div>
{% endif %}
{{ form(form) }}
{% endif %}
{{ form(form) }}
{% endif %}
</div>
</div>
{% elseif editmode %}
<i>{{ 'lmf_select_object_first' | trans }} </i>
{% endif %}
2 changes: 1 addition & 1 deletion src/Result/AttemptResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(
$this->incorrectAnswers = $incorrectAnswers;
$this->ratio = $ratio;
$this->time = $time;
$this->gradAchieved = $gradeAchieved;
$this->gradeAchieved = $gradeAchieved;
$this->isPassed = $isPassed;
$this->hash = $hash;
}
Expand Down

0 comments on commit da2323d

Please sign in to comment.