Skip to content

Commit

Permalink
Issue alaashafaee#470, profile progress view
Browse files Browse the repository at this point in the history
  • Loading branch information
Rania Abdel Fattah authored and Rania Abdel Fattah committed May 10, 2014
1 parent 8d69a78 commit 6bf8670
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 86 deletions.
83 changes: 0 additions & 83 deletions tutor/app/controllers/solutions_constraints_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,90 +30,7 @@ def show
@methods = MethodConstraint.find_by_id(params[:id])
end

# [Edit Solutions' Constraints - Story 4.14]
# Display only one record for the method parameter and the variable constraint and
# the method constraint
# Parameters:
# params[:id]: The method parameter and the variable constraint and the method variable
# Returns:
# @parameters: one record of the methods parameters
# @variables: one record of the variables constraints
# @methods: one record of the methods constraints
# Author: Rania Abdel Fattah
def edit
if lecturer_signed_in? || teaching_assistant_signed_in?
@parameters = MethodParameter.find_by_id(params[:id])
@variables = VariableConstraint.find_by_id(params[:id])
@methods = MethodConstraint.find_by_id(params[:id])
end
end

# [Edit Solutions' Constraints - Story 4.14]
# Update the given record
# Parameters:
# params[:id]: The method parameter and the variable constraint and the method variable
# Returns:
# @parameters: one record of the methods parameters
# @variables: one record of the variables constraints
# @methods: one record of the methods constraints
# => Author: Rania Abdel Fattah
def update
@parameters = MethodParameter.find_by_id(params[:id])
@variables = VariableConstraint.find_by_id(params[:id])
@methods = MethodConstraint.find_by_id(params[:id])
if @parameters && @variables && @methods
@parameters.parameter = constraint_params[:parameters]
@variables.variable_name = constraint_params[:variables]
@methods.method_name = constraint_params[:methods]
@parameters.save
@variables.save
@methods.save
flash[:notice] = "Constraints updated"
redirect_to :action => 'show'
else
redirect_to :action => 'index'
end
end

# [Remove Solution Constraint - Story 4.19]
# Display only one record for the method parameter and the variable constraint and
# the method constraint
# Parameters:
# params[:id]: The method parameter and the variable constraint and the method variable
# Returns:
# @parameters: one record of the methods parameters
# @variables: one record of the variables constraints
# @methods: one record of the methods constraints
# Author: Rania Abdel Fattah
def destroy_methods
parameters = MethodParameter.find_by_id(params[:id])
methods = MethodConstraint.find_by_id(params[:id])

if parameters && methods
parameters = MethodParameter.find_by_id(params[:id]).destroy
methods = MethodConstraint.find_by_id(params[:id]).destroy
flash[:notice] = "deleted"
redirect_to :action => 'index'
else
flash[:error] = "not"
redirect_to :back
end
end

def destroy_methods

variables = VariableConstraint.find_by_id(params[:id])
if variables
variables = VariableConstraint.find_by_id(params[:id]).destroy

flash[:notice] = "deleted"
redirect_to :action => 'index'
else
flash[:error] = "not"
redirect_to :back
end
end

# [Add Solutions' constraints - Story 4.14]
# Description: Creates new record for either method or variable constraints
# Parameters:
Expand Down
1 change: 0 additions & 1 deletion tutor/app/controllers/students_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ def show
@student = Student.find(params[:id])
@courses = @student.courses.order("created_at desc")
end

end
42 changes: 40 additions & 2 deletions tutor/app/views/students/_show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
<%= render 'layouts/profile' %>
<li class = "active"><a href = "#tab1">Info</a></li>
<li><a href = "#tab2">Performance</a></li>
<li class="dropdown">
<a class="dropdown-toggle"
data-toggle="dropdown"
href="#tab2">
Performance
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<!-- links -->
<li><a href="#">contest</a></li>
<li><a href="#">course</a></li>
<li><a href="#">assig</a></li>
</ul>
</li>
<!--<li><a href = "#tab2">Performance</a></li>-->
<li><a href = "#tab3">Statistics</a></li>
</ul>
<div class = "tab-content">
Expand All @@ -13,7 +27,31 @@
<p><b>Joined on: </b><%= current_student.created_at.to_date %></p>
</div>
<div id = "tab2" class = "tab">
Performance under construction
<!--Performance under construction-->
<div>
<h2 align="center">Continue from where you left off</h2><br>
<% next_problems_to_solve = current_student.get_next_problems_to_solve %>
<% if next_problems_to_solve != nil then %>
<% next_problems_to_solve.each do |key , value| %>
<%= key %>
<%= link_to value.title,
controller: "/problems",
action: "show",
id: value.id %>
<% end %>
</div><br>
<h2 align="center">Your Progress</h2>
<table class = "table table-striped">
<tr>
<th>Topic</th>
<th>Track</th>
<th>Problem</th>
</tr>
</table>
<ul class="pager">
<li><a href="#">Previous</a></li>
<li><a href="#">Next</a></li>
</ul>
</div>
<div id = "tab3" class = "tab">
Statistics under construction
Expand Down
Binary file modified tutor/db/development.sqlite3
Binary file not shown.

0 comments on commit 6bf8670

Please sign in to comment.