From 92a4b6ce49e331bedceb56d12ded1eb68699d1e8 Mon Sep 17 00:00:00 2001 From: Nadine Adel Date: Thu, 17 Apr 2014 15:00:26 +0200 Subject: [PATCH 01/17] created a view --- tutor/app/assets/javascripts/hints.js.coffee | 3 + tutor/app/assets/javascripts/tips.js.coffee | 3 + tutor/app/assets/stylesheets/hints.css.scss | 27 +++++++ tutor/app/assets/stylesheets/tips.css.scss | 7 ++ tutor/app/controllers/hints_controller.rb | 16 ++++ tutor/app/controllers/tips_controller.rb | 8 ++ tutor/app/helpers/hints_helper.rb | 2 + tutor/app/helpers/tips_helper.rb | 2 + tutor/app/views/hints/create.html.erb | 2 + tutor/app/views/hints/destroy.html.erb | 2 + tutor/app/views/hints/edit.html.erb | 2 + tutor/app/views/hints/new.html.erb | 48 ++++++++++++ tutor/app/views/model_answers/index.html.erb | 28 +++---- tutor/app/views/model_answers/new.html.erb | 78 ++++++++++++++++--- tutor/app/views/model_answers/show.html.erb | 5 +- tutor/app/views/tips/create.html.erb | 2 + tutor/app/views/tips/destroy.html.erb | 2 + tutor/app/views/tips/edit.html.erb | 2 + tutor/app/views/tips/new.html.erb | 38 +++++++++ tutor/config/routes.rb | 8 ++ tutor/db/seeds.rb | 4 +- .../test/controllers/hints_controller_test.rb | 24 ++++++ .../test/controllers/tips_controller_test.rb | 24 ++++++ tutor/test/helpers/hints_helper_test.rb | 4 + tutor/test/helpers/tips_helper_test.rb | 4 + 25 files changed, 316 insertions(+), 29 deletions(-) create mode 100644 tutor/app/assets/javascripts/hints.js.coffee create mode 100644 tutor/app/assets/javascripts/tips.js.coffee create mode 100644 tutor/app/assets/stylesheets/hints.css.scss create mode 100644 tutor/app/assets/stylesheets/tips.css.scss create mode 100644 tutor/app/controllers/hints_controller.rb create mode 100644 tutor/app/controllers/tips_controller.rb create mode 100644 tutor/app/helpers/hints_helper.rb create mode 100644 tutor/app/helpers/tips_helper.rb create mode 100644 tutor/app/views/hints/create.html.erb create mode 100644 tutor/app/views/hints/destroy.html.erb create mode 100644 tutor/app/views/hints/edit.html.erb create mode 100644 tutor/app/views/hints/new.html.erb create mode 100644 tutor/app/views/tips/create.html.erb create mode 100644 tutor/app/views/tips/destroy.html.erb create mode 100644 tutor/app/views/tips/edit.html.erb create mode 100644 tutor/app/views/tips/new.html.erb create mode 100644 tutor/test/controllers/hints_controller_test.rb create mode 100644 tutor/test/controllers/tips_controller_test.rb create mode 100644 tutor/test/helpers/hints_helper_test.rb create mode 100644 tutor/test/helpers/tips_helper_test.rb diff --git a/tutor/app/assets/javascripts/hints.js.coffee b/tutor/app/assets/javascripts/hints.js.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/tutor/app/assets/javascripts/hints.js.coffee @@ -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/ diff --git a/tutor/app/assets/javascripts/tips.js.coffee b/tutor/app/assets/javascripts/tips.js.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/tutor/app/assets/javascripts/tips.js.coffee @@ -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/ diff --git a/tutor/app/assets/stylesheets/hints.css.scss b/tutor/app/assets/stylesheets/hints.css.scss new file mode 100644 index 00000000..f9ac3584 --- /dev/null +++ b/tutor/app/assets/stylesheets/hints.css.scss @@ -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; +} \ No newline at end of file diff --git a/tutor/app/assets/stylesheets/tips.css.scss b/tutor/app/assets/stylesheets/tips.css.scss new file mode 100644 index 00000000..eb6b85cd --- /dev/null +++ b/tutor/app/assets/stylesheets/tips.css.scss @@ -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; + } diff --git a/tutor/app/controllers/hints_controller.rb b/tutor/app/controllers/hints_controller.rb new file mode 100644 index 00000000..0a792023 --- /dev/null +++ b/tutor/app/controllers/hints_controller.rb @@ -0,0 +1,16 @@ +class HintsController < ApplicationController + def new + @hints = Hint.all + + @hint = Hint.new + end + + def create + end + + def edit + end + + def destroy + end +end diff --git a/tutor/app/controllers/tips_controller.rb b/tutor/app/controllers/tips_controller.rb new file mode 100644 index 00000000..b6ad6400 --- /dev/null +++ b/tutor/app/controllers/tips_controller.rb @@ -0,0 +1,8 @@ +class TipsController < ApplicationController + + def new + @tips= Hint.all + + end + +end \ No newline at end of file diff --git a/tutor/app/helpers/hints_helper.rb b/tutor/app/helpers/hints_helper.rb new file mode 100644 index 00000000..f40a7961 --- /dev/null +++ b/tutor/app/helpers/hints_helper.rb @@ -0,0 +1,2 @@ +module HintsHelper +end diff --git a/tutor/app/helpers/tips_helper.rb b/tutor/app/helpers/tips_helper.rb new file mode 100644 index 00000000..1dc531fd --- /dev/null +++ b/tutor/app/helpers/tips_helper.rb @@ -0,0 +1,2 @@ +module TipsHelper +end diff --git a/tutor/app/views/hints/create.html.erb b/tutor/app/views/hints/create.html.erb new file mode 100644 index 00000000..9620bc60 --- /dev/null +++ b/tutor/app/views/hints/create.html.erb @@ -0,0 +1,2 @@ +

