Skip to content

Commit 5584d88

Browse files
palves-ulhtjoao-marques-a22108693
authored andcommitted
add link to the assignment's github page on the assignment detail and the build report
1 parent b43cf97 commit 5584d88

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/main/kotlin/org/dropProject/dao/Assignment.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,18 @@ data class Assignment(
201201
override fun toString(): String {
202202
return "$id - $name"
203203
}
204+
205+
fun linkToGithub(): String? {
206+
if (gitRepositoryPrivKey == null) {
207+
return null
208+
}
209+
210+
val parts = gitRepositoryUrl.split(":")
211+
val hostAndPath = parts[1].removeSuffix(".git").split("/")
212+
val username = parts[0].substringAfter("@")
213+
val host = hostAndPath[0]
214+
val repositoryName = hostAndPath[1]
215+
216+
return "https://$host/$username/$repositoryName"
217+
}
204218
}

src/main/resources/templates/assignment-detail.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ <h1 class="page-header col-sm-11" th:text="'Assignment ' + ${assignment.id}">Ass
8686
</div>
8787
<div class="form-group" >
8888
<label class="col-sm-3 control-label">Connected to:</label>
89-
<div th:if="${assignment.gitRepositoryPrivKey != null}" class="col-sm-9 read-row" th:text="${assignment.gitRepositoryUrl}"></div>
89+
<a th:if="${assignment.gitRepositoryPrivKey != null}" class="col-sm-9 read-row"
90+
th:text="${assignment.gitRepositoryUrl}"
91+
th:href="${assignment.linkToGithub()}">link to github</a>
9092
<div th:if="${assignment.gitRepositoryPrivKey == null}" class="col-sm-9 read-row alert alert-warning">This assignment is not yet connected to a git repository!</div>
9193
</div>
9294
<div class="form-group" th:if="${lastCommitInfoStr != null}">

src/main/resources/templates/build-report.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<h1 class="page-header" th:text="'Build report for submission ' + ${submission.id}"></h1>
2525
<h6>
26-
Assignment: <span th:text="${assignment.id}"></span> |
26+
Assignment: <a th:href="${assignment.linkToGithub()}" th:text="${assignment.id}"></a> |
2727
Submitted: <span th:text="${#dates.format(submission.submissionDate, 'dd-MM HH:mm:ss')}"></span>
2828
<a th:if="${isTeacher}"
2929
th:href="@{'/submissions?assignmentId=' + ${assignment.id} + '&groupId=' + ${submission.group.id}}">(other submissions)</a>

0 commit comments

Comments
 (0)