-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CSS for courses new and edit page, user model testcases
- Loading branch information
1 parent
19642ae
commit c6dc030
Showing
7 changed files
with
252 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,7 @@ def create | |
end | ||
end | ||
else | ||
edirect_to unauthorized_url | ||
redirect_to unauthorized_url | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +0,0 @@ | ||
<%= form_for(@course) do |f| %> | ||
<% if @course.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@course.errors.count, "error") %> prohibited this course from being saved:</h2> | ||
|
||
<ul> | ||
<% @course.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :title %><br> | ||
<%= f.text_area :title %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :description %><br> | ||
<%= f.text_area :description %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :start_date %><br> | ||
<%= f.date_select :start_date %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :end_date %><br> | ||
<%= f.date_select :end_date %> | ||
</div> | ||
<div class="field"> | ||
|
||
<%= f.label :user_id %><br> | ||
<% users_array = User.all.map{|user| [user.name,user.id] if user.utype =="instructor"} %> | ||
<%= f.select(:user_id) do %> | ||
<% users_array.each do |u| -%> | ||
<% if u!=nil %> | ||
<%=content_tag(:option, u.first, value: u.last) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
|
||
<!-- <%= options_from_collection_for_select(User.all, :id, :name) %> | ||
<%= f.text_field :user_id %> --> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :status %><br> | ||
<%= f.text_field :status %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% end %> | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,60 @@ | ||
<h1>Editing Course</h1> | ||
<% provide(:title, 'Edit ' + @course.title + ' details') %> | ||
|
||
<%= render 'form' %> | ||
<div class="container" style="height:80vh; overflow:auto"> | ||
<div class = "center"> | ||
<h1>Edit course</h1> | ||
</div> | ||
|
||
<%= link_to 'Show', @course %> | | ||
<%= link_to 'Back', courses_path %> | ||
|
||
<div class="row"> | ||
<div class="col-md-6 col-md-offset-3"> | ||
<% if @course.errors.any? %> | ||
<div id="error_explanation"> | ||
<div class="alert alert-danger"> | ||
The form contains <%= pluralize(@course.errors.count, "error") %>. | ||
<ul> | ||
<% @course.errors.full_messages.each do |error_msg| %> | ||
<li><%= error_msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
</div> | ||
<% end %> | ||
<%= form_for(@course) do |f| %> | ||
<%= f.label :title, "Title" %> | ||
<%= f.text_field :title, class:'form-control' %> | ||
<%= f.label :description, "Description" %> | ||
<%= f.text_area :description, class:'form-control' %> | ||
<%= f.label :start_date, "Start date" %> | ||
<%= f.date_select :start_date, { :order => [:year, :month, :day], :prompt => { year: 'Select year', day:'Select day', month:'Select month' }}, {class: "form-control"} %> | ||
<%= f.label :end_date, "End date" %> | ||
<%= f.date_select :end_date, { :order => [:year, :month, :day], :prompt => { year: 'Select year', day:'Select day', month:'Select month' }}, {class: "form-control"} %> | ||
<%= f.label :user_id, "Instructor" %><br> | ||
<% users_array = User.all.map{|user| [user.name, user.id] if user.utype =="instructor"} %> | ||
<%= f.select(:user_id, {}, {}, {class:'form-control'}) do %> | ||
<% users_array.each do |user| %> | ||
<% if user != nil %> | ||
<%= content_tag(:option, user.first, value: user.last) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<%= f.select(:status, {}, {}, {class:'form-control'}) do %> | ||
<%=content_tag(:option, "Inactive", value: "Inactive") %> | ||
<%=content_tag(:option, "Active", value: "Active") %> | ||
<% end %> | ||
<%= f.submit "Edit course", class: "btn btn-primary" %> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,60 @@ | ||
<% provide(:title, 'Add a course') %> | ||
<div class = "center"> | ||
<h1>Add a course</h1> | ||
</div> | ||
|
||
|
||
<div class="row"> | ||
<div class="col-md-6 col-md-offset-3"> | ||
<% if @course.errors.any? %> | ||
<div id="error_explanation"> | ||
<div class="alert alert-danger"> | ||
The form contains <%= pluralize(@course.errors.count, "error") %>. | ||
<ul> | ||
<% @course.errors.full_messages.each do |error_msg| %> | ||
<li><%= error_msg %></li> | ||
<% end %> | ||
</ul> | ||
<div class="container" style="height:80vh; overflow:auto"> | ||
<div class = "center"> | ||
<h1>Add a course</h1> | ||
</div> | ||
|
||
|
||
<div class="row"> | ||
<div class="col-md-6 col-md-offset-3"> | ||
<% if @course.errors.any? %> | ||
<div id="error_explanation"> | ||
<div class="alert alert-danger"> | ||
The form contains <%= pluralize(@course.errors.count, "error") %>. | ||
<ul> | ||
<% @course.errors.full_messages.each do |error_msg| %> | ||
<li><%= error_msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
<%= form_for(@course) do |f| %> | ||
<%= form_for(@course) do |f| %> | ||
<%= f.label :title, "Title" %> | ||
<%= f.text_field :title, class:'form-control' %> | ||
<%= f.label :title, "Title" %> | ||
<%= f.text_field :title, class:'form-control' %> | ||
<%= f.label :description, "Description" %> | ||
<%= f.text_area :description, class:'form-control' %> | ||
<%= f.label :description, "Description" %> | ||
<%= f.text_area :description, class:'form-control' %> | ||
<%= f.label :start_date, "Start date" %> | ||
<%= f.date_select :start_date, { :order => [:year, :month, :day], :prompt => { year: 'Select year', day:'Select day', month:'Select month' }}, {class: "form-control"} %> | ||
<%= f.label :start_date, "Start date" %> | ||
<%= f.date_select :start_date, { :order => [:year, :month, :day], :prompt => { year: 'Select year', day:'Select day', month:'Select month' }}, {class: "form-control"} %> | ||
<%= f.label :end_date, "End date" %> | ||
<%= f.date_select :end_date, { :order => [:year, :month, :day], :prompt => { year: 'Select year', day:'Select day', month:'Select month' }}, {class: "form-control"} %> | ||
<%= f.label :end_date, "End date" %> | ||
<%= f.date_select :end_date, { :order => [:year, :month, :day], :prompt => { year: 'Select year', day:'Select day', month:'Select month' }}, {class: "form-control"} %> | ||
<%= f.label :user_id, "Instructor" %><br> | ||
<% users_array = User.all.map{|user| [user.name, user.id] if user.utype =="instructor"} %> | ||
<%= f.select(:user_id, {}, {}, {class:'form-control'}) do %> | ||
<% users_array.each do |user| %> | ||
<% if user != nil %> | ||
<%= content_tag(:option, user.first, value: user.last) %> | ||
<%= f.label :user_id, "Instructor" %><br> | ||
<% users_array = User.all.map{|user| [user.name, user.id] if user.utype =="instructor"} %> | ||
<%= f.select(:user_id, {}, {}, {class:'form-control'}) do %> | ||
<% users_array.each do |user| %> | ||
<% if user != nil %> | ||
<%= content_tag(:option, user.first, value: user.last) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<%= f.label :status, "Status" %><br> | ||
|
||
<%= f.select(:status, {}, {}, {class:'form-control'}) do %> | ||
<%=content_tag(:option, "Inactive", value: "Inactive") %> | ||
<%=content_tag(:option, "Active", value: "Active") %> | ||
<% end %> | ||
<%= f.submit "Create course", class: "btn btn-primary" %> | ||
<% end %> | ||
|
||
</div> | ||
</div> | ||
<%= f.label :status, "Status" %><br> | ||
|
||
<%= f.select(:status, {}, {}, {class:'form-control'}) do %> | ||
<%=content_tag(:option, "Inactive", value: "Inactive") %> | ||
<%=content_tag(:option, "Active", value: "Active") %> | ||
<% end %> | ||
<%= f.submit "Create course", class: "btn btn-primary" %> | ||
<% end %> | ||
|
||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.