Web App Design project done with Ruby and Sinatra I need help with. NOT WITH ALL
ID: 3779302 • Letter: W
Question
Web App Design project done with Ruby and Sinatra I need help with. NOT WITH ALL OF IT, JUST 2 PARTS! Below is the project description.
I am doing it using Ruby and Sinatra. I need help with the 2 of points.
How should I implement this?
2ND
In my main.rb file I have implemented it so that when they put their username and password they are redirected to either instructor.erb or student.erb depending on ther roles. I just don't know what I need to put in the both those views files (instructor.erb and student.erb). How do I display the websites from the previous point and create a voting system?
Any help is appreciated!! Thank You!!!
Recall an earlier assignment has extra credit for the best submissions. You will build a web site that will allow for students to view and rate (first, second, and third) of the various student submitted web sites. Your web app, must store usernames and passwords in an SQL database The passwords must be salted and hashed. There needs to be at least 2 roles one for students allowing them to vote, and one for instructors/tas. There must be a way to upload a list (CSV) of users, their passwords, and roles. Your web app should allow each student to vote once and only once. The instructor/ta is able to upload as a large zip file the websites for the students. They instructorita is able to view a report of the voting. The report should clearly indicate who voted and how they voted. The instructor/ta should be able to download the voting report as a CSV file. All input from the client needs to be sanitized and validated on the server. NOTE: you are not required to sanitize and validate the data coming from the database. For the voting, the order of the websites should be randomized when displayed for students. You will need to use sessions to ensure that users log in You are also required to have an option for logging out. You are required to use Bootstrap for styling your web app.Explanation / Answer
PART I:
------
require 'rubygems'
require 'sinatra'
require 'haml'
# This part will Handle GET-request and will Show the upload form
get "/upload" do
haml :upload
end
# This part will Handle POST-request and will Receive and save the uploaded file
post "/upload" do
File.open('uploads/' + params['myfile'][:filename], "w") do |f|
f.write(params['myfile'][:tempfile].read)
end
return "The file has been successfully uploaded!"
end
Example :
{
"myfile" => {
:type => "file/zip",
:head => "Content-Disposition: form-data;
name="myfile";
filename="example.zip"
Content-Type: file/zip ",
:name => "myfile",
:tempfile => #<File:/u01/folders/4n/4sd/-Tmp-/RackTestpart201-1332-nfw1-0>,
:filename=>"example.zip"
}
}
PART II:
------
instructor.erb:
---------------
<h1>Welcome Instructors/ta</h1>
<form action="/success" method="POST"> //form actions
<label for="name">Name: </label>
<input type="text" name="name" />
<BR>
<label for="email">E-mail: </label>
<input type="text" name="email" />
<BR>
<label for="type">Student or Instructors/ta? </label>
<input type="text" name="type" />
<BR>
<label for="Facebook">Facebook Name: </label>
<input type="text" name="Facebook" />
<BR>
<label for="Instagram">Instagram Name: </label>
<input type="text" name="Instagram" />
<BR>
<input type="submit" />
</form>
student.erb:
---------------
<h1>Welcome Students</h1>
<form action="/success" method="POST"> //form actions
<label for="name">Name: </label>
<input type="text" name="name" />
<BR>
<label for="email">E-mail: </label>
<input type="text" name="email" />
<BR>
<label for="type">Student or Instructor/ta? </label>
<input type="text" name="type" />
<BR>
<label for="Facebook">Facebook Name: </label>
<input type="text" name="Facebook" />
<BR>
<label for="Instagram">Instagram Name: </label>
<input type="text" name="Instagram" />
<BR>
<input type="submit" />
</form>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.