Skip to content

Commit

Permalink
Fix incorrect times and info
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondburned committed Mar 18, 2024
1 parent b1ad3ab commit 195f234
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 12 deletions.
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
},
"hackathon": {
"start_time": "2024-03-20T00:15:00-08:00",
"duration": "150m"
"duration": "150m",
"location": "EC 063"
},
"open_registration_time": "2024-03-17T00:00:00-08:00"
}
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type ProblemModule struct {
type HackathonConfig struct {
StartTime time.Time `json:"start_time"`
Duration Duration `json:"duration"`
Location string `json:"location"`
}

func (c HackathonConfig) EndTime() time.Time {
Expand Down
2 changes: 2 additions & 0 deletions server/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/Masterminds/sprig/v3"
"github.com/dustin/go-humanize"
"github.com/yuin/goldmark"
"libdb.so/tmplutil"
)
Expand Down Expand Up @@ -65,6 +66,7 @@ func NewTemplater(fs fs.FS) *tmplutil.Templater {
int(d.Seconds())%60)
}
},
"ordinal": humanize.Ordinal,
},
),
}
Expand Down
10 changes: 8 additions & 2 deletions server/frontend/pages/hackathon.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@
<hgroup>
<h1>Mini Hackathon</h1>
<p>
<b>Think</b>, <b>create</b> and <b>present</b> at this mini hackathon geared towards
beginners
{{ .StartTime.Format "Monday, January" }}
{{ .StartTime.Day | ordinal }}
in
{{ .Location }}
</p>
</hgroup>

<section>
<p>
<b>Think</b>, <b>create</b> and <b>present</b> at this mini Hackathon geared towards
beginners.
</p>
<p><strong>Move quickly, you've only got 2 hours!</strong></p>
</section>

Expand Down
14 changes: 12 additions & 2 deletions server/frontend/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ <h2>Getting Started</h2>
<section class="compete">
<hgroup>
<h2>Week of Code</h2>
<p>Monday, February 19th until 23rd</p>
<p>
{{ .Problems.StartedAt.Format "Monday, January" }}
{{ .Problems.StartedAt.Day | ordinal }}
until the
{{ .Problems.EndingAt.Day | ordinal }}
</p>
</hgroup>
<p>
A week of coding challenges designed and curated by ACM to promote good problem-solving
Expand All @@ -58,7 +63,12 @@ <h2>Week of Code</h2>
<section>
<hgroup>
<h2>Mini Hackathon</h2>
<p>Monday, February 23rd at ??? in CS ???</p>
<p>
{{ .HackathonConfig.StartTime.Format "Monday, January" }}
{{ .HackathonConfig.StartTime.Day | ordinal }}
in
{{ .HackathonConfig.Location }}
</p>
</hgroup>

<p>
Expand Down
18 changes: 13 additions & 5 deletions server/frontend/pages/problems.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@
<article>
<hgroup>
<h2>Week of Code</h2>
<p>A new coding problem every day</p>
<p>
{{ .Problems.StartedAt.Format "Monday, January" }}
{{ .Problems.StartedAt.Day | ordinal }}
until the
{{ .Problems.EndingAt.Day | ordinal }}
</p>
</hgroup>

<p>
Completing at least one part each day will result in a
<mark>1337</mark> score bonus for your team!
</p>
<section>
<p>A new coding problem every day!</p>
<p>
You may get more points for solving problems <b>as soon as they are released</b>, so keep an
eye out for the next problem!
</p>
</section>

{{ if not (eq .Problems.TotalProblems 1) }}
<ul class="problems">
Expand Down
9 changes: 9 additions & 0 deletions server/problem/problemset.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ func (p *ProblemSet) StartedAt() time.Time {
return p.schedule.StartReleaseAt
}

// EndingAt returns the time at which the last problem is released. If the
// problem set does not have a release schedule, it returns the zero time.
func (p *ProblemSet) EndingAt() time.Time {
if p.schedule == nil {
return time.Time{}
}
return p.schedule.StartReleaseAt.Add(time.Duration(len(p.problems)) * p.schedule.ReleaseEvery)
}

// Problems returns all available problems in the set.
func (p *ProblemSet) Problems() []Problem {
return p.problems[:p.AvailableProblems()]
Expand Down
8 changes: 6 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ func writeError(w http.ResponseWriter, code int, err error) {

type indexPageData struct {
frontend.ComponentContext
InviteCode string
Problems *problem.ProblemSet
HackathonConfig config.HackathonConfig
InviteCode string
}

func (s *Server) index(w http.ResponseWriter, r *http.Request) {
Expand All @@ -130,7 +132,9 @@ func (s *Server) index(w http.ResponseWriter, r *http.Request) {
TeamName: u.TeamName,
Username: u.Username,
},
InviteCode: inviteCode,
Problems: s.problems,
HackathonConfig: s.config.HackathonConfig,
InviteCode: inviteCode,
})
}

Expand Down

0 comments on commit 195f234

Please sign in to comment.