Update
This commit is contained in:
parent
a9fcab7add
commit
76ab5cbc87
|
@ -3,7 +3,11 @@ name = "auth"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
[profile.release]
|
||||||
|
codegen-units = 1
|
||||||
|
lto = "fat"
|
||||||
|
strip = true
|
||||||
|
panic = "abort"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "4.3.0"
|
actix-web = "4.3.0"
|
||||||
|
|
|
@ -60,7 +60,7 @@ COPY --from=public /usr/src/public/dist ./public
|
||||||
COPY --from=templates-html /usr/src/templates/html ./templates/html
|
COPY --from=templates-html /usr/src/templates/html ./templates/html
|
||||||
COPY ./src ./src
|
COPY ./src ./src
|
||||||
RUN if [ "${BUILD_ENV}" = "development" ]; then \
|
RUN if [ "${BUILD_ENV}" = "development" ]; then \
|
||||||
make dev; \
|
make dev && \
|
||||||
ldd bin/backend | tr -s '[:blank:]' '\n' | grep '^/' | \
|
ldd bin/backend | tr -s '[:blank:]' '\n' | grep '^/' | \
|
||||||
xargs -I % sh -c 'mkdir -p $(dirname deps%); cp % deps%;'; \
|
xargs -I % sh -c 'mkdir -p $(dirname deps%); cp % deps%;'; \
|
||||||
else \
|
else \
|
||||||
|
|
|
@ -193,7 +193,6 @@ module Backend
|
||||||
# teacher_role_count = Db::User.query.where(role: Db::UserRole::Teacher).count
|
# teacher_role_count = Db::User.query.where(role: Db::UserRole::Teacher).count
|
||||||
# raise Errors::TeachersNotRegistered.new if teacher_role_count != Db::Teacher.query.count || teacher_role_count.zero?
|
# raise Errors::TeachersNotRegistered.new if teacher_role_count != Db::Teacher.query.count || teacher_role_count.zero?
|
||||||
|
|
||||||
pp! config = Db::Config.query.select(:can_vote).where { active }.first!
|
|
||||||
raise Errors::VotingNotAllowed.new unless Db::Config.query.select(:can_vote).where { active }.first!.can_vote
|
raise Errors::VotingNotAllowed.new unless Db::Config.query.select(:can_vote).where { active }.first!.can_vote
|
||||||
|
|
||||||
input.teacher_ids.each do |id|
|
input.teacher_ids.each do |id|
|
||||||
|
|
|
@ -94,7 +94,8 @@ module Backend
|
||||||
best : {assignment: Hash(Int32, Assignment), priority_score: Int64, teacher_score: Int64}? = nil
|
best : {assignment: Hash(Int32, Assignment), priority_score: Int64, teacher_score: Int64}? = nil
|
||||||
empty_assignment_count = Hash.zip(teachers.map(&.id), [0] * teachers.size)
|
empty_assignment_count = Hash.zip(teachers.map(&.id), [0] * teachers.size)
|
||||||
p! "Starting assignment"
|
p! "Starting assignment"
|
||||||
Backend.config.assignment_possibility_count.times.each do
|
i = 0
|
||||||
|
while i < Backend.config.assignment_possibility_count
|
||||||
assignment = {} of Int32 => Assignment
|
assignment = {} of Int32 => Assignment
|
||||||
assignment_count = empty_assignment_count.clone
|
assignment_count = empty_assignment_count.clone
|
||||||
votes_a.shuffle(Random::Secure).each do |s, tvs|
|
votes_a.shuffle(Random::Secure).each do |s, tvs|
|
||||||
|
@ -112,6 +113,8 @@ module Backend
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
next if assignment.size != student_count
|
||||||
|
|
||||||
priority_score = 0_i64
|
priority_score = 0_i64
|
||||||
assignment.each do |_, a|
|
assignment.each do |_, a|
|
||||||
priority_score += a[:priority] ** 2
|
priority_score += a[:priority] ** 2
|
||||||
|
@ -146,7 +149,7 @@ module Backend
|
||||||
active: true,
|
active: true,
|
||||||
priority_score: best.not_nil![:priority_score],
|
priority_score: best.not_nil![:priority_score],
|
||||||
teacher_score: best.not_nil![:teacher_score],
|
teacher_score: best.not_nil![:teacher_score],
|
||||||
})
|
}).id
|
||||||
Db::StudentAssignment.import(
|
Db::StudentAssignment.import(
|
||||||
best.not_nil![:assignment].map do |s, a|
|
best.not_nil![:assignment].map do |s, a|
|
||||||
Db::StudentAssignment.new({
|
Db::StudentAssignment.new({
|
||||||
|
|
|
@ -90,6 +90,7 @@ services:
|
||||||
BACKEND_AUTH_URL: "http://auth/v1"
|
BACKEND_AUTH_URL: "http://auth/v1"
|
||||||
volumes:
|
volumes:
|
||||||
- /etc/timezone:/etc/timezone:ro
|
- /etc/timezone:/etc/timezone:ro
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
- ./data/static:/static
|
- ./data/static:/static
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
|
|
|
@ -138,6 +138,7 @@ impl Component for StudentVote {
|
||||||
self.fetching = false;
|
self.fetching = false;
|
||||||
self.errors = errors;
|
self.errors = errors;
|
||||||
self.teachers = teachers;
|
self.teachers = teachers;
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Msg::RadioSelect { priority, teacher } => {
|
Msg::RadioSelect { priority, teacher } => {
|
||||||
|
@ -168,8 +169,6 @@ impl Component for StudentVote {
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
// log::debug!("{:?}", response.data.unwrap().create_vote.unwrap());
|
|
||||||
log::debug!("{:?}", response);
|
|
||||||
|
|
||||||
Msg::Vote(graphql::convert(response.errors))
|
Msg::Vote(graphql::convert(response.errors))
|
||||||
});
|
});
|
||||||
|
@ -239,37 +238,40 @@ impl Component for StudentVote {
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
<>
|
<>
|
||||||
<fieldset>
|
<fieldset class={classes!("fieldset")}>
|
||||||
<legend>{ format!("{}. Wahl", i + 1) }</legend>
|
<legend>{ format!("{}. Wahl", i + 1) }</legend>
|
||||||
|
<div class={classes!("control")}>
|
||||||
|
{
|
||||||
|
for self.teachers.iter().enumerate().filter_map(|(j, t)| {
|
||||||
|
let checked = curr_t == Some(&Some(t.id));
|
||||||
|
|
||||||
{
|
if teachers.contains(&t.id) && !checked {
|
||||||
for self.teachers.iter().enumerate().filter_map(|(j, t)| {
|
None
|
||||||
let checked = curr_t == Some(&Some(t.id));
|
} else {
|
||||||
|
let id = format!("{}_{}", name, j);
|
||||||
|
let teacher_id = t.id;
|
||||||
|
let onchange = ctx.link().callback(move |_| Msg::RadioSelect { priority: i, teacher: teacher_id });
|
||||||
|
|
||||||
if teachers.contains(&t.id) && !checked {
|
Some(html! {
|
||||||
None
|
<>
|
||||||
} else {
|
<label class={classes!("radio")} key={id}>
|
||||||
let id = format!("{}_{}", name, j);
|
<input
|
||||||
let teacher_id = t.id;
|
type="radio"
|
||||||
let onchange = ctx.link().callback(move |_| Msg::RadioSelect { priority: i, teacher: teacher_id });
|
name={name.to_owned()}
|
||||||
|
value={t.user.name.to_owned()}
|
||||||
Some(html! {
|
required=true
|
||||||
<div>
|
{onchange}
|
||||||
<input
|
{checked}
|
||||||
type="radio"
|
/>
|
||||||
id={id.to_owned()}
|
{ &t.user.name }
|
||||||
name={name.to_owned()}
|
</label>
|
||||||
value={t.user.name.to_owned()}
|
<br />
|
||||||
required=true
|
</>
|
||||||
{onchange}
|
})
|
||||||
{checked}
|
}
|
||||||
/>
|
|
||||||
<label for={id}>{ &t.user.name }</label>
|
|
||||||
</div>
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
</div>
|
||||||
}
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
if i < self.slots - 1 {
|
if i < self.slots - 1 {
|
||||||
<br />
|
<br />
|
||||||
|
@ -278,28 +280,44 @@ impl Component for StudentVote {
|
||||||
}
|
}
|
||||||
}) }
|
}) }
|
||||||
|
|
||||||
<div>
|
<div class={classes!("field", "has-addons")}>
|
||||||
<button
|
<div class={classes!("control")}>
|
||||||
onclick={ctx.link().callback(|e: MouseEvent| {
|
<button
|
||||||
e.prevent_default();
|
onclick={ctx.link().callback(|e: MouseEvent| {
|
||||||
Msg::AddSlot
|
e.prevent_default();
|
||||||
})}
|
Msg::RemoveSlot
|
||||||
>
|
})}
|
||||||
{ "+" }
|
>
|
||||||
</button>
|
<span class={classes!("icon", "is-small")}>
|
||||||
<button
|
<i class={classes!("fa-solid", "fa-minus")} />
|
||||||
onclick={ctx.link().callback(|e: MouseEvent| {
|
</span>
|
||||||
e.prevent_default();
|
</button>
|
||||||
Msg::RemoveSlot
|
</div>
|
||||||
})}
|
<div class={classes!("control")}>
|
||||||
>
|
<button
|
||||||
{ "-" }
|
onclick={ctx.link().callback(|e: MouseEvent| {
|
||||||
</button>
|
e.prevent_default();
|
||||||
|
Msg::AddSlot
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<span class={classes!("icon", "is-small")}>
|
||||||
|
<i class={classes!("fa-solid", "fa-plus")} />
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div class={classes!("field", "is-grouped")}>
|
||||||
<input type="submit" value="Submit" />
|
<div class={classes!("control")}>
|
||||||
<input type="reset" value="Reset" onclick={ctx.link().callback(|_| Msg::Reset)} />
|
<button class={classes!("button", "is-link")} type="submit">
|
||||||
|
{ "Submit" }
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class={classes!("control")}>
|
||||||
|
<button class={classes!("button")} type="reset" onclick={ctx.link().callback(|_| Msg::Reset)}>
|
||||||
|
{ "Reset" }
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<components::graphql_errors::GraphQLErrors errors={self.errors.clone()} />
|
<components::graphql_errors::GraphQLErrors errors={self.errors.clone()} />
|
||||||
|
|
Loading…
Reference in a new issue