Skip to content

Commit

Permalink
Issue #466 editing assignments view
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohab authored and Mohab committed May 17, 2014
1 parent 272287c commit 5f684ab
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 120 deletions.
44 changes: 43 additions & 1 deletion tutor/app/assets/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
padding-top: 20px;
}
.content_container{
background-color: #FAFAFA;

}
.profile_picture {
width:200px;
Expand Down Expand Up @@ -165,4 +165,46 @@

.sign_in_button {
margin-right: 20px;
}

.left-box{
margin: -30px -15px -15px;
}

.xob {
padding: 0px 20px 20px;
margin-top: 20px;
margin-bottom: 20px;
border-radius: 5px;
background-color: #FAFAFA;

}

.xox {
background-color: #FAFAFA;
border-radius: 5px;
}

.topic-box .well {
max-width: 400px;
max-height: 260px;
min-width: 400px;
min-height: 260px;
overflow-y: auto;
}

.box-title {
font-size: 2em;
color: #808080;
margin-bottom: 30px;
margin-top: 15px;
font-weight: lighter;
border-bottom: solid 0.5px #D2D3D4;
padding-bottom: 10px;
}

.box-title .btn {
float: right;
height: 40px;
text-align: center;
}
13 changes: 13 additions & 0 deletions tutor/app/helpers/courses_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
module CoursesHelper

def crop (string, length)
s = string
i = length
if s.length > i
while s[i] != ' '
i -= 1
end
else
return s
end
return s.slice(0, i) + '...'
end
end
264 changes: 146 additions & 118 deletions tutor/app/views/courses/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,146 +1,174 @@
<div class = "course_info panel-body" >
<div class= "row course_title">
<div class="course_code"><%= @course.code %></div>
<div class="course_name"><%= @course.name %></div>
<% if current_lecturer %>
<div class="course_manage">
<%= link_to "Manage", { :controller => 'courses', :action => 'edit',
:method => :get, :id => params[:id] }, class: "" %>
<div class= "left-box" >
<div class="xob">
<div class = "course_info panel-body" >
<div class= "row course_title">
<div class="course_code"><%= @course.code %></div>
<div class="course_name"><%= @course.name %></div>
<% if current_lecturer %>
<div class="course_manage">
<%= link_to "Manage", { :controller => 'courses', :action => 'edit',
:method => :get, :id => params[:id] }, class: "" %>
</div>
<% end %>
</div>
<% end %>
</div>
<div class="row">
<div class="course_sem">
Semester <%= @course.semester %>
Class <%= @course.year %>
<div class="row">
<div class="course_sem">
Semester <%= @course.semester %>
Class <%= @course.year %>
</div>
</div>
</div>
<div class="row course_description">
<p>About the Course</p>
<div class="description-body" ><%= @course.description %> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
<div class="view_discussion">
<%= link_to "View Discussion Board", { :controller => 'discussion_boards', :action => 'show', :id => params[:id] }, method: :get %>
</div>
</div>
</div>
<div class="row course_description">
<p>About the Course</p>
<div class="description-body" ><%= @course.description %> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
<div class="view_discussion">
<%= link_to "View Discussion Board", { :controller => 'discussion_boards', :action => 'show', :id => params[:id] }, method: :get %>
</div>

<div class="well">
<% topics = @course.topics %>
<% if topics.any? %>
<% topics.each_slice(2) do |topic| %>
<% if topic.count == 1 %>
<div class="row">
<div class="container col-sm-6 box-bag topic-box">
<div class="well" style="background-color: #d7dde2 !important;">
<h3><b><%= link_to topic[0].title, topic[0]%></b><hr></h3>
<label><%= topic[0].description %></label><br><br>
<% if lecturer_signed_in? || teaching_assistant_signed_in? %>
<%= link_to "Delete Topic", {controller: "topics",
action: "destroy", :id => topic[0].id},
class: "btn btn-danger btn-xs", method: :delete %>
<% end %>
</div>
</div>
</div>
<% else %>
<div class="row">
<% topics.each do |topic| %>
<div class="container col-sm-6 topic-box">
<div class="well" style="background-color: #d7dde2 !important;">
<h3><b><%= link_to topic.title, topic %></b><hr></h3>
<label><%= topic.description %></label><br><br>
<% if lecturer_signed_in? || teaching_assistant_signed_in? %>
<%= link_to "Delete Topic", {controller: "topics",
action: "destroy", :id => topic.id},
class: "btn btn-danger btn-xs", method: :delete %>
<% end %>
</div>
</div>
<%end%>
</div>
<% end %>
<% end %>
<% end %>
</div>


<div class="well">
<% assignments = @course.assignments %>
<% if assignments.any? %>
<% if @can_edit %>
<% assignments.each_slice(2) do |assignment| %>
<% if assignment.count == 1 %>
<div class="xox">
<div class="well bell">
<div class="box-title"> Topics
<% if lecturer_signed_in? || teaching_assistant_signed_in? %>
<%= link_to "Add Topic", {:controller => 'topics', :action => 'new',
:course_id => @course.id}, class: "btn btn-default", method: :post %>
<% end %>
</div>
<% topics = @course.topics %>
<% if topics.any? %>
<% topics.each_slice(2) do |topic| %>
<% if topic.count == 1 %>
<div class="row">
<div class="container col-sm-6 box-bag topic-box">
<div class="well" style="background-color: #d7dde2 !important;">
<h3><b><%= link_to assignment[0].title, assignment[0]%></b><hr></h3>
<label><%= assignment[0].description %></label><br><br>
<% if @can_edit %>
<% if !assignment[0] .publish %>
<span class="badge">unpublished</span>
<% end %>
<h3><b><%= link_to topic[0].title, topic[0]%></b><hr></h3>
<% if topic[0].description %>
<label><%= crop(topic[0].description, 150) %></label><br><br>
<% end %>
<% if lecturer_signed_in? || teaching_assistant_signed_in? %>
<%= link_to "Delete Topic", {controller: "topics",
action: "destroy", :id => topic[0].id},
class: "btn btn-danger btn-xs", method: :delete %>
<% end %>
</div>
</div>
</div>
<% else %>
<div class="row">
<% assignment.each do |assignment| %>
<% topics.each do |topic| %>
<div class="container col-sm-6 topic-box">
<div class="well" style="background-color: #d7dde2 !important;">
<h3><b><%= link_to assignment.title, assignment %></b><hr></h3>
<label><%= assignment.description %></label><br><br>
<% if @can_edit %>
<% if !assignment.publish %>
<span class="badge">unpublished</span>
<% end %>
<h3><b><%= link_to topic.title, topic %></b><hr></h3>
<% if topic.description %>
<label><%= crop(topic.description,150) %></label><br><br>
<% end %>

<% if lecturer_signed_in? || teaching_assistant_signed_in? %>
<%= link_to "Delete Topic", {controller: "topics",
action: "destroy", :id => topic.id},
class: "btn btn-danger btn-xs", method: :delete %>
<% end %>
</div>
</div>
<%end%>
</div>
<% end %>
<% end %>
<% else %>
<% assignments.each_slice(2) do |assignment| %>
<% if assignment.count == 1 %>
<div class="row">
<div class="container col-sm-6 box-bag topic-box">
<div class="well" style="background-color: #d7dde2 !important;">
<h3><b><%= link_to assignment[0].title, assignment[0]%></b><hr></h3>
<label><%= assignment[0].description %></label><br><br>
<% if @can_edit %>
<% if !assignment[0].publish %>
<span class="badge">unpublished</span>
<% end %>
<% end %>
</div>
</div>
</div>
<% else %>
<div class="row">
<% assignment.each do |assignment| %>
<div class="container col-sm-6 topic-box">
<div class="well" style="background-color: #d7dde2 !important;">
<h3><b><%= link_to assignment.title, assignment %></b><hr></h3>
<% if assignment.publish %>
<%= link_to assignment.title, assignment %>
<% if assignment.due_date > DateTime.now.to_date %>
<span class="badge">Due</span>
<% end %>
</div>
</div>

<div class="xox">
<div class="well bell">
<div class="box-title"> Assignments
<% if lecturer_signed_in? || teaching_assistant_signed_in? %>
<div class="btn btn-default"> Create Assignment</div>
<% end %>
</div>
<% assignments = @course.assignments %>
<% if assignments.any? %>
<% if @can_edit %>
<% assignments.each_slice(2) do |assignment| %>
<% if assignment.count == 1 %>
<div class="row">
<div class="container col-sm-6 box-bag topic-box">
<div class="well" style="background-color: #d7dde2 !important;">
<h3><b><%= link_to assignment[0].title, assignment[0]%></b><hr></h3>
<% if assignment[0].description %>
<label><%= crop(assignment[0].description,150) %></label><br><br>
<% end %>
<% if @can_edit %>
<% if !assignment[0].publish %>
<span class="badge">unpublished</span>
<% end %>
<% end %>
</div>
</div>
</div>
<% else %>
<div class="row">
<% assignment.each do |assignment| %>
<div class="container col-sm-6 topic-box">
<div class="well" style="background-color: #d7dde2 !important;">
<h3><b><%= link_to assignment.title, assignment %></b><hr></h3>
<% if assignment.description %>
<label><%= assignment.description %></label><br><br>
<% end %>
<% if @can_edit %>
<% if !assignment.publish %>
<span class="badge">unpublished</span>
<% end %>
<% end %>

</div>
</div>
<%end%>
</div>
<% end %>
<% end %>
<% else %>
<% assignments.each_slice(2) do |assignment| %>
<% if assignment.count == 1 %>
<div class="row">
<div class="container col-sm-6 box-bag topic-box">
<div class="well" style="background-color: #d7dde2 !important;">
<h3><b><%= link_to assignment[0].title, assignment[0]%></b><hr></h3>
<% if assignment[0].description %>
<label><%= assignment[0].description %></label><br><br>
<% end %>
<% end %>
<% if @can_edit %>
<% if !assignment[0].publish %>
<span class="badge">unpublished</span>
<% end %>
<% end %>
</div>
</div>
</div>
<%end%>
</div>
<% else %>
<div class="row">
<% assignment.each do |assignment| %>
<div class="container col-sm-6 topic-box">
<div class="well" style="background-color: #d7dde2 !important;">
<h3><b><%= link_to assignment.title, assignment %></b><hr></h3>
<% if assignment.publish %>
<%= link_to assignment.title, assignment %>
<% if assignment.due_date > DateTime.now.to_date %>
<span class="badge">Due</span>
<% end %>
<% end %>
</div>
</div>
<%end%>
</div>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion tutor/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<div class="container cont">
<% if signed_in? %>
<div class="col-md-10 left_side">
<div class="container content_container" style="width: 100% !important;">
<div class="container" style="width: 100% !important;">
<%= yield %>
</div>
</div>
Expand Down

0 comments on commit 5f684ab

Please sign in to comment.