improve class student dashboard
This commit is contained in:
parent
1cd41801ea
commit
0769a7b446
|
@ -60,11 +60,13 @@ final class Clas(
|
||||||
case _ =>
|
case _ =>
|
||||||
env.clas.api.clas.byId(lila.clas.Clas.Id(id)) flatMap {
|
env.clas.api.clas.byId(lila.clas.Clas.Id(id)) flatMap {
|
||||||
_ ?? { clas =>
|
_ ?? { clas =>
|
||||||
env.clas.api.student.activeWithUsers(clas) flatMap { students =>
|
env.clas.api.teacher.of(clas) flatMap { teachers =>
|
||||||
if (students.exists(_.student is me)) {
|
env.clas.api.student.activeWithUsers(clas) flatMap { students =>
|
||||||
preloadStudentUsers(students)
|
if (students.exists(_.student is me)) {
|
||||||
Ok(views.html.clas.studentDashboard(clas, students)).fuccess
|
preloadStudentUsers(students)
|
||||||
} else notFound
|
Ok(views.html.clas.studentDashboard(clas, teachers, students)).fuccess
|
||||||
|
} else notFound
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,14 @@ import controllers.routes
|
||||||
import lila.api.Context
|
import lila.api.Context
|
||||||
import lila.app.templating.Environment._
|
import lila.app.templating.Environment._
|
||||||
import lila.app.ui.ScalatagsTemplate._
|
import lila.app.ui.ScalatagsTemplate._
|
||||||
import lila.clas.{ Clas, Student }
|
import lila.clas.{ Clas, Student, Teacher }
|
||||||
import lila.common.String.html.richText
|
import lila.common.String.html.richText
|
||||||
|
|
||||||
object studentDashboard {
|
object studentDashboard {
|
||||||
|
|
||||||
def apply(
|
def apply(
|
||||||
c: Clas,
|
c: Clas,
|
||||||
|
teachers: List[Teacher.WithUser],
|
||||||
students: List[Student.WithUser]
|
students: List[Student.WithUser]
|
||||||
)(implicit ctx: Context) =
|
)(implicit ctx: Context) =
|
||||||
bits.layout(c.name, Left(c withStudents Nil))(
|
bits.layout(c.name, Left(c withStudents Nil))(
|
||||||
|
@ -18,12 +19,43 @@ object studentDashboard {
|
||||||
div(cls := "box__top")(
|
div(cls := "box__top")(
|
||||||
h1(dataIcon := "f", cls := "text")(c.name)
|
h1(dataIcon := "f", cls := "text")(c.name)
|
||||||
),
|
),
|
||||||
div(cls := "box__pad")(
|
c.archived map { archived =>
|
||||||
c.desc.nonEmpty option div(cls := "clas-desc")(richText(c.desc)),
|
div(cls := "box__pad")(
|
||||||
c.archived map { archived =>
|
|
||||||
div(cls := "clas-show__archived archived")(bits.showArchived(archived))
|
div(cls := "clas-show__archived archived")(bits.showArchived(archived))
|
||||||
},
|
)
|
||||||
clas.teachers(c)
|
},
|
||||||
|
c.desc.trim.nonEmpty option div(cls := "clas-show__overview")(richText(c.desc)),
|
||||||
|
table(cls := "slist slist-pad teachers")(
|
||||||
|
thead(
|
||||||
|
tr(
|
||||||
|
th("Teachers"),
|
||||||
|
th,
|
||||||
|
th
|
||||||
|
)
|
||||||
|
),
|
||||||
|
tbody(
|
||||||
|
teachers.map {
|
||||||
|
case Teacher.WithUser(_, user) =>
|
||||||
|
tr(
|
||||||
|
td(
|
||||||
|
userLink(
|
||||||
|
user,
|
||||||
|
name = span(
|
||||||
|
strong(user.username),
|
||||||
|
user.profile.flatMap(_.nonEmptyRealName) map { em(_) }
|
||||||
|
).some,
|
||||||
|
withTitle = false
|
||||||
|
)
|
||||||
|
),
|
||||||
|
td(
|
||||||
|
user.seenAt.map { seen =>
|
||||||
|
trans.lastSeenActive(momentFromNow(seen))
|
||||||
|
}
|
||||||
|
),
|
||||||
|
challengeTd(user)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
),
|
),
|
||||||
div(cls := "students")(studentList(students))
|
div(cls := "students")(studentList(students))
|
||||||
)
|
)
|
||||||
|
@ -55,16 +87,19 @@ object studentDashboard {
|
||||||
td(cls := "rating")(user.best3Perfs.map { showPerfRating(user, _) }),
|
td(cls := "rating")(user.best3Perfs.map { showPerfRating(user, _) }),
|
||||||
td(user.count.game.localize),
|
td(user.count.game.localize),
|
||||||
td(user.perfs.puzzle.nb.localize),
|
td(user.perfs.puzzle.nb.localize),
|
||||||
td(
|
challengeTd(user)
|
||||||
a(
|
|
||||||
dataIcon := "U",
|
|
||||||
cls := "button button-empty",
|
|
||||||
title := trans.challengeToPlay.txt(),
|
|
||||||
href := s"${routes.Lobby.home()}?user=${user.username}#friend"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private def challengeTd(user: lila.user.User)(implicit ctx: Context) =
|
||||||
|
td(
|
||||||
|
a(
|
||||||
|
dataIcon := "U",
|
||||||
|
cls := "button button-empty",
|
||||||
|
title := trans.challengeToPlay.txt(),
|
||||||
|
href := s"${routes.Lobby.home()}?user=${user.username}#friend"
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,18 @@ final class ClasApi(
|
||||||
coll.insert.one(teacher) inject Teacher.WithUser(teacher, user)
|
coll.insert.one(teacher) inject Teacher.WithUser(teacher, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
// def of(clas: Clas): Fu[List[Teacher]] =
|
def of(clas: Clas): Fu[List[Teacher.WithUser]] =
|
||||||
// coll.ext.byOrderedIds[Teacher, Teacher.Id](clas.teacherIds)(_.id)
|
coll.ext.byOrderedIds[Teacher, Teacher.Id](clas.teachers.toList)(_.id) flatMap withUsers
|
||||||
|
|
||||||
|
def withUsers(teachers: List[Teacher]): Fu[List[Teacher.WithUser]] =
|
||||||
|
userRepo.coll.idsMap[User, User.ID](
|
||||||
|
teachers.map(_.userId),
|
||||||
|
ReadPreference.secondaryPreferred
|
||||||
|
)(_.id) map { users =>
|
||||||
|
teachers.flatMap { s =>
|
||||||
|
users.get(s.userId) map { Teacher.WithUser(s, _) }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object clas {
|
object clas {
|
||||||
|
|
|
@ -91,9 +91,6 @@ $clas-color: rgb(127, 90, 240);
|
||||||
&__overview {
|
&__overview {
|
||||||
@extend %box-padding;
|
@extend %box-padding;
|
||||||
background: $c-bg-zebra;
|
background: $c-bg-zebra;
|
||||||
.clas-desc {
|
|
||||||
margin-bottom: 2em;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__archived {
|
&__archived {
|
||||||
|
@ -113,10 +110,13 @@ $clas-color: rgb(127, 90, 240);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.students {
|
.students, .teachers {
|
||||||
th:first-child {
|
th:first-child {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.button {
|
||||||
|
font-size: 1.2em;
|
||||||
|
}
|
||||||
.user-link {
|
.user-link {
|
||||||
@extend %flex-center;
|
@extend %flex-center;
|
||||||
span {
|
span {
|
||||||
|
@ -130,6 +130,8 @@ $clas-color: rgb(127, 90, 240);
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
.students {
|
||||||
.rating {
|
.rating {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
span {
|
span {
|
||||||
|
@ -142,15 +144,17 @@ $clas-color: rgb(127, 90, 240);
|
||||||
}
|
}
|
||||||
|
|
||||||
&-student {
|
&-student {
|
||||||
.students {
|
.teachers {
|
||||||
.button {
|
margin-bottom: 2em;
|
||||||
font-size: 1.2em;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-teacher {
|
&-teacher {
|
||||||
|
|
||||||
|
.clas-desc {
|
||||||
|
margin-bottom: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
.progress {
|
.progress {
|
||||||
@extend %box-padding;
|
@extend %box-padding;
|
||||||
background: $c-bg-zebra;
|
background: $c-bg-zebra;
|
||||||
|
|
Loading…
Reference in a new issue