Hints#create

+

Find me in app/views/hints/create.html.erb

diff --git a/tutor/app/views/hints/destroy.html.erb b/tutor/app/views/hints/destroy.html.erb new file mode 100644 index 00000000..9ac37889 --- /dev/null +++ b/tutor/app/views/hints/destroy.html.erb @@ -0,0 +1,2 @@ +

Hints#destroy

+

Find me in app/views/hints/destroy.html.erb

diff --git a/tutor/app/views/hints/edit.html.erb b/tutor/app/views/hints/edit.html.erb new file mode 100644 index 00000000..0535af66 --- /dev/null +++ b/tutor/app/views/hints/edit.html.erb @@ -0,0 +1,2 @@ +

Hints#edit

+

Find me in app/views/hints/edit.html.erb

diff --git a/tutor/app/views/hints/new.html.erb b/tutor/app/views/hints/new.html.erb new file mode 100644 index 00000000..abd7f201 --- /dev/null +++ b/tutor/app/views/hints/new.html.erb @@ -0,0 +1,48 @@ + + + + + + +

  • Previous Hints
  • + diff --git a/tutor/app/views/model_answers/index.html.erb b/tutor/app/views/model_answers/index.html.erb index 6a016e67..529f49e4 100644 --- a/tutor/app/views/model_answers/index.html.erb +++ b/tutor/app/views/model_answers/index.html.erb @@ -1,15 +1,15 @@ -

    Previous Answers

    + - - - - - - - <% @answers.each do |answer1| %> - - - - - <% end %> -
    TitleText
    <%= answer1.answer %><%= answer1.answer %>
    \ No newline at end of file + + <%= flash[:notice]%> - - <% @answers.each do |answer1| %> -
    - - - - <% end %> -
    <%= answer1.answer %>
    + + +

    -

    Please Insert your model answer

    - <%= f.text_area :answer %> + +

    Please Insert your model answer

    +<%= f.text_area :answer %> +

    + +

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

    + + + + +

  • Previous Answers
  • + + + + + + + + + + + <% end %> \ No newline at end of file diff --git a/tutor/app/views/model_answers/show.html.erb b/tutor/app/views/model_answers/show.html.erb index b9a2cc35..47e9d159 100644 --- a/tutor/app/views/model_answers/show.html.erb +++ b/tutor/app/views/model_answers/show.html.erb @@ -1,4 +1,7 @@ -

    Listing posts

    +<%= form_for :model_answer, url: model_answers_path do |f| %> +

    Edit Your Ans

    +

    Title

    + diff --git a/tutor/app/views/tips/create.html.erb b/tutor/app/views/tips/create.html.erb new file mode 100644 index 00000000..538b2b35 --- /dev/null +++ b/tutor/app/views/tips/create.html.erb @@ -0,0 +1,2 @@ +

    Tips#create

    +

    Find me in app/views/tips/create.html.erb

    diff --git a/tutor/app/views/tips/destroy.html.erb b/tutor/app/views/tips/destroy.html.erb new file mode 100644 index 00000000..ae7b3ca4 --- /dev/null +++ b/tutor/app/views/tips/destroy.html.erb @@ -0,0 +1,2 @@ +

    Tips#destroy

    +

    Find me in app/views/tips/destroy.html.erb

    diff --git a/tutor/app/views/tips/edit.html.erb b/tutor/app/views/tips/edit.html.erb new file mode 100644 index 00000000..90207b7a --- /dev/null +++ b/tutor/app/views/tips/edit.html.erb @@ -0,0 +1,2 @@ +

    Tips#edit

    +

    Find me in app/views/tips/edit.html.erb

    diff --git a/tutor/app/views/tips/new.html.erb b/tutor/app/views/tips/new.html.erb new file mode 100644 index 00000000..3fe8401b --- /dev/null +++ b/tutor/app/views/tips/new.html.erb @@ -0,0 +1,38 @@ + + + + + +

  • Previous Tips
  • +
    Text
    + + + + + + + + + + + <% @tips.each do |tip1| %> + <% if tip1.category == true %> + + + + + + <% end %> + <% end %> +
    TitleView or Edit
    <%= tip1.message %><%= button_to "View or Edit" , {:action => 'new', :controller => 'tips',:method => :post}, {class: 'btn btn-primary btn-xs' } %>
    + \ No newline at end of file diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index 32e78ee9..5925be28 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -1,4 +1,12 @@ Tutor::Application.routes.draw do + get "hints/new" + get "hints/create" + get "hints/edit" + get "hints/destroy" + get "tips/new" + get "tips/create" + get "tips/edit" + get "tips/destroy" get 'courses/show' get "model_answers/new" post "model_answers/new" diff --git a/tutor/db/seeds.rb b/tutor/db/seeds.rb index 5b44e317..9945b9ad 100644 --- a/tutor/db/seeds.rb +++ b/tutor/db/seeds.rb @@ -53,8 +53,8 @@ Topic.create(title: "Topic3") puts("# -----------------------Hints---------------------------") -Hint.create(message: "Do not Try to Solve CS problem-1") -Hint.create(message: "Do not Try to Solve CS problem-2") +Hint.create(message: "Do not Try to Solve CS problem-1", type: 0) +Hint.create(message: "Do not Try to Solve CS problem-2", type: 1) Hint.create(message: "Do not Try to Solve CS problem-3") puts("# -----------------------ModelAnswer---------------------------") diff --git a/tutor/test/controllers/hints_controller_test.rb b/tutor/test/controllers/hints_controller_test.rb new file mode 100644 index 00000000..a1d58605 --- /dev/null +++ b/tutor/test/controllers/hints_controller_test.rb @@ -0,0 +1,24 @@ +require 'test_helper' + +class HintsControllerTest < ActionController::TestCase + test "should get new" do + get :new + assert_response :success + end + + test "should get create" do + get :create + assert_response :success + end + + test "should get edit" do + get :edit + assert_response :success + end + + test "should get destroy" do + get :destroy + assert_response :success + end + +end diff --git a/tutor/test/controllers/tips_controller_test.rb b/tutor/test/controllers/tips_controller_test.rb new file mode 100644 index 00000000..0c8519d9 --- /dev/null +++ b/tutor/test/controllers/tips_controller_test.rb @@ -0,0 +1,24 @@ +require 'test_helper' + +class TipsControllerTest < ActionController::TestCase + test "should get new" do + get :new + assert_response :success + end + + test "should get create" do + get :create + assert_response :success + end + + test "should get edit" do + get :edit + assert_response :success + end + + test "should get destroy" do + get :destroy + assert_response :success + end + +end diff --git a/tutor/test/helpers/hints_helper_test.rb b/tutor/test/helpers/hints_helper_test.rb new file mode 100644 index 00000000..1a40f25c --- /dev/null +++ b/tutor/test/helpers/hints_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class HintsHelperTest < ActionView::TestCase +end diff --git a/tutor/test/helpers/tips_helper_test.rb b/tutor/test/helpers/tips_helper_test.rb new file mode 100644 index 00000000..fc90c2c7 --- /dev/null +++ b/tutor/test/helpers/tips_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class TipsHelperTest < ActionView::TestCase +end From c4d26235b9d20059a8c0efd17d4f8d000704a169 Mon Sep 17 00:00:00 2001 From: Nadine Adel Date: Thu, 17 Apr 2014 23:10:26 +0200 Subject: [PATCH 02/17] modification in 'new'view in hints and tips --- tutor/app/views/hints/new.html.erb | 8 ++++---- tutor/app/views/tips/new.html.erb | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tutor/app/views/hints/new.html.erb b/tutor/app/views/hints/new.html.erb index abd7f201..75018285 100644 --- a/tutor/app/views/hints/new.html.erb +++ b/tutor/app/views/hints/new.html.erb @@ -15,13 +15,13 @@

  • Previous Hints
  • + \ No newline at end of file diff --git a/tutor/app/views/tips/new.html.erb b/tutor/app/views/tips/new.html.erb index fbc9387f..454eb443 100644 --- a/tutor/app/views/tips/new.html.erb +++ b/tutor/app/views/tips/new.html.erb @@ -1,4 +1,3 @@ - @@ -15,7 +14,6 @@ \ No newline at end of file From 73a743a0b3c9c3c6e6eb70a326556906d6536ebc Mon Sep 17 00:00:00 2001 From: Nadine Adel Date: Fri, 18 Apr 2014 00:40:03 +0200 Subject: [PATCH 04/17] editing view --- tutor/app/views/hints/new.html.erb | 2 +- tutor/app/views/tips/new.html.erb | 60 +++++++++++++++--------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tutor/app/views/hints/new.html.erb b/tutor/app/views/hints/new.html.erb index 49cb1643..d43c419a 100644 --- a/tutor/app/views/hints/new.html.erb +++ b/tutor/app/views/hints/new.html.erb @@ -27,7 +27,7 @@ <% if hint1.category == false %> <%= hint1.message %> <%= hint1.submission_counter %> - <%= button_to "View or Edit" , {:action => 'new', :controller => 'tips',:method => :post},{class: 'btn btn-primary btn-xs' } %> + <%= button_to "Edit" , {:action => 'new', :controller => 'hints',:method => :post},{class: 'btn btn-primary btn-xs' } %> <% end %> diff --git a/tutor/app/views/tips/new.html.erb b/tutor/app/views/tips/new.html.erb index 454eb443..899067dd 100644 --- a/tutor/app/views/tips/new.html.erb +++ b/tutor/app/views/tips/new.html.erb @@ -1,36 +1,36 @@ - +

  • Previous Tips
  • - + \ No newline at end of file diff --git a/tutor/app/views/tips/new.html.erb b/tutor/app/views/tips/new.html.erb index 899067dd..f7621e5e 100644 --- a/tutor/app/views/tips/new.html.erb +++ b/tutor/app/views/tips/new.html.erb @@ -10,7 +10,7 @@ -

  • Previous Tips
  • + Previous Tips \ No newline at end of file + + + \ No newline at end of file From e00036a96263135dde20e383553652557db8ef0c Mon Sep 17 00:00:00 2001 From: Nadine Adel Date: Sun, 20 Apr 2014 02:15:46 +0200 Subject: [PATCH 07/17] failure scenario --- tutor/app/views/hints/new.html.erb | 2 +- tutor/config/routes.rb | 6 +++--- tutor/db/development.sqlite3 | Bin 200704 -> 204800 bytes 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tutor/app/views/hints/new.html.erb b/tutor/app/views/hints/new.html.erb index a92ab479..68767aab 100644 --- a/tutor/app/views/hints/new.html.erb +++ b/tutor/app/views/hints/new.html.erb @@ -11,7 +11,7 @@ <% @hints1=Array.new %> <% @hints_check.each do |hint2| %> - <% if hint2.category == true %> + <% if hint2.category == false%> <% @hints1.push(hint2) %> <%end%> <%end%> diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index 6cfe65ee..5fe10a2c 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -1,7 +1,7 @@ Tutor::Application.routes.draw do - - resources :hints - resources :tips + + resources :hints + resources :tips get 'courses/show' get "model_answers/new" post "model_answers/new" diff --git a/tutor/db/development.sqlite3 b/tutor/db/development.sqlite3 index 59018a8b757c2c501da5801baaba8e82775923b6..8d91eeb2d76d2b390b29d32bd53a7595e192ddc8 100644 GIT binary patch delta 1517 zcmaJ>ZERCj7(VaY+x6piJ#9DEZEUog6&7Lj_O@di#z;+&g^6^7j;(Cyp!+~Z3+{v9 z#O{FbW1v#6atJ0MqWlnzN|73gX8s^XP(w^)8beGZ8h$K9lqC%C5Yo9*Qs|EBm5Xvp4vo*S6RzV@$Yw+uAoMT| zh`B3hB8oCuO*0!!g27Bd)t%9^s?IW1@dYZCK&7g<6=jJpuq5F3`qiq%O6}}O6lUqN za+Y3w_qOq=-r8DUO_lGSHvb~0Mr7M@dBi4$pKw(;;242pn2$&BHz}e&n{&?4ZFHDC zrZeVYxlsPaay0j$+)LK)#76W(`hx~2k>L6C*I_ULB=~3(yorox>n$hbT~-DL=iIrl zyH|_L@A6B{(1r}PQS-~X5YzEr189NG0WlC*TKig4E&u|IE>7w zeVTJfH^@xHYd2 za>k7olfiV`{I?~MJ7~3AZ)$eii}IclCL5eC7YrM;FJXr^j63;}Ff2@;Z^S;(^)rjM z0{SIZ&T=_K;VooVej*AZ$SCjX$i%j^r4xz)nLWLr3+4#N!5{9131oS^dK3JPEI<9g z(*R(8j?FPROG{x-Jr8V#eR-Q=8{=EH_H^`hl)E>?<2@biF+S9YF8ytkMYXAf(? zfjb&-KoFxoJ=TD$5!qb6bPe_*E8(Zt;1PLG4=Xh|{eBou@KsMi1Ai}!k7d`dZ9=_R zKaaOH<56TT{%13Oh0M)^A$*pvi=df55y7{SmGK)9{0mt*|15+n_)Bdl^SV|Pgujnp XX~m1kJn7SI;x~ot{`7_QSOxz85k-_F delta 2960 zcmaJ@eQXow8NcV=bDVSHya{RI1W02@SfFVx_kBKhqcQm;fjA)_kf3%+90x-ZoA@Ik z=^w_>GHI&)TwS+aH@$V49~&>(I2VU4zCnZPGNYly=glNo#?&YgJ%$?>WVB zLfF~&-1+^z{yiV}eBANNg~wklJiT!PbCzKkiJte5qh}tME9h#&2U~1(jm4i?$k*^4 z{F#%xF#8O~+htALLDyWnsVMheECvzdPZ$ngWbixqANVi$;-!+}^Vn9-A%$Pul3%J6 z0;+;oJTV>&$784vp=y3A7>FmL!Dy_2MVlZHNkn78n4K~@`OL;k|MlD58|=<24E`w| z$F8E^7R?uJcV3~?KXWFB?GC1)l7&*n=WCA!gOl!_(BY{_EOIn7e>60uiIV-A%{S02 zi;~(PstuCvmNYN@s=8o^qG4(eNBnsXrqZ>{y>~Poax2qRD)wur{XSumGHPx~q;y`@ z6jYC?8Y_$sAYC>GQ&zgn*xct<0P4D5-JdOuID05-i4A;fu z1;yaBlzxiOkBH}vvUyw?gUe_-7vN+n1TJP9RmU(^*lJQ%>4DEzUA^b4GI96MMS4Ol zYdkZ(q9N#}u849L(cPl#RSmB!3c6xyx*VU2G|^KCM5b%y(OOBY)jW~NO#8e)+7tB0 z_Duzb+xiYP&I{7Q*n$z?+qT#2mco1IW+oC-(a}SRU@UfIeELWix4sIGsVQp^tI`Bb z^=OJgK1#9`+${#*qM`XGt}a3~e2ziOk-y8}yVP-p*+4h_8>jES!sZu0wgFye;B~f! z{R#Ueci8q$-k2C3aZilQb2ZIS|rs4gh^LjpXe?I1l3D(}h29oG6m)u1%ZZWNa}~@MH431Mn2c zWcv`D28Fya1b+mTyf_RmfJQbSgeB0)zYfCB!C2gHf0=c8$dgaO%U~}4(ssvjqQ+}? zxm@tny)cIcn`LMSazb3!pl?cD9Lg zAm<>1A1yMSgS1dOoXOM(s>;S@`Nrp~%ajXml}k1e4Yy3Yv*MK%!SooazEU5#h^fko zG(l%ilO=L0jaN9BiUzj*GL=$b84#{`N?FSP3*n+Il7uoszK7*_)VZTZrtL+%H9gf!J*S zXn((Fs6_}KnQfbqZCT~3G)Ps7v@%DRUnwL@x#H0@MYVcexdY)P1~1`T_+6T^zre{7 zR0pe443(mKSo1tst1splZ;hTp$Y&s*+sR$9?aLp|zsELD&7jouK5}yt>U5k^Ix}Vaf=SF0G`rFv(zi=c z9}8W?{|Jh~9`fr)(03iDYxvI5P5pL||{ zu0T)vHZD}4WyN|G(_}%D4Mkdco5(?Q zkD|#+xG9{I9D*41wH}KZ$950SL=HDcCpzNYKH=EJn40he4F6Q0a3~_QPWunch7+y+ w!2zFcOm$^*<16x7ORw&cJmyN7uhMHFX_^~V#jqn?+{50?OgJn;L$=rb4<6CaSO5S3 From a423e4ae80f3788772ff0aeb06a8025a2a24d7d3 Mon Sep 17 00:00:00 2001 From: Mohamed Fadel Date: Mon, 21 Apr 2014 00:23:36 +0200 Subject: [PATCH 08/17] Issue #210 Adding helping hints --- tutor/app/controllers/hints_controller.rb | 30 ++++++++++++++++++++++ tutor/app/views/hints/create_new.html.erb | 29 +++++++++++++++++++++ tutor/app/views/hints/new.html.erb | 4 +++ tutor/app/views/problems/_timer.html.erb | 1 + tutor/db/development.sqlite3 | Bin 204800 -> 204800 bytes 5 files changed, 64 insertions(+) create mode 100644 tutor/app/views/hints/create_new.html.erb diff --git a/tutor/app/controllers/hints_controller.rb b/tutor/app/controllers/hints_controller.rb index cc377db6..a373e6d3 100644 --- a/tutor/app/controllers/hints_controller.rb +++ b/tutor/app/controllers/hints_controller.rb @@ -10,4 +10,34 @@ def new @hints = Hint.all @hints_check=Hint.all end + # [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 = Hint.new(permitCreate) + + if p.save + redirect_to :action => "new", :id => p.id + else + flash.keep[:notice] = "Hint is 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(:Hint).permit(:title , :category, :submission_counter, :message) + end + def create_new + end end \ No newline at end of file diff --git a/tutor/app/views/hints/create_new.html.erb b/tutor/app/views/hints/create_new.html.erb new file mode 100644 index 00000000..e2ee2cd0 --- /dev/null +++ b/tutor/app/views/hints/create_new.html.erb @@ -0,0 +1,29 @@ +

    Add a Hint

    +
    + +<%= form_for :Hint, url: {action: "create"} do |p| %> +

    + <%= p.label :title %>
    + <%= p.text_field :title %> +

    +

    + <%= p.label :category %>
    + <%= p.text_field :category %> +

    +

    + <%= p.label :submission_counter %>
    + <%= p.text_field :submission_counter %> +

    +

    + <%= p.label :message %>
    + <%= p.text_area :message , :cols => "50", :rows => "10" %> +

    +

    + <%= p.submit %> +

    +<% end %> + +<% if flash[:notice] %> +
    <%= flash[:notice] %>
    +<% end %> \ No newline at end of file diff --git a/tutor/app/views/hints/new.html.erb b/tutor/app/views/hints/new.html.erb index 68767aab..c987db63 100644 --- a/tutor/app/views/hints/new.html.erb +++ b/tutor/app/views/hints/new.html.erb @@ -47,7 +47,11 @@ <%end%> + +
    + + \ No newline at end of file +

    Add a Hint

    +
    + +<%= form_for :Hint, url: {action: "create"} do |p| %> +

    + <%= p.label :submission_counter %>
    + <%= p.text_field :submission_counter %> +

    +

    + <%= p.label :message %>
    + <%= p.text_area :message , :cols => "50", :rows => "10" %> +

    +

    + <%= p.submit %> +

    +<% end %> + +<% if flash[:notice] %> +
    <%= flash[:notice] %>
    +<% end %> \ No newline at end of file From 0cecad7e7434de0384bc2a2de7fcc7d131e0e8bf Mon Sep 17 00:00:00 2001 From: Mohamed Fadel Date: Tue, 22 Apr 2014 13:31:01 +0200 Subject: [PATCH 14/17] Remove helping hints Issue #211 --- tutor/app/controllers/hints_controller.rb | 21 +++++++++++++++++++-- tutor/app/views/hints/_index.html.erb | 7 +++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 tutor/app/views/hints/_index.html.erb diff --git a/tutor/app/controllers/hints_controller.rb b/tutor/app/controllers/hints_controller.rb index 33aaab9e..c0fc5c21 100644 --- a/tutor/app/controllers/hints_controller.rb +++ b/tutor/app/controllers/hints_controller.rb @@ -18,7 +18,7 @@ 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: @@ -58,4 +58,21 @@ def create # Author: Mohamed Fadel def permitCreate params.require(:Hint).permit(:submission_counter, :message) - end \ No newline at end of file + 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 \ No newline at end of file diff --git a/tutor/app/views/hints/_index.html.erb b/tutor/app/views/hints/_index.html.erb new file mode 100644 index 00000000..6ae76c16 --- /dev/null +++ b/tutor/app/views/hints/_index.html.erb @@ -0,0 +1,7 @@ + + +Delete + +<%= button_to "Delete", {controller: :hints, action: :destroy, id: hint1.id}, + :method => :delete, class: 'btn btn-primary btn-xs' %> \ No newline at end of file From 22cad5c9fdcb7b39d3f99430b0195c9a69e9a409 Mon Sep 17 00:00:00 2001 From: Mohamed Fadel Date: Tue, 22 Apr 2014 19:14:48 +0200 Subject: [PATCH 15/17] Fixing indentation issue #211 --- tutor/app/controllers/hints_controller.rb | 58 ++++++++--------------- 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/tutor/app/controllers/hints_controller.rb b/tutor/app/controllers/hints_controller.rb index c0fc5c21..9e2ed571 100644 --- a/tutor/app/controllers/hints_controller.rb +++ b/tutor/app/controllers/hints_controller.rb @@ -2,31 +2,15 @@ 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 - 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 - # 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 - # Author: Mohamed Fadel + # [Adding Helping Hints - 4.12] + # Creates a new record to Hint Table + # Parameters: + # owner_id: ID of the hint owner + # 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 + # Author: Mohamed Fadel def create p = Hint.new(permitCreate) if lecturer_signed_in? @@ -49,26 +33,26 @@ def create 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 - # message: hint's message - # Returns: params to create action - # Author: Mohamed Fadel + # [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 + # 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 + # [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: + # Parameters: # params[:id]: The current hint's id - # Returns: + # Returns: # none - # Author: Mohamed Fadel + # Author: Mohamed Fadel def destroy hint = Hint.find_by_id(params[:id]) hint.destroy From c2101348bf60d5f1a586015183262d945ceaa089 Mon Sep 17 00:00:00 2001 From: Mohamed Fadel Date: Tue, 22 Apr 2014 20:19:05 +0200 Subject: [PATCH 16/17] Fixing documentation and code issue #211 --- tutor/app/controllers/hints_controller.rb | 35 ++++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tutor/app/controllers/hints_controller.rb b/tutor/app/controllers/hints_controller.rb index 9e2ed571..cfe6b215 100644 --- a/tutor/app/controllers/hints_controller.rb +++ b/tutor/app/controllers/hints_controller.rb @@ -2,15 +2,15 @@ class HintsController < ApplicationController @@answer_id = nil - # [Adding Helping Hints - 4.12] - # Creates a new record to Hint Table - # Parameters: + #[Adding Helping Hints - 4.12] + #Creates a new record to Hint Table + #Parameters: # owner_id: ID of the hint owner # owner type: type of hint owner # category: states whether it is a hint or tip - # Returns: + #Returns: # Redirects to edit page on success, refreshes on failure - # Author: Mohamed Fadel + #Author: Mohamed Fadel def create p = Hint.new(permitCreate) if lecturer_signed_in? @@ -33,26 +33,27 @@ def create end end - # [Adding Helping Hints - 4.12] - # Passes the input of the form as paramaters for create action to use it - # Parameters: + #[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 # message: hint's message - # Returns: params to create action - # Author: Mohamed Fadel + #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: + #[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: + #Returns: # none - # Author: Mohamed Fadel + #Author: Mohamed Fadel def destroy hint = Hint.find_by_id(params[:id]) hint.destroy From db83e1eee26a284c28881a71b4d23b24205d6b36 Mon Sep 17 00:00:00 2001 From: Mohamed Fadel Date: Wed, 23 Apr 2014 00:34:29 +0200 Subject: [PATCH 17/17] Fixing indentation issues #211 --- tutor/app/controllers/hints_controller.rb | 34 +++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tutor/app/controllers/hints_controller.rb b/tutor/app/controllers/hints_controller.rb index cfe6b215..46cceed5 100644 --- a/tutor/app/controllers/hints_controller.rb +++ b/tutor/app/controllers/hints_controller.rb @@ -2,15 +2,15 @@ class HintsController < ApplicationController @@answer_id = nil - #[Adding Helping Hints - 4.12] - #Creates a new record to Hint Table - #Parameters: + # [Adding Helping Hints - 4.12] + # Creates a new record to Hint Table + # Parameters: # owner_id: ID of the hint owner # owner type: type of hint owner # category: states whether it is a hint or tip - #Returns: + # Returns: # Redirects to edit page on success, refreshes on failure - #Author: Mohamed Fadel + # Author: Mohamed Fadel def create p = Hint.new(permitCreate) if lecturer_signed_in? @@ -33,27 +33,27 @@ def create end end - #[Adding Helping Hints - 4.12] - #Passes the input of the form as paramaters for create action to use it - #Parameters: + # [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 # message: hint's message - #Returns: + # Returns: # params to create action - #Author: Mohamed Fadel + # 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: + # [Delete a Hint - Story 4.21] + # This action takes the hint id, removes 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: + # Returns: # none - #Author: Mohamed Fadel + # Author: Mohamed Fadel def destroy hint = Hint.find_by_id(params[:id]) hint.destroy