Commit 367de6ac authored by Björn Eyselein's avatar Björn Eyselein
Browse files

Updates Corp Ident

parent 33b40d53
......@@ -15,7 +15,6 @@ class AdminController @Inject()(cc: ControllerComponents, protected val tableDef
override protected val adminRightsRequired: Boolean = true
def index: EssentialAction = futureWithUser { admin =>
implicit request =>
tableDefs.futureAllCourses map {
......@@ -47,7 +46,7 @@ class AdminController @Inject()(cc: ControllerComponents, protected val tableDef
def onRead: Course => Future[Result] = { newCourse =>
tableDefs.futureInsertCourse(newCourse) map {
_ => Redirect(routes.AdminController.courseAdmin(newCourse.id))
_ => Redirect(routes.AdminController.index())
}
}
......@@ -79,7 +78,7 @@ class AdminController @Inject()(cc: ControllerComponents, protected val tableDef
def onRead: Collection => Future[Result] = { newCollection =>
tableDefs.futureInsertCollection(newCollection) map {
_ => Redirect(routes.AdminController.collectionAdmin(courseId, newCollection.id))
_ => Redirect(routes.AdminController.courseAdmin(courseId))
}
}
......@@ -88,6 +87,10 @@ class AdminController @Inject()(cc: ControllerComponents, protected val tableDef
// Flashcards
def uploadCardsFileForm(courseId: Int, collId: Int): EssentialAction = withUser { user =>
implicit request => Ok(views.html.forms.uploadCardsForm(user, courseId, collId))
}
def uploadCardsFile(courseId: Int, collId: Int): EssentialAction = futureWithUserAndCollection(courseId, collId) { (admin, collection) =>
implicit request =>
......
......@@ -4,7 +4,7 @@ import model.levenshtein.Levenshtein
object Corrector {
private def matchAnswerIds(selectedIds: Seq[Int], correctIds: Seq[Int]): AnswerSelectionResult = AnswerSelectionResult(
def matchAnswerIds(selectedIds: Seq[Int], correctIds: Seq[Int]): AnswerSelectionResult = AnswerSelectionResult(
wrong = selectedIds diff correctIds,
correct = selectedIds intersect correctIds,
missing = correctIds diff selectedIds
......
package model
object TemplateConsts {
val primaryColor = "blue-grey darken-3"
val accentColor = "deep-orange accent-3"
// val accentColor = ""
val colorGreen = "green accent-3"
val colorRed = "red accent-3"
}
......@@ -7,7 +7,7 @@ object Levenshtein {
@inline
private def minimum(i: Int*): Int = i.min
private def calcuateTable(s1: String, s2: String): Array[Array[Int]] = {
private def calculateTable(s1: String, s2: String): Array[Array[Int]] = {
val dist = Array.tabulate(s1.length + 1, s2.length + 1) { (j, i) => if (j == 0) i else if (i == 0) j else 0 }
for {
......@@ -21,12 +21,11 @@ object Levenshtein {
}
def distance(s1: String, s2: String): Int = {
val dist = calcuateTable(s1, s2)
val dist = calculateTable(s1, s2)
dist(s2.length)(s1.length)
}
def calculateBacktrace(start: String, target: String): Seq[EditOperation] = {
@annotation.tailrec
......@@ -52,7 +51,7 @@ object Levenshtein {
} else operations
val dist = calcuateTable(start, target)
val dist = calculateTable(start, target)
go(dist, start.length, target.length, List[EditOperation]())
}
......
......@@ -11,11 +11,17 @@ trait CoursesCollectionsFlashcardsTableQueries {
// Numbers
def futureNextCourseId: Future[Int] = db.run(coursesTQ.map(_.id).max.result).map(_.getOrElse(0))
def futureNextCourseId: Future[Int] = db.run(coursesTQ.map(_.id).max.result).map {
case None => 0
case Some(currentId) => currentId + 1
}
def futureNextCollectionIdInCourse(courseId: Int): Future[Int] = db.run(
collectionsTQ.filter { coll => coll.courseId === courseId }.map(_.id).max.result
).map(_.getOrElse(0))
).map {
case None => 0
case Some(currentId) => currentId + 1
}
// Reading
......@@ -103,7 +109,7 @@ trait CoursesCollectionsFlashcardsTableQueries {
futureSavedBlanksAnswers <- Future.sequence(blanksAnswers.map(futureInsertBlanksAnswer))
} yield futureSavedChoiceAnswers.forall(identity) && futureSavedBlanksAnswers.forall(identity)
}
}
......
......@@ -2,42 +2,46 @@
@(user: User, courses: Seq[Course])
@title = @{
"Administrator"
}
@title = @{
"Administrator"
}
@coursesPerRow = @{
2
}
@coursesPerRow = @{
2
}
@colWidth = @{
12 / coursesPerRow
}
@colWidth = @{
12 / coursesPerRow
}
@main(title, Some(user)) {
<h2 class="center-align">Kurse</h2>
@main(title, Some(user)) {
<h2 class="center-align">Kurse</h2>
<hr>
<hr>
@if(courses.nonEmpty) {
@if(courses.nonEmpty) {
@for(languageGroup <- courses.grouped(coursesPerRow)) {
<div class="row">
@for(language <- languageGroup) {
<div class="col m@colWidth s12">
<a class="btn btn-large waves-effect waves-block blue" href="@routes.AdminController.courseAdmin(language.id)">@language.name</a>
@for(languageGroup <- courses.grouped(coursesPerRow)) {
<div class="row">
@for(language <- languageGroup) {
<div class="col m@colWidth s12">
<a class="btn btn-large waves-effect waves-block @primaryColor" href="@routes.AdminController.courseAdmin(language.id)">@language.name</a>
</div>
}
</div>
}
</div>
}
} else {
<h4 class="red-text">Es existieren noch keine Kurse.</h4>
}
} else {
<h4 class="red-text center-align">Es existieren noch keine Kurse.</h4>
}
<hr>
<hr>
<a href="@routes.AdminController.newCourseForm" class="btn btn-large waves-effect waves-block green">
Neuen Kurs erstellen</a>
<div class="row">
<div class="col s12">
<a href="@routes.AdminController.newCourseForm" class="btn btn-large waves-effect waves-block @accentColor">
Neuen Kurs erstellen</a>
</div>
</div>
}
}
@import model.{User, Course, Collection}
@(user: User, course: Course, x: Seq[(Collection, Boolean)])
@title = @{
s"Kurs '${course.name}', Sammlungen importieren"
}
@main(title, Some(user)) {
<h2 class="center-align">@title</h2>
<hr>
@*
@if(x.nonEmpty) {
@for(xGroup <- x.grouped(2)) {
<div class="row">
@for((collection, isImported) <- xGroup) {
<div class="col s6">
@if(isImported) {
<a href="@routes.AdminController.deallocateCollectionFromCourse(course.id, collection.id)"
class="btn btn-large waves-effect waves-block green">Import @collection.name beenden</a>
} else {
<a href="@routes.AdminController.allocateCollectionToCourse(course.id, collection.id)"
class="btn btn-large waves-effect waves-block red">@collection.name importieren</a>
}
</div>
}
</div>
}
} else {
<p class="red-text">Konnte keine Sammlungen finden...</p>
}
*@
}
......@@ -6,6 +6,14 @@
s"Sammlung '${collection.name}'"
}
@flashcardsPerRow = @{
2
}
@colWidth = @{
12 / flashcardsPerRow
}
@main(title, Some(user)) {
<h2 class="center-align">@title</h2>
......@@ -13,10 +21,10 @@
@if(flashcards.nonEmpty) {
@for(flashcardGroup <- flashcards.grouped(2)) {
@for(flashcardGroup <- flashcards.grouped(flashcardsPerRow)) {
<div class="row">
@for(flashcard <- flashcardGroup) {
<div class="col m6 s12">
<div class="col m@colWidth s12">
<div class="card-panel">@flashcard.identifier.asString @flashcard.question</div>
</div>
}
......@@ -25,36 +33,16 @@
} else {
<h4 class="red-text center-align">Diese Sammlung enthält noch keine Karteikarten.</h4>
<br>
}
<hr>
<div class="row">
<div class="col s12">
<h4 class="center-align">Karteikarten hochladen</h4>
@helper.form(routes.AdminController.uploadCardsFile(courseId, collection.id), 'enctype -> "multipart/form-data") {
@helper.CSRF.formField
<div class="file-field input-field">
<div class="btn">
<span>File</span>
<input type="file" name="@Consts.excelFileName" required>
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text">
</div>
</div>
<p class="red-text"><i>Achtung:</i> Es findet keinerlei Überprüfung auf Duplikate statt!</p>
<button class="btn btn-large waves-effect waves-block green">Hochladen</button>
}
<a href="@routes.AdminController.uploadCardsFileForm(courseId, collection.id)"
class="btn btn-large waves-effect waves-block @accentColor">Sammlung erstellen</a>
</div>
</div>
}
......@@ -3,7 +3,7 @@
@(user: User, course: Course, collections: Seq[Collection])
@title = @{
s"Administration Kurs '${course.name}'"
s"Kurs '${course.name}'"
}
@collsPerRow = @{
......@@ -26,20 +26,21 @@
@for(collection <- collectionGroup) {
<div class="col m@colWidth s12">
<a href="@routes.AdminController.collectionAdmin(course.id, collection.id)"
class="btn btn-large waves-effect waves-block green">@collection.name</a>
class="btn btn-large waves-effect waves-block @primaryColor">@collection.name</a>
</div>
}
</div>
}
} else {
<p class="center-align red-text">
Dieser Kurs besitzt noch keine Sammlungen. Sie müssen dem Kurs erst Sammlungen zuordnen.
</p>
<h4 class="red-text center-align">Dieser Kurs besitzt noch keine Sammlungen.</h4>
}
<hr>
<a href="@routes.AdminController.newCollectionForm(course.id)"
class="btn btn-large waves-effect waves-block blue">Sammlung erstellen</a>
<div class="row">
<div class="col s12">
<a href="@routes.AdminController.newCollectionForm(course.id)"
class="btn btn-large waves-effect waves-block @accentColor">Sammlung erstellen</a>
</div>
</div>
}
......@@ -15,7 +15,7 @@
<div class="row">
<div class="col s12">
<a href="@routes.AdminController.collectionAdmin(courseId, collection.id)" class="btn btn-large waves-effect waves-block green">
<a href="@routes.AdminController.collectionAdmin(courseId, collection.id)" class="btn btn-large waves-effect waves-block @accentColor">
Zurück zur Sammlung
</a>
</div>
......
......@@ -2,33 +2,31 @@
@(user: User, course: Course, collections: Seq[Collection])
@title = @{
s"Kurs ${course.name}"
}
@title = @{
s"Kurs '${course.name}'"
}
@main(title, Some(user)) {
<h2 class="center-align">@course.name</h2>
@main(title, Some(user)) {
<h2 class="center-align">@title</h2>
<hr>
<hr>
@if(collections.nonEmpty) {
@if(collections.nonEmpty) {
@for(collectionGroup <- collections.grouped(2)) {
<div class="row">
@for(collection <- collectionGroup) {
<div class="col s6">
<a href="@routes.HomeController.collection(course.id, collection.id)"
class="btn btn-large waves-effect waves-block green">@collection.name</a>
@for(collectionGroup <- collections.grouped(2)) {
<div class="row">
@for(collection <- collectionGroup) {
<div class="col s6">
<a href="@routes.HomeController.collection(course.id, collection.id)"
class="btn btn-large waves-effect waves-block @primaryColor">@collection.name</a>
</div>
}
</div>
}
</div>
} else {
<h4 class="center-align red-text">Für diesen Kurs existieren noch keine Sammlungen.<br>
Wenden Sie Sich bitte an den oder die Kursverantwortliche(n).</h4>
}
} else {
<p class="center-align red-text">
Für diesen Kurs existieren noch keine Sammlungen.
Wenden Sie Sich bitte an den oder die Kursverantwortliche(n).
</p>
}
}
@(user: model.User)
@title = @{
"Import ..."
}
@main(title, Some(user)) {
}
\ No newline at end of file
......@@ -8,18 +8,18 @@
@main(title, None) {
<h1 class="center-align">@title</h1>
<h2 class="center-align">@title</h2>
<form action="@routes.LoginController.login" method="post" class="col s12">
@* @helper.CSRF.formField *@
@helper.CSRF.formField
@myhelpers.input(loginForm(Consts.usernameName), "Nutzername", isRequired = true)
@myhelpers.input(loginForm(Consts.pwName), "Password", fieldType = "password", isRequired = true)
<div>
<button class="btn waves-effect waves-light green">Login</button>
<button class="btn btn-large waves-effect waves-light @accentColor">Login</button>
</div>
</form>
......
......@@ -2,25 +2,29 @@
@(user: User, courseId: Int, newCollectionForm: Form[Collection])(implicit requestHeader: RequestHeader, messagesProvider: MessagesProvider)
@title = @{
"Neue Sammlung erstellen"
}
@title = @{
"Neue Sammlung erstellen"
}
@main(title, Some(user)) {
<div class="row">
<div class="col s12">
<h4 class="center-align">Neue Sammlung erstellen</h4>
@main(title, Some(user)) {
<h2 class="center-align">@title</h2>
<div class="row">
<div class="col s12">
@helper.form(routes.AdminController.newCollection(courseId)) {
@helper.CSRF.formField
@myhelpers.input(newCollectionForm(Consts.idName), labelContent = "Id", isRequired = true, isReadOnly = true)
@myhelpers.input(newCollectionForm(Consts.courseIdName), labelContent = "Kurs", isRequired = true, isReadOnly = true)
@myhelpers.input(newCollectionForm(Consts.nameName), labelContent = "Name", isRequired = true)
<button class="btn btn-large waves-effect waves-block green">Sammlung erstellen</button>
<button class="btn btn-large waves-effect waves-block @accentColor">Sammlung erstellen</button>
}
</div>
</div>
</div>
}
}
......@@ -2,28 +2,29 @@
@(user: User, newCourseForm: Form[Course])(implicit requestHeader: RequestHeader, messagesProvider: MessagesProvider)
@title = @{
"Neuen Kurs erstellen"
}
@title = @{
"Neuen Kurs erstellen"
}
@main(title, Some(user)) {
<div class="row">
<div class="col s12">
<h4 class="center-align">Neuen Kurs erstellen</h4>
@main(title, Some(user)) {
<h2 class="center-align">@title</h2>
<div class="row">
<div class="col s12">
@helper.form(routes.AdminController.newCourse) {
@helper.CSRF.formField
@myhelpers.input(newCourseForm(Consts.idName), labelContent = "Id", fieldType = "number", isRequired = true)
@myhelpers.input(newCourseForm(Consts.idName), labelContent = "Id", fieldType = "number", isRequired = true, isReadOnly = true)
@myhelpers.input(newCourseForm(Consts.shortNameName), labelContent = "Kurzname", isRequired = true)
@myhelpers.input(newCourseForm(Consts.nameName), labelContent = "Name", isRequired = true)
<button class="btn btn-large waves-effect waves-block green">Kurs erstellen</button>
<button class="btn btn-large waves-effect waves-block @accentColor">Kurs erstellen</button>
}
</div>
</div>
</div>
}
}
......@@ -6,6 +6,14 @@
"In Kurse einschreiben"
}
@btnsPerRow = @{
2
}
@colWidth = @{
12 / btnsPerRow
}
@main(title, Some(user)) {
<h2 class="center">@title</h2>
......@@ -14,19 +22,32 @@
@if(allCoursesAndRegisterStates.nonEmpty) {
@for((course, registered) <- allCoursesAndRegisterStates;
btnColor = if(registered) "red" else "green";
linkText = if(registered) s"Aus Kurs ${course.name} austragen" else s"In Kurs ${course.name} einschreiben";
linkHref = if(registered) routes.HomeController.unregisterForCourse(course.id) else routes.HomeController.registerForCourse(course.id)) {
<a href="@linkHref" class="btn btn-large waves-effect waves-block @btnColor">@linkText</a>
@for(xGroup <- allCoursesAndRegisterStates.grouped(btnsPerRow)) {
<div class="row">
@for((course, registered) <- xGroup;
btnColor = if(registered) colorRed else colorGreen;
linkText = if(registered) s"Aus Kurs ${course.name} austragen" else s"In Kurs ${course.name} einschreiben";
linkHref = if(registered) routes.HomeController.unregisterForCourse(course.id) else routes.HomeController.registerForCourse(course.id)) {
<div class="col m@colWidth s12">
<a href="@linkHref" class="btn btn-large waves-effect waves-block @btnColor">@linkText</a>
</div>
}
</div>
}
} else {
<h4 class="red-text">Es konnten keine Kurse gefunden werden!</h4>
<h4 class="red-text center-align">Es konnten keine Kurse gefunden werden!</h4>
}
<hr>
<a class="btn btn-large waves-effect waves-block blue" href="@routes.HomeController.index()">Zu den Kursen</a>
<div class="row">
<div class="col s12">
<a class="btn btn-large waves-effect waves-block @accentColor" href="@routes.HomeController.index()">
Zu meinen Kursen</a>
</div>
</div>
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment