Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C3 fadel 211 remove helping hints 4.21 #307

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tutor/app/assets/javascripts/hints.js.coffee
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/
3 changes: 3 additions & 0 deletions tutor/app/assets/javascripts/tips.js.coffee
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/
27 changes: 27 additions & 0 deletions tutor/app/assets/stylesheets/hints.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Place all the styles related to the Hints controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
thk,tdj{
overflow: hidden;
width: 500px;
height: 50px;
display: block;

}
td{
//height: 70px;
width: 20px;
}
.achievements-wrapper { table-layout:fixed; }
.the-table {
table-layout: fixed;
word-wrap: break-word;
}
.myWidth { max-width: 20px; }
.concat div { overflow: hidden; -ms-text-overflow: ellipsis; -o-text-overflow: ellipsis; text-overflow: ellipsis; white-space: nowrap; width: inherit; }
//overflow: auto;
//"table table-condensed table-striped"
.the-table {
table-layout: fixed;
word-wrap: break-word;
}
7 changes: 7 additions & 0 deletions tutor/app/assets/stylesheets/tips.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Place all the styles related to the Tips controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
td{
//height: 70px;
width: 20px;
}
78 changes: 78 additions & 0 deletions tutor/app/controllers/hints_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
class HintsController < ApplicationController

@@answer_id = nil

# [View hints and tips-Story 4.22]
# It fetches from database all the previous hints.
# Parameters:
# @hints: All the previous hints that had been entered before.
# @hints_check: All the previous hints that had been entered before to check if it is a hint or a tip.
# Return : table with all previous hints
# Author: Nadine Adel
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fadel1493 You can't make a pull request of other peoples' methods. Apply this to the rest of the file.

def index

@hints = Hint.all
@hints_check=Hint.all
end
def new
@answer = ModelAnswer.find(params[:model_answer_id])
@@answer_id = params[:model_answer_id]
end

# [Adding Helping Hints - 4.12]
# Creates a new record to Hint Table
# Parameters:
# owner_id: ID of the hint owner
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fadel1493 Please use just one tab, not a space and a tab. Apply this to the rest of the file.

# owner type: type of hint owner
# category: states whether it is a hint or tip
# Returns: Redirects to edit page on success, refreshes on failure
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fadel1493 Place this: "Redirects to edit page on success, refreshes on failure" in a new line preceded by a tab. Apply this to the rest of the file.

# Author: Mohamed Fadel
def create
p = Hint.new(permitCreate)
if lecturer_signed_in?
p.owner_id = current_lecturer.id
p.owner_type = "lecturer"
p.category = false
p.model_answer_id = @@answer_id
else
p.owner_id = current_teaching_assistant.id
p.owner_type = "teaching_assistant"
p.category = false
p.model_answer_id = @@answer_id
end

if p.save
redirect_to :controller => 'model_answers', :action => 'edit', :id => @@answer_id
else
flash.keep[:notice] = "Hint is missing paramaters"
redirect_to :back
end
end

# [Adding Helping Hints - 4.12]
# Passes the input of the form as paramaters for create action to use it
# Parameters:
# submission_counter: hint's submission counter
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fadel1493 Use a tabs, not spaces. Apply this to the rest of the file.

# message: hint's message
# Returns: params to create action
# Author: Mohamed Fadel
def permitCreate
params.require(:Hint).permit(:submission_counter, :message)
end

# [Delete a Hint - Story 4.21]
# This action takes the hint id, remove it from the database
# and then redirects the user to the edit page accompanied
# with a "Hint deleted" message.
# Parameters:
# params[:id]: The current hint's id
# Returns:
# none
# Author: Mohamed Fadel
def destroy
hint = Hint.find_by_id(params[:id])
hint.destroy
flash[:success_deletion] = "Hint deleted."
redirect_to :controller => 'model_answers', :action => 'edit', :id => @@answer_id
end
end
13 changes: 13 additions & 0 deletions tutor/app/controllers/tips_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class TipsController < ApplicationController
# [View hints and tips]
# It fetches from database all the previous tips.
# Parameters:
# @tips: All the previous tips that had been entered before.
# @tips_check:All the previous tips that had been entered before to check if it is a tip or hint.
# Return : none
# Author: Nadine Adel
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fadel1493 You cannot merge other peoples' code.

def new
@tips= Hint.all
@tips_check =Hint.all
end
end
2 changes: 2 additions & 0 deletions tutor/app/helpers/hints_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module HintsHelper
end
2 changes: 2 additions & 0 deletions tutor/app/helpers/tips_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module TipsHelper
end
7 changes: 7 additions & 0 deletions tutor/app/views/hints/_index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--Add delete button to the edit view in model answers
Author: Mohamed Fadel-->

