-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from alaashafaee/C4_Husseny_201_add_problem_4.4
Issue #201 Add problems by tas
- Loading branch information
Showing
10 changed files
with
143 additions
and
2 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the problems_by_tas controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class ProblemsByTasController < ApplicationController | ||
# [Add Problem - 4.4] | ||
# Creates a new record to Problem Table | ||
# Parameters: | ||
# title: problem's title through permitCreate action | ||
# description: problem's description through permitCreate action | ||
# Returns: Redirects to edit page on success, refreshes on failure | ||
# Author: Abdullrahman Elhusseny | ||
def create | ||
p = Problem.new(permitCreate) | ||
if p.save | ||
redirect_to :action => "edit", :id => p.id | ||
else | ||
flash.keep[:notice] = "Problem are missing paramaters" | ||
redirect_to :back | ||
end | ||
end | ||
# [Add Problem - 4.4] | ||
# Passes the input of the form as paramaters for create action to use it | ||
# Parameters: | ||
# title: problem's title | ||
# description: problem's description | ||
# Returns: params to create action | ||
# Author: Abdullrahman Elhusseny | ||
def permitCreate | ||
params.require(:Problem).permit(:title , :description) | ||
end | ||
# [Edit Problem - 4.5] | ||
# Shows the problem's title and description (Further development is in Sprint 1) | ||
# Parameters: | ||
# id: The id of the problem to be edited or newly created | ||
# Returns: Redirects to edit page on success, refreshes on failure | ||
# Author: Abdullrahman Elhusseny | ||
def edit | ||
@problem = Problem.find_by_id(params[:id]) | ||
end | ||
def new | ||
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ProblemsByTasHelper | ||
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- The html web page consists of two tags | ||
a header to view the problem title of the instance variable @problem | ||
and a paragraph to view the problem description of the instance variable @problem --> | ||
<h2 align ="center"><%= @problem.title %></h2> | ||
<p><%= @problem.description %></p> |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<h1 align ="center">Edit Problem Page</h1> | ||
|
||
<br> | ||
<!--A form that takes the input for the model Problem and calls the action create | ||
through two text fields :title and description --> | ||
<%= form_for :Problem, url: {action: "create"} do |p| %> | ||
<p> | ||
<%= p.label :title %><br> | ||
<%= p.text_field :title %> | ||
</p> | ||
|
||
<p> | ||
<%= p.label :description %><br> | ||
<%= p.text_area :description , :cols => "50", :rows => "10" %> | ||
</p> | ||
|
||
<p> | ||
<%= p.submit %> | ||
</p> | ||
<% end %> | ||
<!-- A division for the flash message output to view the action's output --> | ||
<% if flash[:notice] %> | ||
<div class="notice"><%= flash[:notice] %></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