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

Update for mobile phones

parent 01214b01
......@@ -21,7 +21,7 @@ function readSolution(cardType: CardType): undefined | Solution {
let selectedAnswers: number[] = [];
switch (cardType) {
case 'Vocable':
case 'Word':
case 'Text':
solution = document.querySelector<HTMLInputElement>('#translation_input').value;
......@@ -89,7 +89,7 @@ function onCorrectionSuccess(result: CorrectionResult, cardType: CardType): void
document.querySelector('#answeredFcCountSpan').innerHTML = answeredFlashcards.toString();
// FIXME: disable solution inputs?
if (flashcard.cardType === 'Text' || flashcard.cardType === 'Vocable') {
if (flashcard.cardType === 'Text' || flashcard.cardType === 'Word') {
document.querySelector<HTMLInputElement>('#translation_input').disabled = true;
}
......@@ -104,7 +104,7 @@ function onCorrectionSuccess(result: CorrectionResult, cardType: CardType): void
document.querySelector<HTMLSpanElement>('#triesSpan').innerText = result.newTriesCount.toString();
switch (cardType) {
case 'Vocable':
case 'Word':
case 'Text':
case 'Blank':
const textInput = document.querySelector<HTMLInputElement>('#translation_input');
......
type CardType = 'Vocable' | 'Text' | 'Blank' | 'Choice';
type CardType = 'Word' | 'Text' | 'Blank' | 'Choice';
type CorrectnessType = 'Correct' | 'Optional' | 'Wrong';
......
......@@ -3,7 +3,7 @@
const textAnswerInput: string = `
<div class="row">
<div class="input-field col s12">
<input type="text" id="translation_input" autofocus autocomplete="off">
<input type="text" id="translation_input" autofocus autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
<label for="translation_input">Übersetzung</label>
</div>
</div>`.trim();
......@@ -56,7 +56,7 @@ function updateView(flashcard: Flashcard): void {
const answerDiv = document.querySelector<HTMLDivElement>('#answerDiv');
switch (flashcard.cardType) {
case 'Text':
case 'Vocable' :
case 'Word' :
answerDiv.innerHTML = textAnswerInput;
document.querySelector<HTMLInputElement>('#translation_input').focus();
break;
......
......@@ -79,9 +79,9 @@ class HomeController @Inject()(cc: ControllerComponents, protected val tableDefs
}
}
def nextFlashcardToLearn(courseId: Int, collId: Int): EssentialAction = futureWithUserAndCollection(courseId, collId) { (user, course, collection) =>
def nextFlashcardToLearn(courseId: Int, collId: Int): EssentialAction = futureWithUserAndCollection(courseId, collId) { (user, _, collection) =>
implicit request =>
tableDefs.futureMaybeNextFlashcardToLearn(user, course, collection).map {
tableDefs.futureMaybeNextFlashcardToLearn(user, collection).map {
case None => NotFound("No Flashcard to learn found")
case Some(fc) => Ok(JsonFormats.flashcardToAnswerFormat.writes(fc))
}
......
......@@ -52,11 +52,7 @@ final case class Flashcard(
backHint: Option[String] = None,
blanksAnswers: Seq[BlanksAnswerFragment] = Seq.empty,
choiceAnswers: Seq[ChoiceAnswer] = Seq.empty
) {
def identifier: FlashcardIdentifier = FlashcardIdentifier(cardId, collId, courseId)
}
)
sealed trait FlashcardComponent {
val answerId: Int
......
......@@ -55,7 +55,7 @@ trait TableQueries {
def futureFlashcardsToLearnCount(user: User, collection: Collection): Future[Int] =
db.run(flashcardsToLearnTQ.filter(flashcardToDoFilter(_, collection, user)).size.result)
def futureMaybeNextFlashcardToLearn(user: User, course: Course, collection: Collection): Future[Option[FlashcardToAnswer]] =
def futureMaybeNextFlashcardToLearn(user: User, collection: Collection): Future[Option[FlashcardToAnswer]] =
db.run(flashcardsToLearnTQ.filter(flashcardToDoFilter(_, collection, user)).result.headOption).flatMap {
case None => Future.successful(None)
case Some(FlashcardToAnswerData(cardId, collId, courseId, _, frontToBack)) =>
......
......@@ -2,46 +2,53 @@
@(user: User, courses: Seq[Course])
@title = @{
"Administrator"
}
@coursesPerRow = @{
2
}
@colWidth = @{
12 / coursesPerRow
}
@main(title, Some(user)) {
<h2 class="center-align">Kurse</h2>
<hr>
@if(courses.nonEmpty) {
@for(courseGroup <- courses.grouped(coursesPerRow)) {
<div class="row">
@for(course <- courseGroup) {
<div class="col m@colWidth s12">
<a class="btn btn-large waves-effect waves-block @primaryColor" href="@routes.AdminController.courseAdmin(course.id)">@course.name</a>
@title = @{
"Administrator"
}
@coursesPerRow = @{
2
}
@colWidth = @{
12 / coursesPerRow
}
@main(title, Some(user)) {
<h3 class="center-align">Administration Kurse</h3>
<hr>
@if(courses.nonEmpty) {
@for(courseGroup <- courses.grouped(coursesPerRow)) {
<div class="row">
@for(course <- courseGroup) {
<div class="col m@colWidth s12">
<div class="card @primaryColor">
<div class="card-content white-text">
<span class="card-title">@course.name</span>
</div>
<div class="card-action">
<a href="@routes.AdminController.courseAdmin(course.id)">Administration Kurs</a>
</div>
</div>
}
</div>
}
} else {
<h4 class="red-text center-align">Es existieren noch keine Kurse.</h4>
</div>
}
<hr>
} else {
<h4 class="red-text center-align">Es existieren noch keine Kurse.</h4>
}
<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>
<hr>
<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>
}
}
......@@ -2,47 +2,47 @@
@(user: User, courseId: Int, collection: Collection, flashcards: Seq[Flashcard])(implicit requestHeader: RequestHeader, messagesProvider: MessagesProvider)
@title = @{
s"Sammlung '${collection.name}'"
}
@title = @{
s"Administration Sammlung '${collection.name}'"
}
@flashcardsPerRow = @{
2
}
@flashcardsPerRow = @{
2
}
@colWidth = @{
12 / flashcardsPerRow
}
@colWidth = @{
12 / flashcardsPerRow
}
@main(title, Some(user)) {
<h2 class="center-align">@title</h2>
@main(title, Some(user)) {
<h3 class="center-align">@title</h3>
<hr>
<hr>
@if(flashcards.nonEmpty) {
@if(flashcards.nonEmpty) {
@for(flashcardGroup <- flashcards.grouped(flashcardsPerRow)) {
<div class="row">
@for(flashcard <- flashcardGroup) {
<div class="col m@colWidth s12">
<div class="card-panel">@flashcard.identifier.asString @flashcard.front</div>
</div>
}
@for(flashcardGroup <- flashcards.grouped(flashcardsPerRow)) {
<div class="row">
@for(flashcard <- flashcardGroup) {
<div class="col m@colWidth s12">
<div class="card-panel">@flashcard.cardId: @flashcard.front</div>
</div>
}
} else {
<h4 class="red-text center-align">Diese Sammlung enthält noch keine Karteikarten.</h4>
</div>
}
<hr>
} else {
<h4 class="red-text center-align">Diese Sammlung enthält noch keine Karteikarten.</h4>
}
<div class="row">
<div class="col s12">
<a href="@routes.AdminController.uploadCardsFileForm(courseId, collection.id)"
class="btn btn-large waves-effect waves-block @accentColor">Karten importieren</a>
</div>
<hr>
<div class="row">
<div class="col s12">
<a href="@routes.AdminController.uploadCardsFileForm(courseId, collection.id)"
class="btn btn-large waves-effect waves-block @accentColor">Karten importieren</a>
</div>
</div>
}
}
......@@ -2,45 +2,51 @@
@(user: User, course: Course, collections: Seq[Collection])
@title = @{
s"Kurs '${course.name}'"
}
@collsPerRow = @{
2
}
@colWidth = @{
12 / collsPerRow
}
@main(title, Some(user)) {
<h2 class="center-align">@title</h2>
<hr>
@if(collections.nonEmpty) {
@for(collectionGroup <- collections.grouped(collsPerRow)) {
<div class="row">
@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 @primaryColor">@collection.name</a>
@title = @{
s"Administration Kurs '${course.name}'"
}
@collsPerRow = @{
2
}
@colWidth = @{
12 / collsPerRow
}
@main(title, Some(user)) {
<h3 class="center-align">@title</h3>
<hr>
@if(collections.nonEmpty) {
@for(collectionGroup <- collections.grouped(collsPerRow)) {
<div class="row">
@for(collection <- collectionGroup) {
<div class="col m@colWidth s12">
<div class="card @primaryColor">
<div class="card-content white-text">
<span class="card-title">@collection.name</span>
</div>
<div class="card-action">
<a href="@routes.AdminController.collectionAdmin(course.id, collection.id)">Administration Sammlung</a>
</div>
</div>
}
</div>
}
} else {
<h4 class="red-text center-align">Dieser Kurs besitzt noch keine Sammlungen.</h4>
</div>
}
} else {
<h4 class="red-text center-align">Dieser Kurs besitzt noch keine Sammlungen.</h4>
}
<hr>
<hr>
<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 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>
}
......@@ -2,31 +2,39 @@
@(user: User, courseId: Int, collection: Collection, flashcardCount: Int, toLearnCount: Int, toRepeatCount: Int)
@title = @{
s"Sammlung '${collection.name}'"
}
@title = @{
s"Sammlung '${collection.name}'"
}
@main(title, Some(user)) {
<h2 class="center-align">@title</h2>
@main(title, Some(user)) {
<h3 class="center-align">@title</h3>
<hr>
<hr>
<h5 class="center-align">Diese Sammlung enthält insgesamt @flashcardCount Karteikarten.</h5>
<div class="row">
<div class="col s12">
<div class="card @primaryColor">
<div class="card-content white-text">
<span class="card-title">
Diese Sammlung enthält insgesamt @flashcardCount Karteikarten.
<br>
<br>
<div class="row">
<div class="col s12">
@if(toLearnCount == 0) {
<a class="btn btn-large waves-effect waves-block white">
<span class="green-text">Sie haben alle Karteikarten gelernt.</span>
</a>
} else {
<a href="@routes.HomeController.learn(courseId, collection.id)"
class="btn btn-large waves-effect waves-block red">
Es existieren noch @toLearnCount neue Karteikarten.
</a>
}
@if(toLearnCount == 0) {
Sie haben alle Karteikarten gelernt.
} else {
Es existieren noch @toLearnCount neue Karteikarten.
}
</span>
</div>
<div class="card-action">
@if(toLearnCount == 0) {
<a class="grey-text">Lernen</a>
} else {
<a href="@routes.HomeController.learn(courseId, collection.id)">Lernen</a>
}
</div>
</div>
</div>
}
</div>
}
......@@ -2,31 +2,45 @@
@(user: User, course: Course, collections: Seq[Collection])
@title = @{
s"Kurs '${course.name}'"
}
@main(title, Some(user)) {
<h2 class="center-align">@title</h2>
<hr>
@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 @primaryColor">@collection.name</a>
@title = @{
s"Kurs '${course.name}'"
}
@collsPerRow = @{
2
}
@colWidth = @{
12 / collsPerRow
}
@main(title, Some(user)) {
<h3 class="center-align">@title</h3>
<hr>
@if(collections.nonEmpty) {
@for(collectionGroup <- collections.grouped(collsPerRow)) {
<div class="row">
@for(collection <- collectionGroup) {
<div class="col m@colWidth s12">
<div class="card @primaryColor">
<div class="card-content white-text">
<span class="card-title">@collection.name</span>
</div>
<div class="card-action">
<a href="@routes.HomeController.collection(course.id, collection.id)">Zur Sammlung</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>
</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>
}
}
......@@ -2,57 +2,64 @@
@(user: User, courses: Seq[Course], repeatCount: Int, pwSet: Boolean)
@title = @{
"Meine Kurse"
}
@title = @{
"Meine Kurse"
}
@coursesPerRow = @{
2
}
@coursesPerRow = @{
2
}
@colWidth = @{
12 / coursesPerRow
}
@colWidth = @{
12 / coursesPerRow
}
@main(title, Some(user), Some(repeatCount)) {
@main(title, Some(user), Some(repeatCount)) {
<h2 class="center-align">@title</h2>
<h3 class="center-align">@title</h3>
<hr>
<hr>
@if(courses.nonEmpty) {
@for(courseGroup <- courses.grouped(coursesPerRow)) {
<div class="row">
@for(course <- courseGroup) {
<div class="col m@colWidth s12">
<a href="@routes.HomeController.course(course.id)" class="btn btn-large waves-effect waves-block @primaryColor">@course.name</a>
@if(courses.nonEmpty) {
@for(courseGroup <- courses.grouped(coursesPerRow)) {
<div class="row">
@for(course <- courseGroup) {
<div class="col m@colWidth s12">
<div class="card @primaryColor">
<div class="card-content white-text">
<span class="card-title">@course.name</span>
</div>
<div class="card-action">
<a href="@routes.HomeController.course(course.id)">Zum Kurs</a>
</div>
</div>
}
</div>
}
} else {
<h4 class="red-text center-align">Sie sind noch nicht in einem Kurs registriert.</h4>
}
@if(!pwSet) {
<hr>
<div class="card-panel red white-text">
Sie haben noch kein Passwort für diese Anwendung eingerichtet. Sie können Sie weiterhin nutzen, sich aber nur über WueCampus einloggen.
Sie können <a href="@routes.LoginController.changePwForm">hier</a> ein Passwort vergeben.
</div>
}
} else {
<h4 class="red-text center-align">Sie sind noch nicht in einem Kurs registriert.</h4>
}
@if(!pwSet) {
<hr>
<div class="row">
<div class="col s12">
<a class="btn btn-large waves-effect waves-block @accentColor" href="@routes.HomeController.registerForCoursesForm">
In Kurse einschreiben</a>
</div>
<div class="card-panel red white-text">
Sie haben noch kein Passwort für diese Anwendung eingerichtet. Sie können Sie weiterhin nutzen, sich aber nur über WueCampus einloggen.
Sie können <a href="@routes.LoginController.changePwForm">hier</a> ein Passwort vergeben.
</div>
}
<hr>
<div class="row">
<div class="col s12">
<a class="btn btn-large waves-effect waves-block @accentColor" href="@routes.HomeController.registerForCoursesForm">
In Kurse einschreiben</a>
</div>
</div>
}
......@@ -67,7 +67,7 @@ create table if not exists flashcards (
id int,
coll_id int,
course_id int,
card_type enum ('Vocable', 'Text', 'Blank', 'Choice') not null default 'Vocable',
card_type enum ('Word', 'Text', 'Blank', 'Choice') not null default 'Word',
front text not null,
front_hint text,
back text not null,
......
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