<th style = "width:20%">Delete</th>

<td><%= button_to "Delete", {controller: :hints, action: :destroy, id: hint1.id},
:method => :delete, class: 'btn btn-primary btn-xs' %></td>
2 changes: 2 additions & 0 deletions tutor/app/views/hints/create.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Hints#create</h1>
<p>Find me in app/views/hints/create.html.erb</p>
2 changes: 2 additions & 0 deletions tutor/app/views/hints/destroy.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Hints#destroy</h1>
<p>Find me in app/views/hints/destroy.html.erb</p>
2 changes: 2 additions & 0 deletions tutor/app/views/hints/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Hints#edit</h1>
<p>Find me in app/views/hints/edit.html.erb</p>
21 changes: 21 additions & 0 deletions tutor/app/views/hints/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<h1 align ="center">Add a Hint</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 :Hint, url: {action: "create"} do |p| %>
<p>
<%= p.label :submission_counter %><br>
<%= p.text_field :submission_counter %>
</p>
<p>
<%= p.label :message %><br>
<%= p.text_area :message , :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 %>
25 changes: 25 additions & 0 deletions tutor/app/views/hints/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<h1 align ="center">Add a Hint</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 :Hint, url: {action: "create"} do |p| %>
<p>
<%= p.label :category %><br>
<%= p.text_field :category %>
</p>
<p>
<%= p.label :submission_counter %><br>
<%= p.text_field :submission_counter %>
</p>
<p>
<%= p.label :message %><br>
<%= p.text_area :message , :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 %>
28 changes: 14 additions & 14 deletions tutor/app/views/model_answers/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<h1>Previous Answers</h1>
<!--<h1>Previous Answers</h1>
<!--Nadine:a view in which there is a loop to fetch fom database all previous answers.-->
<table>
<tr>
<th>Title</th>
<th>Text</th>
</tr>
<% @answers.each do |answer1| %>
<tr>
<td><%= answer1.answer %></td>
<td><%= answer1.answer %></td>
</tr>
<% end %>
</table>
<!--<table>
<tr>
<th>Title</th>
<th>Text</th>
</tr>
<% @answers.each do |answer1| %>
<tr>
<td><%= answer1.answer %></td>
<td><%= answer1.answer %></td>
</tr>
<% end %>
</table>

73 changes: 73 additions & 0 deletions tutor/app/views/model_answers/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<%= form_for :model_answer, url: model_answers_path do |f| %>
<!--Nadine:form to display textarea where the answer should be written and show the previous answers in a table.-->

<%= flash[:notice]%>
<!--kkdk-->

<!--Nadine:a view in which there is a loop to fetch fom database all previous answers.-->
<p>

<h2>Please Insert your model answer</h2>
<%= f.text_area :answer %>

</p>


<p>

<%= f.submit class: "btn btn-primary" %>

</p>
<body>
<script type="text/javascript">

function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}

</script>
</body>

<a href="#" onclick="toggle_visibility('foo');"><h2><li>Previous Answers</li></h2></a>
<div id="foo" style="display:none;">


<table class="table table-striped">

<thead>
<tr>
<th style="width: 30%">Title</th>
<th style="width: 20%">View or Edit</th>
</tr>
</thead>
<tbody>

<tr>
<% @answers.each do |answer1| %>
<td><%= answer1.answer %></td>
<td><%= button_to "View or Edit" , {:action => 'new', :controller => 'tips',:method => :post} , {
class: 'btn btn-primary btn-xs' } %></td>
</tr>

</tbody>
<% end %>
</table>



</div>





<!--dd-->




<% end %>
5 changes: 4 additions & 1 deletion tutor/app/views/model_answers/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h1>Listing posts</h1>
<%= form_for :model_answer, url: model_answers_path do |f| %>
<h1>Edit Your Ans</h1>
<h2>Title</h2>

<table>
<tr>
<th>Text</th>
Expand Down
1 change: 1 addition & 0 deletions tutor/app/views/problems/_timer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var time;
var timer_is_on=0;

function timer(){
@time = min +":" + digit;
digit++;

if(digit>59){
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions tutor/app/views/tips/create.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Tips#create</h1>
<p>Find me in app/views/tips/create.html.erb</p>
2 changes: 2 additions & 0 deletions tutor/app/views/tips/destroy.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Tips#destroy</h1>
<p>Find me in app/views/tips/destroy.html.erb</p>
2 changes: 2 additions & 0 deletions tutor/app/views/tips/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Tips#edit</h1>
<p>Find me in app/views/tips/edit.html.erb</p>
Loading