Skip to content

Commit

Permalink
feat: submission page, submission to contest
Browse files Browse the repository at this point in the history
  • Loading branch information
Asrani-Aman committed Jul 28, 2024
1 parent 5316fff commit f3c2853
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 4 deletions.
11 changes: 10 additions & 1 deletion app/assets/stylesheets/contests.scss
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,13 @@
color: white;
box-shadow: 0 0 5px 0px #0000004d;
}
}
}
.project-submission {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px;
background: #f9fffc;
border: 1px solid #42b983;
margin-bottom: 1rem;
}
17 changes: 17 additions & 0 deletions app/controllers/contests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ def create
end
end

# GET /contests/new_submission
def new_submission
@projects = current_user.projects
@contest = Contest.find(params[:id])
@submission = Submission.new
end

# POST /contests/:id/create_submission
def create_submission
@submission = Submission.new
@submission.project_id = params[:submission][:project_id]
@submission.contest_id = params[:contest_id]
if @submission.save
redirect_to contest_page_path(params[:contest_id]), notice: "Submission was successfully added."
end
end

private

def authorize_admin
Expand Down
4 changes: 2 additions & 2 deletions app/views/contests/_view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
<div class="modal-body">
<div class="embed-responsive embed-responsive-4by3 feature feature-preview users-iframe-container">
<iframe src="/uploads/project/image_preview/5/preview_1663047671939863.jpeg" id="projectPreview" scrolling="no" webkitAllowFullScreen mozAllowFullScreen allowFullScreen> </iframe>
<iframe src=<%= simulator_path(project) %> id="view" webkitAllowFullScreen mozAllowFullScreen allowFullScreen scrolling="no"></iframe>
</div>
</div>
<div class="modal-footer">
Expand All @@ -16,4 +16,4 @@
</div>
</div>
</div>
</div>s
</div>
30 changes: 30 additions & 0 deletions app/views/contests/new_submission.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<div class="container projects-new-container">
<div class="">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 center-row">
<h1 class="submain-heading">Project Submission</h1>
<h2 class="submain-heading assignments-submain-heading">Contest #<%= @contest.id %></h2>
</div>
<div class="contest-page-line"></div>
<div>
<h5>Select your circuit</h5>
</div>
<div>
<%= form_with(model: Submission.new, url: create_submission_path, local: true) do |form| %>
<% @projects.each do |project| %>
<div class="project-submission">
<div class="project-submission-detail">
<%= form.radio_button :project_id, project.id %>
<i class="fas fa-code-branch ml-2"></i>
<strong><span><%= project.author.name %> / <%= project.name %></span></strong>
</div>
<div>
<%= link_to t("view"), user_project_path(project.author_id, project), class: "btn primary-button", id: "project-more-button", target: "_blank" %>
</div>
</div>
<% end %>
<%= hidden_field_tag "contest_id", @contest.id %>
<%= form.submit "Submit", class: "btn primary-button" %>
<% end %>
</div>
</div>
</div>
4 changes: 3 additions & 1 deletion app/views/contests/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
<% if @contest.status == 'Live' %>
<div class="d-flex flex-column align-items-center">
<span class="contest-header-timer">Time Left: <span id="timeLeftCounter">...</span></span>
<button class="contest-submission-button">Register your circuit</button>
<%= link_to new_submission_path(@contest.id), class: "contest-submission-button" do %>
<span>Register your circuit</span>
<% end %>
</div>
<% else %>
<div class="d-flex flex-column align-items-center">
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@
get "/contests/:id", to: "contests#show", as: "contest_page"
post "/contests/host", to: "contests#create", as: "new_contest"
put "/contests/:id/close", to: "contests#close_contest", as: "close_contest"
get "/contests/:id/new_submission", to: "contests#new_submission", as: "new_submission"
post "/contests/:id/create_submission", to: "contests#create_submission", as: "create_submission"

# lti
scope "lti" do
Expand Down

0 comments on commit f3c2853

Please sign in to comment.