limit heavy class features to reaonably sized classes
This commit is contained in:
parent
f577e39ba8
commit
0a5875221f
|
@ -127,8 +127,10 @@ final class Clas(
|
||||||
|
|
||||||
def notifyStudents(id: String) = Secure(_.Teacher) { implicit ctx => me =>
|
def notifyStudents(id: String) = Secure(_.Teacher) { implicit ctx => me =>
|
||||||
WithClass(me, id) { clas =>
|
WithClass(me, id) { clas =>
|
||||||
env.clas.api.student.activeWithUsers(clas) map { students =>
|
env.clas.api.student.activeWithUsers(clas) flatMap { students =>
|
||||||
Ok(html.clas.clas.notify(clas, students, env.clas.forms.clas.notifyText))
|
Reasonable(clas, students, "notify") {
|
||||||
|
Ok(html.clas.clas.notify(clas, students, env.clas.forms.clas.notifyText)).fuccess
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,11 +146,13 @@ final class Clas(
|
||||||
},
|
},
|
||||||
text =>
|
text =>
|
||||||
env.clas.api.student.activeWithUsers(clas) flatMap { students =>
|
env.clas.api.student.activeWithUsers(clas) flatMap { students =>
|
||||||
val url = routes.Clas.show(clas.id.value).url
|
Reasonable(clas, students, "notify") {
|
||||||
val full = if (text contains url) text else s"$text\n\n${env.net.baseUrl}$url"
|
val url = routes.Clas.show(clas.id.value).url
|
||||||
env.msg.api.multiPost(me, students.map(_.user.id), full)
|
val full = if (text contains url) text else s"$text\n\n${env.net.baseUrl}$url"
|
||||||
} inject
|
env.msg.api.multiPost(me, students.map(_.user.id), full) inject
|
||||||
Redirect(routes.Clas.show(clas.id.value)).flashSuccess
|
Redirect(routes.Clas.show(clas.id.value)).flashSuccess
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,8 +169,10 @@ final class Clas(
|
||||||
lila.rating.PerfType(key) ?? { perfType =>
|
lila.rating.PerfType(key) ?? { perfType =>
|
||||||
WithClass(me, id) { clas =>
|
WithClass(me, id) { clas =>
|
||||||
env.clas.api.student.activeWithUsers(clas) flatMap { students =>
|
env.clas.api.student.activeWithUsers(clas) flatMap { students =>
|
||||||
env.clas.progressApi(perfType, days, students) map { progress =>
|
Reasonable(clas, students, "progress") {
|
||||||
views.html.clas.teacherDashboard.progress(clas, students, progress)
|
env.clas.progressApi(perfType, days, students) map { progress =>
|
||||||
|
views.html.clas.teacherDashboard.progress(clas, students, progress)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,6 +412,12 @@ final class Clas(
|
||||||
Redirect("https://forms.gle/b19pDZZuotncxtbRA")
|
Redirect("https://forms.gle/b19pDZZuotncxtbRA")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def Reasonable(clas: lila.clas.Clas, students: List[lila.clas.Student.WithUser], active: String)(
|
||||||
|
f: => Fu[Result]
|
||||||
|
)(implicit ctx: Context): Fu[Result] =
|
||||||
|
if (students.size <= lila.clas.Clas.maxStudents) f
|
||||||
|
else Unauthorized(views.html.clas.teacherDashboard.unreasonable(clas, students, active)).fuccess
|
||||||
|
|
||||||
private def WithClass(me: lila.user.User, clasId: String)(
|
private def WithClass(me: lila.user.User, clasId: String)(
|
||||||
f: lila.clas.Clas => Fu[Result]
|
f: lila.clas.Clas => Fu[Result]
|
||||||
): Fu[Result] =
|
): Fu[Result] =
|
||||||
|
|
|
@ -6,7 +6,7 @@ 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 }
|
||||||
|
|
||||||
private object bits {
|
object bits {
|
||||||
|
|
||||||
def layout(
|
def layout(
|
||||||
title: String,
|
title: String,
|
||||||
|
|
|
@ -80,6 +80,22 @@ object teacherDashboard {
|
||||||
studentList(c, archived)
|
studentList(c, archived)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def unreasonable(c: Clas, students: List[Student.WithUser], active: String)(implicit ctx: Context) =
|
||||||
|
layout(c, students, active)(
|
||||||
|
div(cls := "box__pad students__empty")(
|
||||||
|
p(
|
||||||
|
"This feature is only available for classes of ",
|
||||||
|
lila.clas.Clas.maxStudents,
|
||||||
|
" or fewer students."
|
||||||
|
),
|
||||||
|
p(
|
||||||
|
"This class has ",
|
||||||
|
students.size,
|
||||||
|
" students. You could maybe create more classes to split the students."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def progress(
|
def progress(
|
||||||
c: Clas,
|
c: Clas,
|
||||||
students: List[Student.WithUser],
|
students: List[Student.WithUser],
|
||||||
|
|
Loading…
Reference in a new issue