aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--services/app/src/App.php3
-rw-r--r--services/app/templates/answer_list.html.twig8
-rw-r--r--services/app/templates/quiz_view.html.twig8
3 files changed, 17 insertions, 2 deletions
diff --git a/services/app/src/App.php b/services/app/src/App.php
index 55f6ae3..e7d2816 100644
--- a/services/app/src/App.php
+++ b/services/app/src/App.php
@@ -260,12 +260,14 @@ final class App
$ranking = $answerRepo->getRanking($quiz->quiz_id, upto: 20);
}
+ $currentUser = $this->getCurrentUser($request);
return $this->render($request, $response, 'quiz_view.html.twig', [
'page_title' => "問題 #{$quiz->quiz_id}",
'quiz' => $quiz,
'ranking' => $ranking,
'is_ranking_hidden' => $quiz->isRankingHidden(),
'is_open' => $quiz->isOpenToAnswer(),
+ 'current_user_id' => $currentUser?->user_id,
]);
}
@@ -297,6 +299,7 @@ final class App
'answers' => $answers,
'is_ranking_hidden' => $quiz->isRankingHidden(),
'is_open' => $quiz->isOpenToAnswer(),
+ 'current_user_id' => isset($currentUser) ? $currentUser->user_id : null,
]);
}
diff --git a/services/app/templates/answer_list.html.twig b/services/app/templates/answer_list.html.twig
index 03ab438..818a755 100644
--- a/services/app/templates/answer_list.html.twig
+++ b/services/app/templates/answer_list.html.twig
@@ -45,7 +45,13 @@
{{ loop.index }}
{% endif %}
</td>
- <td><a href="{{ url_for('answer_view', { qslug: quiz.slug, anum: answer.answer_number }) }}">#{{ answer.answer_number }}</a></td>
+ <td>
+ {% if quiz.isOpenToAnswer() and answer.author_id != current_user_id %}
+ #{{ answer.answer_number }}
+ {% else %}
+ <a href="{{ url_for('answer_view', { qslug: quiz.slug, anum: answer.answer_number }) }}">#{{ answer.answer_number }}</a>
+ {% endif %}
+ </td>
<td>{{ answer.author_name }}{% if answer.author_is_admin %} (staff){% endif %}</td>
<td>{{ answer.code_size }} byte</td>
<td>{{ answer.submitted_at|date('Y-m-d H:i:s', 'Asia/Tokyo') }}</td>
diff --git a/services/app/templates/quiz_view.html.twig b/services/app/templates/quiz_view.html.twig
index ade324a..44676e2 100644
--- a/services/app/templates/quiz_view.html.twig
+++ b/services/app/templates/quiz_view.html.twig
@@ -41,7 +41,13 @@
{% for answer in ranking %}
<tr>
<td>{{ loop.index }}</td>
- <td><a href="{{ url_for('answer_view', { qslug: quiz.slug, anum: answer.answer_number }) }}">#{{ answer.answer_number }}</a></td>
+ <td>
+ {% if quiz.isOpenToAnswer() and answer.author_id != current_user_id %}
+ #{{ answer.answer_number }}
+ {% else %}
+ <a href="{{ url_for('answer_view', { qslug: quiz.slug, anum: answer.answer_number }) }}">#{{ answer.answer_number }}</a>
+ {% endif %}
+ </td>
<td>{{ answer.author_name }}{% if answer.author_is_admin %} (staff){% endif %}</td>
<td>{{ answer.code_size }} byte</td>
<td>{{ answer.submitted_at|date('Y-m-d H:i:s', 'Asia/Tokyo') }}</td>