From 8cd0dad3acf8b7ae806b65302b2a9cf04ab8c715 Mon Sep 17 00:00:00 2001 From: Khaled Date: Mon, 14 Apr 2014 17:19:07 +0200 Subject: [PATCH 001/526] Issue #216 Add missing fields in lecturer registeration --- .../app/controllers/application_controller.rb | 2 +- tutor/app/models/lecturer.rb | 4 ++ .../lecturers/registrations/new.html.erb | 45 ++++++++++++++----- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/tutor/app/controllers/application_controller.rb b/tutor/app/controllers/application_controller.rb index f59c26be..ba3b3e2a 100644 --- a/tutor/app/controllers/application_controller.rb +++ b/tutor/app/controllers/application_controller.rb @@ -10,7 +10,7 @@ class ApplicationController < ActionController::Base def update_sanitized_params if "#{resource_name}" == "lecturer" devise_parameter_sanitizer.for(:sign_up) { - |u| u.permit(:name, :email, :password, :password_confirmation, :degree) + |u| u.permit(:name, :email, :password, :password_confirmation, :degree, :age) } elsif "#{resource_name}" == "student" devise_parameter_sanitizer.for(:sign_up) { diff --git a/tutor/app/models/lecturer.rb b/tutor/app/models/lecturer.rb index 79d862a4..04e3cc25 100644 --- a/tutor/app/models/lecturer.rb +++ b/tutor/app/models/lecturer.rb @@ -5,6 +5,10 @@ class Lecturer < ActiveRecord::Base :recoverable, :rememberable, :trackable, :validatable #Validations + validates :name, presence: true + validates :dob, presence: true + validates :degree, presence: true + validates :age, presence: true #Relations has_one :user, as: :sub diff --git a/tutor/app/views/lecturers/registrations/new.html.erb b/tutor/app/views/lecturers/registrations/new.html.erb index 80ada924..4842fb7d 100644 --- a/tutor/app/views/lecturers/registrations/new.html.erb +++ b/tutor/app/views/lecturers/registrations/new.html.erb @@ -1,21 +1,42 @@

Sign up

+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> + <%= devise_error_messages! %> +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %> +
-<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> - <%= devise_error_messages! %> +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
-
<%= f.label :degree %>
- <%= f.text_field :degree%>
+
+ <%= f.label :password %>
+ <%= f.password_field :password, autocomplete: "off" %> +
-
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: "off" %> +
-
<%= f.label :password %>
- <%= f.password_field :password, autocomplete: "off" %>
+
+ <%= f.label :age %>
+ <%= f.number_field :age %> +
-
<%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: "off" %>
+
+ <%= f.label :date_of_birth %>
+ <%= f.datetime_field :dob %> +
-
<%= f.submit "Sign up" %>
-<% end %> +
+ <%= f.label :degree %>
+ <%= f.text_field :degree %> +
+ +
<%= f.submit "Sign up" %>
+ <% end %> <%= render "lecturers/shared/links" %> From 9e3b8c7224b47296c1fcf468d5ac0f3905291794 Mon Sep 17 00:00:00 2001 From: Khaled Date: Mon, 14 Apr 2014 17:45:04 +0200 Subject: [PATCH 002/526] Issue #216 Add missing fields in lecturer registeration with required presence validations --- tutor/app/controllers/application_controller.rb | 2 +- tutor/app/models/lecturer.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tutor/app/controllers/application_controller.rb b/tutor/app/controllers/application_controller.rb index ba3b3e2a..0abe72b6 100644 --- a/tutor/app/controllers/application_controller.rb +++ b/tutor/app/controllers/application_controller.rb @@ -10,7 +10,7 @@ class ApplicationController < ActionController::Base def update_sanitized_params if "#{resource_name}" == "lecturer" devise_parameter_sanitizer.for(:sign_up) { - |u| u.permit(:name, :email, :password, :password_confirmation, :degree, :age) + |u| u.permit(:name, :email, :password, :password_confirmation, :degree, :age, :dob) } elsif "#{resource_name}" == "student" devise_parameter_sanitizer.for(:sign_up) { diff --git a/tutor/app/models/lecturer.rb b/tutor/app/models/lecturer.rb index 15c158be..6df75430 100644 --- a/tutor/app/models/lecturer.rb +++ b/tutor/app/models/lecturer.rb @@ -9,6 +9,7 @@ class Lecturer < ActiveRecord::Base validates :dob, presence: true validates :degree, presence: true validates :age, presence: true + validates :dob, presence: true #Relations has_and_belongs_to_many :courses, join_table: "courses_lecturers" From 36283fbdb0cdee5b3c1840e3f1ffc6f83f8113ed Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Tue, 15 Apr 2014 17:23:06 +0200 Subject: [PATCH 003/526] Issue #188 create controllers --- tutor/app/assets/javascripts/method_constraints.js.coffee | 3 +++ tutor/app/assets/stylesheets/method_constraints.css.scss | 3 +++ tutor/app/controllers/method_constraints_controller.rb | 7 +++++++ tutor/app/helpers/method_constraints_helper.rb | 2 ++ .../test/controllers/method_constraints_controller_test.rb | 7 +++++++ tutor/test/helpers/method_constraints_helper_test.rb | 4 ++++ 6 files changed, 26 insertions(+) create mode 100644 tutor/app/assets/javascripts/method_constraints.js.coffee create mode 100644 tutor/app/assets/stylesheets/method_constraints.css.scss create mode 100644 tutor/app/controllers/method_constraints_controller.rb create mode 100644 tutor/app/helpers/method_constraints_helper.rb create mode 100644 tutor/test/controllers/method_constraints_controller_test.rb create mode 100644 tutor/test/helpers/method_constraints_helper_test.rb diff --git a/tutor/app/assets/javascripts/method_constraints.js.coffee b/tutor/app/assets/javascripts/method_constraints.js.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/tutor/app/assets/javascripts/method_constraints.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/method_constraints.css.scss b/tutor/app/assets/stylesheets/method_constraints.css.scss new file mode 100644 index 00000000..611417eb --- /dev/null +++ b/tutor/app/assets/stylesheets/method_constraints.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the methodConstraints controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/tutor/app/controllers/method_constraints_controller.rb b/tutor/app/controllers/method_constraints_controller.rb new file mode 100644 index 00000000..582ebb5a --- /dev/null +++ b/tutor/app/controllers/method_constraints_controller.rb @@ -0,0 +1,7 @@ +class MethodConstraintsController < ApplicationController + + def create + + end + +end diff --git a/tutor/app/helpers/method_constraints_helper.rb b/tutor/app/helpers/method_constraints_helper.rb new file mode 100644 index 00000000..1102b1dc --- /dev/null +++ b/tutor/app/helpers/method_constraints_helper.rb @@ -0,0 +1,2 @@ +module MethodConstraintsHelper +end diff --git a/tutor/test/controllers/method_constraints_controller_test.rb b/tutor/test/controllers/method_constraints_controller_test.rb new file mode 100644 index 00000000..28467947 --- /dev/null +++ b/tutor/test/controllers/method_constraints_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class MethodConstraintsControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/tutor/test/helpers/method_constraints_helper_test.rb b/tutor/test/helpers/method_constraints_helper_test.rb new file mode 100644 index 00000000..45964376 --- /dev/null +++ b/tutor/test/helpers/method_constraints_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class MethodConstraintsHelperTest < ActionView::TestCase +end From 357e408b799a59d82b136df51a3f83df72c079ec Mon Sep 17 00:00:00 2001 From: Mohab Date: Thu, 17 Apr 2014 15:13:36 +0200 Subject: [PATCH 004/526] Create git_next_problem_to_solve method --- .gitignore~ | 25 +++++++++++++++++ .../app/assets/javascripts/profile.js.coffee | 3 ++ tutor/app/assets/stylesheets/profile.css.scss | 3 ++ tutor/app/controllers/profile_controller.rb | 2 ++ tutor/app/models/student.rb | 28 +++++++++++++++++++ tutor/app/views/profile/index.html.erb | 12 ++++++++ tutor/config/routes.rb | 2 ++ .../controllers/profile_controller_test.rb | 7 +++++ 8 files changed, 82 insertions(+) create mode 100644 .gitignore~ create mode 100644 tutor/app/assets/javascripts/profile.js.coffee create mode 100644 tutor/app/assets/stylesheets/profile.css.scss create mode 100644 tutor/app/controllers/profile_controller.rb create mode 100644 tutor/app/views/profile/index.html.erb create mode 100644 tutor/test/controllers/profile_controller_test.rb diff --git a/.gitignore~ b/.gitignore~ new file mode 100644 index 00000000..40c1a8fa --- /dev/null +++ b/.gitignore~ @@ -0,0 +1,25 @@ +.DS_Store +*.rbc +capybara-*.html +.rspec +/log +/tmp +/db/*.sqlite3 +/public/system +/coverage/ +/spec/tmp +**.orig +rerun.txt +pickle-email-*.html +config/initializers/secret_token.rb +config/secrets.yml + +## Environment normalisation: +/.bundle +/vendor/bundle + +# these should all be checked in to normalise the environment: +# Gemfile.lock, .ruby-version, .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc diff --git a/tutor/app/assets/javascripts/profile.js.coffee b/tutor/app/assets/javascripts/profile.js.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/tutor/app/assets/javascripts/profile.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/profile.css.scss b/tutor/app/assets/stylesheets/profile.css.scss new file mode 100644 index 00000000..22ee5087 --- /dev/null +++ b/tutor/app/assets/stylesheets/profile.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Profile controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/tutor/app/controllers/profile_controller.rb b/tutor/app/controllers/profile_controller.rb new file mode 100644 index 00000000..c46b6546 --- /dev/null +++ b/tutor/app/controllers/profile_controller.rb @@ -0,0 +1,2 @@ +class ProfileController < ApplicationController +end diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index 7a686980..a1738991 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -49,5 +49,33 @@ def get_a_system_suggested_problem # Return random element from array return suggestions.to_a().sample() end + + def get_next_problems_hash + next_problems_to_solve = Hash.new + + courses.each do |course| + course.topics.each do |topic| + level = TrackProgression.get_progress(self.id, topic.id) + + topic.tracks.each do |track| + if(track.difficulty == level) + track.problems.each do |problem| + if(!problem.is_solved_by_student(self.id)) + key = course.name + key += " - " + topic.title + key += " - " + track.title + next_problems_to_solve[key] = problem + break + end + end + end + end + end + end + + return next_problems_to_solve + end + + end diff --git a/tutor/app/views/profile/index.html.erb b/tutor/app/views/profile/index.html.erb new file mode 100644 index 00000000..664d4793 --- /dev/null +++ b/tutor/app/views/profile/index.html.erb @@ -0,0 +1,12 @@ +<% if student_signed_in? %> +

you are signed in

+<% + next_problems_to_solve = current_student.get_next_problems_hash + if next_problems_to_solve != nil then + next_problems_to_solve.each do |key , value| + str = key + "--" + value.title + %> + <%= str %> + <% end %> + <% end %> +<% end %> \ No newline at end of file diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index 6b97d09f..ece105c4 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -31,6 +31,8 @@ devise_for :students devise_for :lecturers + get 'profile' => 'profile#index' + # Example of named route that can be invoked with purchase_url(id: product.id) # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase diff --git a/tutor/test/controllers/profile_controller_test.rb b/tutor/test/controllers/profile_controller_test.rb new file mode 100644 index 00000000..81441f04 --- /dev/null +++ b/tutor/test/controllers/profile_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ProfileControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end From 40c56e05fd2ccff2e40326fa0e88546dc6ee3c5d Mon Sep 17 00:00:00 2001 From: Mohab Date: Thu, 17 Apr 2014 18:25:05 +0200 Subject: [PATCH 005/526] Applying modification --- tutor/app/models/student.rb | 2 +- tutor/app/views/profile/index.html.erb | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index a1738991..1eda018f 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -50,7 +50,7 @@ def get_a_system_suggested_problem return suggestions.to_a().sample() end - def get_next_problems_hash + def get_next_problems_to_solve next_problems_to_solve = Hash.new courses.each do |course| diff --git a/tutor/app/views/profile/index.html.erb b/tutor/app/views/profile/index.html.erb index 664d4793..ed7c92ba 100644 --- a/tutor/app/views/profile/index.html.erb +++ b/tutor/app/views/profile/index.html.erb @@ -1,12 +1,10 @@ -<% if student_signed_in? %> -

you are signed in

<% - next_problems_to_solve = current_student.get_next_problems_hash + 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| - str = key + "--" + value.title - %> - <%= str %> - <% end %> - <% end %> -<% end %> \ No newline at end of file + next_problems_to_solve.each do |key , value| + concat key + concat link_to value.title, controller: "problems", action: "show", id: value.id + concat "
".html_safe + end + end +%> \ No newline at end of file From 0a56a85853daa0f466f88c33eb941326183cddb8 Mon Sep 17 00:00:00 2001 From: Khaled Date: Thu, 17 Apr 2014 22:13:21 +0200 Subject: [PATCH 006/526] Issue #216 Special handling for 'date of birth' field in lecturer registeration --- tutor/app/views/lecturers/registrations/new.html.erb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tutor/app/views/lecturers/registrations/new.html.erb b/tutor/app/views/lecturers/registrations/new.html.erb index 4842fb7d..14293b46 100644 --- a/tutor/app/views/lecturers/registrations/new.html.erb +++ b/tutor/app/views/lecturers/registrations/new.html.erb @@ -28,7 +28,7 @@
<%= f.label :date_of_birth %>
- <%= f.datetime_field :dob %> + <%= f.date_select :dob, {:start_year => Date.today.year-90, :end_year => Date.today.year} %>
@@ -36,6 +36,11 @@ <%= f.text_field :degree %>
+
+ <%= f.label :department %>
+ <%= f.text_field :department %> +
+
<%= f.submit "Sign up" %>
<% end %> From 9e1eb4a8576c1c62cf93a967321ccbb077654467 Mon Sep 17 00:00:00 2001 From: Khaled Date: Fri, 18 Apr 2014 01:27:38 +0200 Subject: [PATCH 007/526] Issue #216 Added uploading profile image in lecturer registeration --- tutor/Gemfile | 11 ++-- tutor/Gemfile.lock | 8 +++ .../app/controllers/application_controller.rb | 3 +- tutor/app/models/lecturer.rb | 6 +-- tutor/app/uploaders/profile_image_uploader.rb | 51 +++++++++++++++++++ .../lecturers/registrations/new.html.erb | 14 +++-- 6 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 tutor/app/uploaders/profile_image_uploader.rb diff --git a/tutor/Gemfile b/tutor/Gemfile index 7382b0e9..1cf25cea 100644 --- a/tutor/Gemfile +++ b/tutor/Gemfile @@ -5,9 +5,16 @@ ruby '2.1.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.0.4' +# User authentication +gem 'devise' + +# File uploading +gem 'carrierwave' +gem 'rmagick' + # Use sqlite3 as the database for Active Record gem 'sqlite3' -gem 'devise' + # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.2' @@ -47,7 +54,5 @@ gem 'foreman' # Use debugger # gem 'debugger', group: [:development, :test] -# User authentication - # Use composite primary keys in models gem 'composite_primary_keys', '~> 6.0.1' diff --git a/tutor/Gemfile.lock b/tutor/Gemfile.lock index fa0d2aac..70e8e6dc 100644 --- a/tutor/Gemfile.lock +++ b/tutor/Gemfile.lock @@ -29,6 +29,11 @@ GEM atomic (1.1.16) bcrypt (3.1.7) builder (3.1.4) + carrierwave (0.10.0) + activemodel (>= 3.2.0) + activesupport (>= 3.2.0) + json (>= 1.7) + mime-types (>= 1.16) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -88,6 +93,7 @@ GEM rake (10.1.1) rdoc (4.1.1) json (~> 1.4) + rmagick (2.13.2) sass (3.2.17) sass-rails (4.0.2) railties (>= 4.0.0, < 5.0) @@ -131,6 +137,7 @@ PLATFORMS ruby DEPENDENCIES + carrierwave coffee-rails (~> 4.0.0) composite_primary_keys (~> 6.0.1) devise @@ -138,6 +145,7 @@ DEPENDENCIES jbuilder (~> 1.2) jquery-rails (~> 3.1.0) rails (= 4.0.4) + rmagick sass-rails (~> 4.0.2) sdoc sqlite3 diff --git a/tutor/app/controllers/application_controller.rb b/tutor/app/controllers/application_controller.rb index c164ace4..64faa7b5 100644 --- a/tutor/app/controllers/application_controller.rb +++ b/tutor/app/controllers/application_controller.rb @@ -11,7 +11,8 @@ class ApplicationController < ActionController::Base def update_sanitized_params if "#{resource_name}" == "lecturer" devise_parameter_sanitizer.for(:sign_up) { - |u| u.permit(:name, :email, :password, :password_confirmation, :degree, :age, :dob) + |u| u.permit(:name, :email, :password, :password_confirmation, :gender, :dob, :degree, :department, + :profile_image, :profile_image_cache) } elsif "#{resource_name}" == "student" devise_parameter_sanitizer.for(:sign_up) { diff --git a/tutor/app/models/lecturer.rb b/tutor/app/models/lecturer.rb index 6df75430..563a2f96 100644 --- a/tutor/app/models/lecturer.rb +++ b/tutor/app/models/lecturer.rb @@ -4,12 +4,12 @@ class Lecturer < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable + mount_uploader :profile_image, ProfileImageUploader + #Validations validates :name, presence: true - validates :dob, presence: true validates :degree, presence: true - validates :age, presence: true - validates :dob, presence: true + validates :department, presence: true #Relations has_and_belongs_to_many :courses, join_table: "courses_lecturers" diff --git a/tutor/app/uploaders/profile_image_uploader.rb b/tutor/app/uploaders/profile_image_uploader.rb new file mode 100644 index 00000000..cfd3a79c --- /dev/null +++ b/tutor/app/uploaders/profile_image_uploader.rb @@ -0,0 +1,51 @@ +# encoding: utf-8 + +class ProfileImageUploader < CarrierWave::Uploader::Base + + # Include RMagick or MiniMagick support: + include CarrierWave::RMagick + # include CarrierWave::MiniMagick + + # Choose what kind of storage to use for this uploader: + storage :file + # storage :fog + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url + # # For Rails 3.1+ asset pipeline compatibility: + # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) + # + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + process :resize_to_limit => [50, 50] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + version :profile do + process :resize_to_fit => [160, 160] + end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + def extension_white_list + %w(jpg jpeg gif png) + end + + # Override the filename of the uploaded files: + # Avoid using model.id or version_name here, see uploader/store.rb for details. + # def filename + # "something.jpg" if original_filename + # end + +end diff --git a/tutor/app/views/lecturers/registrations/new.html.erb b/tutor/app/views/lecturers/registrations/new.html.erb index 14293b46..bd6d8cc0 100644 --- a/tutor/app/views/lecturers/registrations/new.html.erb +++ b/tutor/app/views/lecturers/registrations/new.html.erb @@ -1,5 +1,5 @@

Sign up

- <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> + <%= form_for(resource, as: resource_name, url: registration_path(resource_name), :html => {:multipart => true}) do |f| %> <%= devise_error_messages! %>
<%= f.label :email %>
@@ -22,8 +22,8 @@
- <%= f.label :age %>
- <%= f.number_field :age %> + <%= f.label :gender %>
+ <%= f.select(:gender, [['Male', true], ['Female', false]]) %>
@@ -41,6 +41,14 @@ <%= f.text_field :department %>
+
+
+ <%= image_tag(@lecturer.profile_image_url.to_s) if @lecturer.profile_image? %> + <%= f.file_field :profile_image, {:accept => 'image/png,image/gif,image/jpeg'} %> + <%= f.hidden_field :profile_image_cache %> +
+
+
<%= f.submit "Sign up" %>
<% end %> From 13ea0a9c0489ab7a6ed461fd8587043fc91f91bc Mon Sep 17 00:00:00 2001 From: AmirGeorge Date: Fri, 18 Apr 2014 01:47:47 +0200 Subject: [PATCH 008/526] added whenever gem, changed action name to reminder_email --- tutor/Gemfile | 3 +++ tutor/app/mailers/system_reminders.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tutor/Gemfile b/tutor/Gemfile index 7382b0e9..48dbb0f4 100644 --- a/tutor/Gemfile +++ b/tutor/Gemfile @@ -51,3 +51,6 @@ gem 'foreman' # Use composite primary keys in models gem 'composite_primary_keys', '~> 6.0.1' + +# whenever gem for scheduling tasks +gem 'whenever' diff --git a/tutor/app/mailers/system_reminders.rb b/tutor/app/mailers/system_reminders.rb index 324af815..88149193 100644 --- a/tutor/app/mailers/system_reminders.rb +++ b/tutor/app/mailers/system_reminders.rb @@ -1,6 +1,6 @@ class SystemReminders < ActionMailer::Base default from: "from@example.com" - def welcome_email(current_student) + def reminder_email(current_student) @user = current_student @url = 'http://localhost:3000' mail(to: @user.email, subject: 'We miss you at our Awesome Tutors Website') From 492d92a81b828ba381edaaa1a9e75c34417490d6 Mon Sep 17 00:00:00 2001 From: Khaled Date: Fri, 18 Apr 2014 02:13:00 +0200 Subject: [PATCH 009/526] Issue #216 Finished lecturer registeration --- .../lecturers/registrations/new.html.erb | 48 +++++++++---------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/tutor/app/views/lecturers/registrations/new.html.erb b/tutor/app/views/lecturers/registrations/new.html.erb index bd6d8cc0..fae5cff1 100644 --- a/tutor/app/views/lecturers/registrations/new.html.erb +++ b/tutor/app/views/lecturers/registrations/new.html.erb @@ -1,55 +1,51 @@

Sign up

<%= form_for(resource, as: resource_name, url: registration_path(resource_name), :html => {:multipart => true}) do |f| %> <%= devise_error_messages! %> -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true %> + +
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%>
-
- <%= f.label :name %>
- <%= f.text_field :name %> +
+ <%= f.text_field :name, class: "form-control", style: "width:300px", placeholder: "Name"%>
-
- <%= f.label :password %>
- <%= f.password_field :password, autocomplete: "off" %> -
+
+ <%= f.password_field :password, autocomplete: "off", class:"form-control", style:"width:300px", placeholder:"Password"%> +
-
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: "off" %> -
+
+ <%= f.password_field :password_confirmation, autocomplete: "off", class:"form-control", style:"width:300px",placeholder: "Confirm Password" %> +
-
- <%= f.label :gender %>
+
+ <%= f.label :gender %> <%= f.select(:gender, [['Male', true], ['Female', false]]) %>
-
- <%= f.label :date_of_birth %>
+
+ <%= f.label :date_of_birth %> <%= f.date_select :dob, {:start_year => Date.today.year-90, :end_year => Date.today.year} %>
-
- <%= f.label :degree %>
- <%= f.text_field :degree %> +
+ <%= f.text_field :degree, class: "form-control", style: "width:300px", placeholder: "Degree"%>
-
- <%= f.label :department %>
- <%= f.text_field :department %> +
+ <%= f.text_field :department, class: "form-control", style: "width:300px", placeholder: "Department"%>
-
+

+ <%= f.label :profile_image %> <%= image_tag(@lecturer.profile_image_url.to_s) if @lecturer.profile_image? %> <%= f.file_field :profile_image, {:accept => 'image/png,image/gif,image/jpeg'} %> <%= f.hidden_field :profile_image_cache %>
-
<%= f.submit "Sign up" %>
+
<%= f.submit "Sign up", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "lecturers/shared/links" %> From b2d2e82c9f875d45f85978517f11c36672a183d6 Mon Sep 17 00:00:00 2001 From: AmirGeorge Date: Fri, 18 Apr 2014 02:40:15 +0200 Subject: [PATCH 010/526] added scheduler file, modified parameter name in system_reminders to avoid conflict --- tutor/app/mailers/system_reminders.rb | 4 ++-- tutor/config/schedule.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 tutor/config/schedule.rb diff --git a/tutor/app/mailers/system_reminders.rb b/tutor/app/mailers/system_reminders.rb index 88149193..c2e8b07d 100644 --- a/tutor/app/mailers/system_reminders.rb +++ b/tutor/app/mailers/system_reminders.rb @@ -1,7 +1,7 @@ class SystemReminders < ActionMailer::Base default from: "from@example.com" - def reminder_email(current_student) - @user = current_student + def reminder_email(user) + @user = user @url = 'http://localhost:3000' mail(to: @user.email, subject: 'We miss you at our Awesome Tutors Website') end diff --git a/tutor/config/schedule.rb b/tutor/config/schedule.rb new file mode 100644 index 00000000..bd8c520a --- /dev/null +++ b/tutor/config/schedule.rb @@ -0,0 +1,8 @@ +every 2.hours do + @current = + Student.all.each do |student| + #if student.last_sign_in_at > #some value + runner "SystemReminders.reminder_email(student)" + #end + end +end \ No newline at end of file From 2956f50d57a6a5dde4194bf6e171dc9419ed4788 Mon Sep 17 00:00:00 2001 From: AmirGeorge Date: Fri, 18 Apr 2014 02:54:29 +0200 Subject: [PATCH 011/526] fixed bugs in scheduler.rb --- tutor/config/schedule.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutor/config/schedule.rb b/tutor/config/schedule.rb index bd8c520a..6e27b345 100644 --- a/tutor/config/schedule.rb +++ b/tutor/config/schedule.rb @@ -1,8 +1,8 @@ -every 2.hours do +every 2.days do @current = Student.all.each do |student| - #if student.last_sign_in_at > #some value - runner "SystemReminders.reminder_email(student)" - #end + if student.last_sign_in_at > Time.now - 7.days + runner "SystemReminders.reminder_email(student).deliver" + end end end \ No newline at end of file From 382946a3c68672c6c65c909a154b26276d730c42 Mon Sep 17 00:00:00 2001 From: Khaled Date: Fri, 18 Apr 2014 09:31:57 +0200 Subject: [PATCH 012/526] Issue #216 Minor bug fix --- tutor/app/views/lecturers/registrations/new.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/views/lecturers/registrations/new.html.erb b/tutor/app/views/lecturers/registrations/new.html.erb index fae5cff1..119f04dc 100644 --- a/tutor/app/views/lecturers/registrations/new.html.erb +++ b/tutor/app/views/lecturers/registrations/new.html.erb @@ -38,7 +38,7 @@

- <%= f.label :profile_image %> + <%= f.label :profile_image %>
<%= image_tag(@lecturer.profile_image_url.to_s) if @lecturer.profile_image? %> <%= f.file_field :profile_image, {:accept => 'image/png,image/gif,image/jpeg'} %> <%= f.hidden_field :profile_image_cache %> From ebb55d817602660060eb035cb78deb55562fab55 Mon Sep 17 00:00:00 2001 From: Mohab Date: Fri, 18 Apr 2014 11:32:50 +0200 Subject: [PATCH 013/526] Placing problems in table --- tutor/app/models/student.rb | 11 +++++++---- tutor/app/views/profile/index.html.erb | 22 +++++++++++++--------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index 1eda018f..b975ea87 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -50,6 +50,12 @@ def get_a_system_suggested_problem return suggestions.to_a().sample() end + #Methods + # [Problem Assined - Story 5.5] + # Returns a Hash containing the next problem to solve in each course - topic - track + # Parameters: None + # Returns: A Hash of key as 'Course-Topic-track' and value as a Problem model instance + # Author: Mohab Ghanim (Modified from Rami Khalil's Story 3.9) def get_next_problems_to_solve next_problems_to_solve = Hash.new @@ -72,10 +78,7 @@ def get_next_problems_to_solve end end end - return next_problems_to_solve end - -end - +end \ No newline at end of file diff --git a/tutor/app/views/profile/index.html.erb b/tutor/app/views/profile/index.html.erb index ed7c92ba..f4a38ffd 100644 --- a/tutor/app/views/profile/index.html.erb +++ b/tutor/app/views/profile/index.html.erb @@ -1,10 +1,14 @@ -<% +<% 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| - concat key - concat link_to value.title, controller: "problems", action: "show", id: value.id - concat "
".html_safe - end - end -%> \ No newline at end of file + if next_problems_to_solve != nil then %> + + + <% next_problems_to_solve.each do |key , value| %> + + + + <% end %> +
Your Next Problems
<%= link_to value.title, controller: "problems", action: "show", id: value.id %> + <%= key %> +
+<% end %> \ No newline at end of file From 7a00e7b21de2249b78d9a2ca4468d14629488d5d Mon Sep 17 00:00:00 2001 From: Mohab Date: Fri, 18 Apr 2014 11:43:18 +0200 Subject: [PATCH 014/526] Adding Documentation --- tutor/app/helpers/profile_helper.rb | 2 ++ tutor/app/views/profile/index.html.erb | 7 +++++-- tutor/app/views/site/home.html | 1 + tutor/test/helpers/profile_helper_test.rb | 4 ++++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tutor/app/helpers/profile_helper.rb create mode 100644 tutor/app/views/site/home.html create mode 100644 tutor/test/helpers/profile_helper_test.rb diff --git a/tutor/app/helpers/profile_helper.rb b/tutor/app/helpers/profile_helper.rb new file mode 100644 index 00000000..5a0d6b31 --- /dev/null +++ b/tutor/app/helpers/profile_helper.rb @@ -0,0 +1,2 @@ +module ProfileHelper +end diff --git a/tutor/app/views/profile/index.html.erb b/tutor/app/views/profile/index.html.erb index f4a38ffd..4d1224e5 100644 --- a/tutor/app/views/profile/index.html.erb +++ b/tutor/app/views/profile/index.html.erb @@ -1,5 +1,8 @@ -<% - next_problems_to_solve = current_student.get_next_problems_to_solve + +<% next_problems_to_solve = current_student.get_next_problems_to_solve if next_problems_to_solve != nil then %> diff --git a/tutor/app/views/site/home.html b/tutor/app/views/site/home.html new file mode 100644 index 00000000..724f4d4c --- /dev/null +++ b/tutor/app/views/site/home.html @@ -0,0 +1 @@ +html \ No newline at end of file diff --git a/tutor/test/helpers/profile_helper_test.rb b/tutor/test/helpers/profile_helper_test.rb new file mode 100644 index 00000000..c79b5454 --- /dev/null +++ b/tutor/test/helpers/profile_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class ProfileHelperTest < ActionView::TestCase +end From 8961f88a7d1ed2f0206c9e46b015f213f493ec16 Mon Sep 17 00:00:00 2001 From: Mohab Date: Fri, 18 Apr 2014 11:44:49 +0200 Subject: [PATCH 015/526] Adding Documentation --- tutor/app/views/profile/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/views/profile/index.html.erb b/tutor/app/views/profile/index.html.erb index 4d1224e5..819c0b0f 100644 --- a/tutor/app/views/profile/index.html.erb +++ b/tutor/app/views/profile/index.html.erb @@ -1,5 +1,5 @@ <% next_problems_to_solve = current_student.get_next_problems_to_solve From 279080ad2d9fb0d1b53b0bb59163ad8f8a166441 Mon Sep 17 00:00:00 2001 From: Mohab Date: Fri, 18 Apr 2014 11:57:52 +0200 Subject: [PATCH 016/526] Deleting helpers --- tutor/app/helpers/profile_helper.rb | 2 -- tutor/test/helpers/profile_helper_test.rb | 4 ---- 2 files changed, 6 deletions(-) delete mode 100644 tutor/app/helpers/profile_helper.rb delete mode 100644 tutor/test/helpers/profile_helper_test.rb diff --git a/tutor/app/helpers/profile_helper.rb b/tutor/app/helpers/profile_helper.rb deleted file mode 100644 index 5a0d6b31..00000000 --- a/tutor/app/helpers/profile_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ProfileHelper -end diff --git a/tutor/test/helpers/profile_helper_test.rb b/tutor/test/helpers/profile_helper_test.rb deleted file mode 100644 index c79b5454..00000000 --- a/tutor/test/helpers/profile_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class ProfileHelperTest < ActionView::TestCase -end From e2252f1d0eb57484641ce75c39db10b038ef24e5 Mon Sep 17 00:00:00 2001 From: Mohab Date: Fri, 18 Apr 2014 13:06:16 +0200 Subject: [PATCH 017/526] deleting home.html --- tutor/app/models/student.rb | 2 +- tutor/app/views/profile/index.html.erb | 2 +- tutor/app/views/site/home.html | 1 - tutor/config/routes.rb | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 tutor/app/views/site/home.html diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index b975ea87..91f51a01 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -81,4 +81,4 @@ def get_next_problems_to_solve return next_problems_to_solve end -end \ No newline at end of file +end diff --git a/tutor/app/views/profile/index.html.erb b/tutor/app/views/profile/index.html.erb index 819c0b0f..ba2bf9ed 100644 --- a/tutor/app/views/profile/index.html.erb +++ b/tutor/app/views/profile/index.html.erb @@ -14,4 +14,4 @@ <% end %>
Your Next Problems
-<% end %> \ No newline at end of file +<% end %> diff --git a/tutor/app/views/site/home.html b/tutor/app/views/site/home.html deleted file mode 100644 index 724f4d4c..00000000 --- a/tutor/app/views/site/home.html +++ /dev/null @@ -1 +0,0 @@ -html \ No newline at end of file diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index ece105c4..bfaa7ef2 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -30,7 +30,6 @@ devise_for :teaching_assistants devise_for :students devise_for :lecturers - get 'profile' => 'profile#index' # Example of named route that can be invoked with purchase_url(id: product.id) From e41e6172d1eb90d8fee14139ccfca69eb4fdd722 Mon Sep 17 00:00:00 2001 From: Mohab Date: Fri, 18 Apr 2014 13:45:59 +0200 Subject: [PATCH 018/526] updating routes --- tutor/config/routes.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index bfaa7ef2..b8aeb1c3 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -30,7 +30,8 @@ devise_for :teaching_assistants devise_for :students devise_for :lecturers - get 'profile' => 'profile#index' + + resources :profile # Example of named route that can be invoked with purchase_url(id: product.id) # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase From 50f41186a9db12e6724a33ccc8c8ddd9c248d724 Mon Sep 17 00:00:00 2001 From: Mohab Date: Fri, 18 Apr 2014 13:56:45 +0200 Subject: [PATCH 019/526] Removing extra spaces --- tutor/app/views/profile/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutor/app/views/profile/index.html.erb b/tutor/app/views/profile/index.html.erb index ba2bf9ed..8e9b588c 100644 --- a/tutor/app/views/profile/index.html.erb +++ b/tutor/app/views/profile/index.html.erb @@ -2,7 +2,7 @@ Displays student's next problem to solve in a table Author: Mohab Ghanim --> -<% next_problems_to_solve = current_student.get_next_problems_to_solve +<% next_problems_to_solve = current_student.get_next_problems_to_solve if next_problems_to_solve != nil then %> @@ -14,4 +14,4 @@ <% end %>
Your Next Problems
-<% end %> +<% end %> From debcf1a40bf468dd3eead1af3ab9328a7f110fb9 Mon Sep 17 00:00:00 2001 From: Khaled Date: Fri, 18 Apr 2014 19:16:27 +0200 Subject: [PATCH 020/526] Issue #216 Finished student registeration --- .../app/controllers/application_controller.rb | 7 +- tutor/app/models/student.rb | 6 ++ .../views/students/registrations/new.html.erb | 64 ++++++++++++++++--- tutor/config/initializers/devise.rb | 2 +- 4 files changed, 65 insertions(+), 14 deletions(-) diff --git a/tutor/app/controllers/application_controller.rb b/tutor/app/controllers/application_controller.rb index 64faa7b5..80f1c87d 100644 --- a/tutor/app/controllers/application_controller.rb +++ b/tutor/app/controllers/application_controller.rb @@ -11,12 +11,13 @@ class ApplicationController < ActionController::Base def update_sanitized_params if "#{resource_name}" == "lecturer" devise_parameter_sanitizer.for(:sign_up) { - |u| u.permit(:name, :email, :password, :password_confirmation, :gender, :dob, :degree, :department, - :profile_image, :profile_image_cache) + |u| u.permit(:name, :email, :password, :password_confirmation, :gender, :dob, :degree, + :department, :profile_image, :profile_image_cache) } elsif "#{resource_name}" == "student" devise_parameter_sanitizer.for(:sign_up) { - |u| u.permit(:name, :email, :password, :password_confirmation) + |u| u.permit(:name, :email, :password, :password_confirmation, :gender, :dob, :faculty, + :major, :semester, :advising, :probation, :profile_image, :profile_image_cache) } elsif "#{resource_name}" == "teaching_assistant" devise_parameter_sanitizer.for(:sign_up) { diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index 7a686980..60cf3697 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -4,7 +4,13 @@ class Student < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable + mount_uploader :profile_image, ProfileImageUploader + #Validations + validates :name, presence: true + validates :faculty, presence: true + validates :major, presence: true + validates :semester, presence: true, numericality: {only_integer: true, message: "must be a number."} #Relations has_many :solutions, dependent: :destroy diff --git a/tutor/app/views/students/registrations/new.html.erb b/tutor/app/views/students/registrations/new.html.erb index 1204ea98..dbb6cca2 100644 --- a/tutor/app/views/students/registrations/new.html.erb +++ b/tutor/app/views/students/registrations/new.html.erb @@ -1,18 +1,62 @@

Sign up

+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name), :html => {:multipart => true}) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
-<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> - <%= devise_error_messages! %> +
+ <%= f.text_field :name, class: "form-control", style: "width:300px", placeholder: "Name"%> +
-
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+
+ <%= f.password_field :password, autocomplete: "off", class:"form-control", style:"width:300px", placeholder:"Password"%> +
-
<%= f.label :password %>
- <%= f.password_field :password, autocomplete: "off" %>
+
+ <%= f.password_field :password_confirmation, autocomplete: "off", class:"form-control", style:"width:300px",placeholder: "Confirm Password" %> +
-
<%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: "off" %>
+
+ <%= f.label :gender %> + <%= f.select(:gender, [['Male', true], ['Female', false]]) %> +
-
<%= f.submit "Sign up" %>
-<% end %> +
+ <%= f.label :date_of_birth %> + <%= f.date_select :dob, {:start_year => Date.today.year-90, :end_year => Date.today.year} %> +
+ +
+ <%= f.text_field :faculty, class: "form-control", style: "width:300px", placeholder: "Faculty"%> +
+ +
+ <%= f.text_field :major, class: "form-control", style: "width:300px", placeholder: "Major"%> +
+ +
+ <%= f.text_field :semester, class: "form-control", style: "width:300px", placeholder: "Semester"%> +
+ +
+ <%= f.label :advising %> + <%= f.select(:advising, [['No', false], ['Yes', true]]) %> + <%= f.label :probation %> + <%= f.select(:probation, [['No', false], ['Yes', true]]) %> +
+ +
+
+ <%= f.label :profile_image %>
+ <%= image_tag(@student.profile_image_url.to_s) if @student.profile_image? %> + <%= f.file_field :profile_image, {:accept => 'image/png,image/gif,image/jpeg'} %> + <%= f.hidden_field :profile_image_cache %> +
+
+ +
<%= f.submit "Sign up", class: "btn btn-success", style: "margin-top:10px" %>
+ <% end %> <%= render "students/shared/links" %> \ No newline at end of file diff --git a/tutor/config/initializers/devise.rb b/tutor/config/initializers/devise.rb index b34152e6..da52f964 100644 --- a/tutor/config/initializers/devise.rb +++ b/tutor/config/initializers/devise.rb @@ -186,7 +186,7 @@ # Time interval you can reset your password with a reset password key. # Don't put a too small interval or your users won't have the time to # change their passwords. - config.reset_password_within = 6.hours + config.reset_password_within = 0 # ==> Configuration for :encryptable # Allow you to use another encryption algorithm besides bcrypt (default). You can use From 2c7ead3e7095e7b8383261baf4fbc7f6df2c4097 Mon Sep 17 00:00:00 2001 From: Khaled Date: Fri, 18 Apr 2014 19:35:00 +0200 Subject: [PATCH 021/526] Issue #216 Finished teaching_assistant registeration --- .../app/controllers/application_controller.rb | 4 +- tutor/app/models/student.rb | 2 +- tutor/app/models/teaching_assistant.rb | 6 ++ .../views/students/registrations/new.html.erb | 2 +- .../registrations/new.html.erb | 57 +++++++++++++++---- 5 files changed, 58 insertions(+), 13 deletions(-) diff --git a/tutor/app/controllers/application_controller.rb b/tutor/app/controllers/application_controller.rb index 80f1c87d..4557f49d 100644 --- a/tutor/app/controllers/application_controller.rb +++ b/tutor/app/controllers/application_controller.rb @@ -21,7 +21,9 @@ def update_sanitized_params } elsif "#{resource_name}" == "teaching_assistant" devise_parameter_sanitizer.for(:sign_up) { - |u| u.permit(:name, :email, :password, :password_confirmation) + |u| u.permit(:name, :email, :password, :password_confirmation, :gender, :dob, + :graduated_from, :graduated_year, :department, :profile_image, + :profile_image_cache) } end end diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index 60cf3697..c95d7021 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -10,7 +10,7 @@ class Student < ActiveRecord::Base validates :name, presence: true validates :faculty, presence: true validates :major, presence: true - validates :semester, presence: true, numericality: {only_integer: true, message: "must be a number."} + validates :semester, presence: true, numericality: {only_integer: true, message: "must be a number"} #Relations has_many :solutions, dependent: :destroy diff --git a/tutor/app/models/teaching_assistant.rb b/tutor/app/models/teaching_assistant.rb index 541e789e..798d2acc 100644 --- a/tutor/app/models/teaching_assistant.rb +++ b/tutor/app/models/teaching_assistant.rb @@ -4,7 +4,13 @@ class TeachingAssistant < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable + mount_uploader :profile_image, ProfileImageUploader + #Validations + validates :name, presence: true + validates :graduated_from, presence: true + validates :graduated_year, presence: true, numericality: {only_integer: true, message: "must be a number"} + validates :department, presence: true #Relations has_many :posts, as: :owner, dependent: :destroy diff --git a/tutor/app/views/students/registrations/new.html.erb b/tutor/app/views/students/registrations/new.html.erb index dbb6cca2..26e873dd 100644 --- a/tutor/app/views/students/registrations/new.html.erb +++ b/tutor/app/views/students/registrations/new.html.erb @@ -37,7 +37,7 @@
- <%= f.text_field :semester, class: "form-control", style: "width:300px", placeholder: "Semester"%> + <%= f.number_field :semester, class: "form-control", style: "width:300px", placeholder: "Semester"%>
diff --git a/tutor/app/views/teaching_assistants/registrations/new.html.erb b/tutor/app/views/teaching_assistants/registrations/new.html.erb index 305592e1..558d2f0b 100644 --- a/tutor/app/views/teaching_assistants/registrations/new.html.erb +++ b/tutor/app/views/teaching_assistants/registrations/new.html.erb @@ -1,18 +1,55 @@

Sign up

+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name), :html => {:multipart => true}) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
-<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> - <%= devise_error_messages! %> +
+ <%= f.text_field :name, class: "form-control", style: "width:300px", placeholder: "Name"%> +
-
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+
+ <%= f.password_field :password, autocomplete: "off", class:"form-control", style:"width:300px", placeholder:"Password"%> +
-
<%= f.label :password %>
- <%= f.password_field :password, autocomplete: "off" %>
+
+ <%= f.password_field :password_confirmation, autocomplete: "off", class:"form-control", style:"width:300px",placeholder: "Confirm Password" %> +
-
<%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: "off" %>
+
+ <%= f.label :gender %> + <%= f.select(:gender, [['Male', true], ['Female', false]]) %> +
-
<%= f.submit "Sign up" %>
-<% end %> +
+ <%= f.label :date_of_birth %> + <%= f.date_select :dob, {:start_year => Date.today.year-90, :end_year => Date.today.year} %> +
+ +
+ <%= f.text_field :graduated_from, class: "form-control", style: "width:300px", placeholder: "Graduated From"%> +
+ +
+ <%= f.number_field :graduated_year, class: "form-control", style: "width:300px", placeholder: "Graduation Year"%> +
+ +
+ <%= f.text_field :department, class: "form-control", style: "width:300px", placeholder: "Department"%> +
+ +
+
+ <%= f.label :profile_image %>
+ <%= image_tag(@teaching_assistant.profile_image_url.to_s) if @teaching_assistant.profile_image? %> + <%= f.file_field :profile_image, {:accept => 'image/png,image/gif,image/jpeg'} %> + <%= f.hidden_field :profile_image_cache %> +
+
+ +
<%= f.submit "Sign up", class: "btn btn-success", style: "margin-top:10px" %>
+ <% end %> <%= render "teaching_assistants/shared/links" %> \ No newline at end of file From b6e91902d93cebe6c03de8568d16af9986a0c1ab Mon Sep 17 00:00:00 2001 From: Khaled Date: Sat, 19 Apr 2014 07:27:22 +0200 Subject: [PATCH 022/526] Issue #216 Fixed layout of lecturer --- .../lecturers/confirmations/new.html.erb | 9 ++++--- .../views/lecturers/passwords/edit.html.erb | 12 +++++---- .../views/lecturers/passwords/new.html.erb | 7 ++--- .../app/views/lecturers/sessions/new.html.erb | 26 +++++++++++++------ .../app/views/lecturers/unlocks/new.html.erb | 9 ++++--- tutor/app/views/site/index.html.erb | 5 ++++ tutor/config/locales/devise.en.yml | 6 ++--- 7 files changed, 47 insertions(+), 27 deletions(-) diff --git a/tutor/app/views/lecturers/confirmations/new.html.erb b/tutor/app/views/lecturers/confirmations/new.html.erb index 896c821a..5df570e4 100644 --- a/tutor/app/views/lecturers/confirmations/new.html.erb +++ b/tutor/app/views/lecturers/confirmations/new.html.erb @@ -1,12 +1,13 @@

Resend confirmation instructions

<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> - <%= devise_error_messages! %> + <%= devise_error_messages! %> -
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
-
<%= f.submit "Resend confirmation instructions" %>
+
<%= f.submit "Resend confirmation instructions", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "lecturers/shared/links" %> diff --git a/tutor/app/views/lecturers/passwords/edit.html.erb b/tutor/app/views/lecturers/passwords/edit.html.erb index 3ab4deb8..98cb535f 100644 --- a/tutor/app/views/lecturers/passwords/edit.html.erb +++ b/tutor/app/views/lecturers/passwords/edit.html.erb @@ -4,13 +4,15 @@ <%= devise_error_messages! %> <%= f.hidden_field :reset_password_token %> -
<%= f.label :password, "New password" %>
- <%= f.password_field :password, autofocus: true, autocomplete: "off" %>
+
+ <%= f.password_field :password, autofocus: true, autocomplete: "off", class:"form-control", style:"width:300px", placeholder:"Password"%> +
-
<%= f.label :password_confirmation, "Confirm new password" %>
- <%= f.password_field :password_confirmation, autocomplete: "off" %>
+
+ <%= f.password_field :password_confirmation, autocomplete: "off", class:"form-control", style:"width:300px",placeholder: "Confirm Password" %> +
-
<%= f.submit "Change my password" %>
+
<%= f.submit "Change my password", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "lecturers/shared/links" %> diff --git a/tutor/app/views/lecturers/passwords/new.html.erb b/tutor/app/views/lecturers/passwords/new.html.erb index 16789b88..0e457fee 100644 --- a/tutor/app/views/lecturers/passwords/new.html.erb +++ b/tutor/app/views/lecturers/passwords/new.html.erb @@ -3,10 +3,11 @@ <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> <%= devise_error_messages! %> -
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
-
<%= f.submit "Send me reset password instructions" %>
+
<%= f.submit "Send me reset password instructions", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "lecturers/shared/links" %> diff --git a/tutor/app/views/lecturers/sessions/new.html.erb b/tutor/app/views/lecturers/sessions/new.html.erb index 72eb9c8e..61537a87 100644 --- a/tutor/app/views/lecturers/sessions/new.html.erb +++ b/tutor/app/views/lecturers/sessions/new.html.erb @@ -1,17 +1,27 @@

Sign in

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> -
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+ <% if flash[:alert] %> +
+
+ <%= flash[:alert] %> +
+

+ <% end %> -
<%= f.label :password %>
- <%= f.password_field :password, autocomplete: "off" %>
+
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
- <% if devise_mapping.rememberable? -%> -
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
- <% end -%> +
+ <%= f.password_field :password, autocomplete: "off", class:"form-control", style:"width:300px", placeholder:"Password"%> +
-
<%= f.submit "Sign in" %>
+ <% if devise_mapping.rememberable? -%> +
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
+ <% end -%> + +
<%= f.submit "Sign in", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "lecturers/shared/links" %> diff --git a/tutor/app/views/lecturers/unlocks/new.html.erb b/tutor/app/views/lecturers/unlocks/new.html.erb index 308bb295..b0a48d1c 100644 --- a/tutor/app/views/lecturers/unlocks/new.html.erb +++ b/tutor/app/views/lecturers/unlocks/new.html.erb @@ -1,12 +1,13 @@

Resend unlock instructions

<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> - <%= devise_error_messages! %> + <%= devise_error_messages! %> -
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
-
<%= f.submit "Resend unlock instructions" %>
+
<%= f.submit "Resend unlock instructions", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "lecturers/shared/links" %> diff --git a/tutor/app/views/site/index.html.erb b/tutor/app/views/site/index.html.erb index 47d8fdb4..90b4e6c1 100644 --- a/tutor/app/views/site/index.html.erb +++ b/tutor/app/views/site/index.html.erb @@ -53,6 +53,11 @@ Author: Ahmed Akram --> <% if signed_in? %> + <% if flash[:notice] %> +
+ <%= flash[:notice] %> +
+ <% end %> <%= button_to "My Courses", {:controller => 'courses', :action => 'index'}, class: "btn btn-success", style: "margin-left:auto; margin-right:auto; margin-top: 80px", method: :get %>


<% if(lecturer_signed_in?) %> diff --git a/tutor/config/locales/devise.en.yml b/tutor/config/locales/devise.en.yml index abccdb08..bb64a7d4 100644 --- a/tutor/config/locales/devise.en.yml +++ b/tutor/config/locales/devise.en.yml @@ -18,11 +18,11 @@ en: unconfirmed: "You have to confirm your account before continuing." mailer: confirmation_instructions: - subject: "Confirmation instructions" + subject: "Coolsoft - Confirmation instructions" reset_password_instructions: - subject: "Reset password instructions" + subject: "Coolsoft - Reset password instructions" unlock_instructions: - subject: "Unlock Instructions" + subject: "Coolsoft - Unlock Instructions" omniauth_callbacks: failure: "Could not authenticate you from %{kind} because \"%{reason}\"." success: "Successfully authenticated from %{kind} account." From a31b111bee8a394fc98af044446de204d7bd7d89 Mon Sep 17 00:00:00 2001 From: Khaled Date: Sat, 19 Apr 2014 07:30:57 +0200 Subject: [PATCH 023/526] Issue #216 Fixed layout of student --- .../views/students/confirmations/new.html.erb | 9 ++++--- .../views/students/passwords/edit.html.erb | 12 +++++---- .../app/views/students/passwords/new.html.erb | 7 ++--- .../app/views/students/sessions/new.html.erb | 26 +++++++++++++------ tutor/app/views/students/unlocks/new.html.erb | 9 ++++--- 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/tutor/app/views/students/confirmations/new.html.erb b/tutor/app/views/students/confirmations/new.html.erb index 7d4c997d..a30f26cd 100644 --- a/tutor/app/views/students/confirmations/new.html.erb +++ b/tutor/app/views/students/confirmations/new.html.erb @@ -1,12 +1,13 @@

Resend confirmation instructions

<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> - <%= devise_error_messages! %> + <%= devise_error_messages! %> -
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
-
<%= f.submit "Resend confirmation instructions" %>
+
<%= f.submit "Resend confirmation instructions", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "students/shared/links" %> \ No newline at end of file diff --git a/tutor/app/views/students/passwords/edit.html.erb b/tutor/app/views/students/passwords/edit.html.erb index d302a497..11633403 100644 --- a/tutor/app/views/students/passwords/edit.html.erb +++ b/tutor/app/views/students/passwords/edit.html.erb @@ -4,13 +4,15 @@ <%= devise_error_messages! %> <%= f.hidden_field :reset_password_token %> -
<%= f.label :password, "New password" %>
- <%= f.password_field :password, autofocus: true, autocomplete: "off" %>
+
+ <%= f.password_field :password, autofocus: true, autocomplete: "off", class:"form-control", style:"width:300px", placeholder:"Password"%> +
-
<%= f.label :password_confirmation, "Confirm new password" %>
- <%= f.password_field :password_confirmation, autocomplete: "off" %>
+
+ <%= f.password_field :password_confirmation, autocomplete: "off", class:"form-control", style:"width:300px",placeholder: "Confirm Password" %> +
-
<%= f.submit "Change my password" %>
+
<%= f.submit "Change my password", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "students/shared/links" %> \ No newline at end of file diff --git a/tutor/app/views/students/passwords/new.html.erb b/tutor/app/views/students/passwords/new.html.erb index b17da591..db3fbf09 100644 --- a/tutor/app/views/students/passwords/new.html.erb +++ b/tutor/app/views/students/passwords/new.html.erb @@ -3,10 +3,11 @@ <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> <%= devise_error_messages! %> -
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
-
<%= f.submit "Send me reset password instructions" %>
+
<%= f.submit "Send me reset password instructions", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "students/shared/links" %> \ No newline at end of file diff --git a/tutor/app/views/students/sessions/new.html.erb b/tutor/app/views/students/sessions/new.html.erb index 9f99178a..5e1cf2d7 100644 --- a/tutor/app/views/students/sessions/new.html.erb +++ b/tutor/app/views/students/sessions/new.html.erb @@ -1,17 +1,27 @@

Sign in

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> -
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+ <% if flash[:alert] %> +
+
+ <%= flash[:alert] %> +
+

+ <% end %> -
<%= f.label :password %>
- <%= f.password_field :password, autocomplete: "off" %>
+
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
- <% if devise_mapping.rememberable? -%> -
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
- <% end -%> +
+ <%= f.password_field :password, autocomplete: "off", class:"form-control", style:"width:300px", placeholder:"Password"%> +
-
<%= f.submit "Sign in" %>
+ <% if devise_mapping.rememberable? -%> +
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
+ <% end -%> + +
<%= f.submit "Sign in", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "students/shared/links" %> \ No newline at end of file diff --git a/tutor/app/views/students/unlocks/new.html.erb b/tutor/app/views/students/unlocks/new.html.erb index 32583423..f13e8c20 100644 --- a/tutor/app/views/students/unlocks/new.html.erb +++ b/tutor/app/views/students/unlocks/new.html.erb @@ -1,12 +1,13 @@

Resend unlock instructions

<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> - <%= devise_error_messages! %> + <%= devise_error_messages! %> -
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
-
<%= f.submit "Resend unlock instructions" %>
+
<%= f.submit "Resend unlock instructions", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "students/shared/links" %> \ No newline at end of file From 275437df86ee9b2f073ab43f793a0d2501322f6b Mon Sep 17 00:00:00 2001 From: Khaled Date: Sat, 19 Apr 2014 07:33:56 +0200 Subject: [PATCH 024/526] Issue #216 Fixed layout of teaching_assistant --- .../confirmations/new.html.erb | 9 ++++--- .../passwords/edit.html.erb | 12 +++++---- .../passwords/new.html.erb | 7 ++--- .../teaching_assistants/sessions/new.html.erb | 26 +++++++++++++------ .../teaching_assistants/unlocks/new.html.erb | 9 ++++--- 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/tutor/app/views/teaching_assistants/confirmations/new.html.erb b/tutor/app/views/teaching_assistants/confirmations/new.html.erb index f6b80b4d..94b266c0 100644 --- a/tutor/app/views/teaching_assistants/confirmations/new.html.erb +++ b/tutor/app/views/teaching_assistants/confirmations/new.html.erb @@ -1,12 +1,13 @@

Resend confirmation instructions

<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> - <%= devise_error_messages! %> + <%= devise_error_messages! %> -
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
-
<%= f.submit "Resend confirmation instructions" %>
+
<%= f.submit "Resend confirmation instructions", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "teaching_assistants/shared/links" %> \ No newline at end of file diff --git a/tutor/app/views/teaching_assistants/passwords/edit.html.erb b/tutor/app/views/teaching_assistants/passwords/edit.html.erb index 3477cbc0..aa9b5cb0 100644 --- a/tutor/app/views/teaching_assistants/passwords/edit.html.erb +++ b/tutor/app/views/teaching_assistants/passwords/edit.html.erb @@ -4,13 +4,15 @@ <%= devise_error_messages! %> <%= f.hidden_field :reset_password_token %> -
<%= f.label :password, "New password" %>
- <%= f.password_field :password, autofocus: true, autocomplete: "off" %>
+
+ <%= f.password_field :password, autofocus: true, autocomplete: "off", class:"form-control", style:"width:300px", placeholder:"Password"%> +
-
<%= f.label :password_confirmation, "Confirm new password" %>
- <%= f.password_field :password_confirmation, autocomplete: "off" %>
+
+ <%= f.password_field :password_confirmation, autocomplete: "off", class:"form-control", style:"width:300px",placeholder: "Confirm Password" %> +
-
<%= f.submit "Change my password" %>
+
<%= f.submit "Change my password", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "teaching_assistants/shared/links" %> \ No newline at end of file diff --git a/tutor/app/views/teaching_assistants/passwords/new.html.erb b/tutor/app/views/teaching_assistants/passwords/new.html.erb index db32ee64..8544e455 100644 --- a/tutor/app/views/teaching_assistants/passwords/new.html.erb +++ b/tutor/app/views/teaching_assistants/passwords/new.html.erb @@ -3,10 +3,11 @@ <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> <%= devise_error_messages! %> -
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
-
<%= f.submit "Send me reset password instructions" %>
+
<%= f.submit "Send me reset password instructions", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "teaching_assistants/shared/links" %> \ No newline at end of file diff --git a/tutor/app/views/teaching_assistants/sessions/new.html.erb b/tutor/app/views/teaching_assistants/sessions/new.html.erb index de1d04f4..d9727994 100644 --- a/tutor/app/views/teaching_assistants/sessions/new.html.erb +++ b/tutor/app/views/teaching_assistants/sessions/new.html.erb @@ -1,17 +1,27 @@

Sign in

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> -
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+ <% if flash[:alert] %> +
+
+ <%= flash[:alert] %> +
+

+ <% end %> -
<%= f.label :password %>
- <%= f.password_field :password, autocomplete: "off" %>
+
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
- <% if devise_mapping.rememberable? -%> -
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
- <% end -%> +
+ <%= f.password_field :password, autocomplete: "off", class:"form-control", style:"width:300px", placeholder:"Password"%> +
-
<%= f.submit "Sign in" %>
+ <% if devise_mapping.rememberable? -%> +
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
+ <% end -%> + +
<%= f.submit "Sign in", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "teaching_assistants/shared/links" %> \ No newline at end of file diff --git a/tutor/app/views/teaching_assistants/unlocks/new.html.erb b/tutor/app/views/teaching_assistants/unlocks/new.html.erb index fcb5ac32..467f3d09 100644 --- a/tutor/app/views/teaching_assistants/unlocks/new.html.erb +++ b/tutor/app/views/teaching_assistants/unlocks/new.html.erb @@ -1,12 +1,13 @@

Resend unlock instructions

<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> - <%= devise_error_messages! %> + <%= devise_error_messages! %> -
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %>
+
+ <%= f.email_field :email, autofocus: true, class: "form-control", style: "width:300px", placeholder: "Email"%> +
-
<%= f.submit "Resend unlock instructions" %>
+
<%= f.submit "Resend unlock instructions", class: "btn btn-success", style: "margin-top:10px" %>
<% end %> <%= render "teaching_assistants/shared/links" %> \ No newline at end of file From 279d9b4612f450e9144f0dea2ae79f9ecb95e076 Mon Sep 17 00:00:00 2001 From: Khaled Date: Sat, 19 Apr 2014 08:24:00 +0200 Subject: [PATCH 025/526] Issue #216 Fixed validations of name and number fields --- tutor/app/models/lecturer.rb | 1 + tutor/app/models/student.rb | 3 ++- tutor/app/models/teaching_assistant.rb | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tutor/app/models/lecturer.rb b/tutor/app/models/lecturer.rb index 563a2f96..8a71a4bf 100644 --- a/tutor/app/models/lecturer.rb +++ b/tutor/app/models/lecturer.rb @@ -8,6 +8,7 @@ class Lecturer < ActiveRecord::Base #Validations validates :name, presence: true + validates_format_of :name, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z/ validates :degree, presence: true validates :department, presence: true diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index c95d7021..daa1b216 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -8,9 +8,10 @@ class Student < ActiveRecord::Base #Validations validates :name, presence: true + validates_format_of :name, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z/ validates :faculty, presence: true validates :major, presence: true - validates :semester, presence: true, numericality: {only_integer: true, message: "must be a number"} + validates :semester, presence: true, numericality: {only_integer: true, greater_than: 0, less_than: 11} #Relations has_many :solutions, dependent: :destroy diff --git a/tutor/app/models/teaching_assistant.rb b/tutor/app/models/teaching_assistant.rb index 798d2acc..1a30c6bf 100644 --- a/tutor/app/models/teaching_assistant.rb +++ b/tutor/app/models/teaching_assistant.rb @@ -8,8 +8,10 @@ class TeachingAssistant < ActiveRecord::Base #Validations validates :name, presence: true + validates_format_of :name, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z/ validates :graduated_from, presence: true - validates :graduated_year, presence: true, numericality: {only_integer: true, message: "must be a number"} + validates :graduated_year, presence: true, numericality: {only_integer: true, + greater_than_or_equal_to: Date.today.year-90, less_than_or_equal_to: Date.today.year} validates :department, presence: true #Relations From 617fafa65b6768537b82351eb25a4d9d0ffe7056 Mon Sep 17 00:00:00 2001 From: Khaled Date: Sat, 19 Apr 2014 08:35:10 +0200 Subject: [PATCH 026/526] Issue #216 Fixed validations of degree and number fields --- tutor/app/models/lecturer.rb | 3 ++- tutor/app/models/student.rb | 4 ++-- tutor/app/models/teaching_assistant.rb | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tutor/app/models/lecturer.rb b/tutor/app/models/lecturer.rb index 8a71a4bf..15996534 100644 --- a/tutor/app/models/lecturer.rb +++ b/tutor/app/models/lecturer.rb @@ -8,8 +8,9 @@ class Lecturer < ActiveRecord::Base #Validations validates :name, presence: true - validates_format_of :name, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z/ + validates_format_of :name, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z|\A\z/ validates :degree, presence: true + validates_format_of :degree, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z|\A\z/ validates :department, presence: true #Relations diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index daa1b216..dd8f9fd6 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -8,10 +8,10 @@ class Student < ActiveRecord::Base #Validations validates :name, presence: true - validates_format_of :name, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z/ + validates_format_of :name, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z|\A\z/ validates :faculty, presence: true validates :major, presence: true - validates :semester, presence: true, numericality: {only_integer: true, greater_than: 0, less_than: 11} + validates :semester, presence: false, numericality: {only_integer: true, greater_than: 0, less_than: 11} #Relations has_many :solutions, dependent: :destroy diff --git a/tutor/app/models/teaching_assistant.rb b/tutor/app/models/teaching_assistant.rb index 1a30c6bf..f3d4a104 100644 --- a/tutor/app/models/teaching_assistant.rb +++ b/tutor/app/models/teaching_assistant.rb @@ -8,9 +8,9 @@ class TeachingAssistant < ActiveRecord::Base #Validations validates :name, presence: true - validates_format_of :name, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z/ + validates_format_of :name, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z|\A\z/ validates :graduated_from, presence: true - validates :graduated_year, presence: true, numericality: {only_integer: true, + validates :graduated_year, presence: false, numericality: {only_integer: true, greater_than_or_equal_to: Date.today.year-90, less_than_or_equal_to: Date.today.year} validates :department, presence: true From 20b7041e7f8af89e9c5bf2b442a23c49d0de83f0 Mon Sep 17 00:00:00 2001 From: Khaled Date: Sat, 19 Apr 2014 09:08:25 +0200 Subject: [PATCH 027/526] Issue #216 Fixed validations of duplicate emails across tables --- tutor/app/models/lecturer.rb | 8 ++++++-- tutor/app/models/student.rb | 9 +++++++-- tutor/app/models/teaching_assistant.rb | 8 ++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/tutor/app/models/lecturer.rb b/tutor/app/models/lecturer.rb index 15996534..e1107ba3 100644 --- a/tutor/app/models/lecturer.rb +++ b/tutor/app/models/lecturer.rb @@ -7,6 +7,7 @@ class Lecturer < ActiveRecord::Base mount_uploader :profile_image, ProfileImageUploader #Validations + validate :duplicate_email validates :name, presence: true validates_format_of :name, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z|\A\z/ validates :degree, presence: true @@ -30,8 +31,11 @@ class Lecturer < ActiveRecord::Base has_many :test_cases, as: :owner has_many :hints, as: :owner - #Scoops - #Methods + def duplicate_email + if Student.find_by email: email or TeachingAssistant.find_by email: email + errors.add(:email, "has already been taken") + end + end end diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index dd8f9fd6..68d01d9c 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -7,6 +7,7 @@ class Student < ActiveRecord::Base mount_uploader :profile_image, ProfileImageUploader #Validations + validate :duplicate_email validates :name, presence: true validates_format_of :name, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z|\A\z/ validates :faculty, presence: true @@ -23,10 +24,14 @@ class Student < ActiveRecord::Base has_many :recommended_problems, class_name: 'Problem', through: :recommendations, source: :problem has_and_belongs_to_many :courses, join_table: 'courses_students' - - #Scoops #Methods + def duplicate_email + if Lecturer.find_by email: email or TeachingAssistant.find_by email: email + errors.add(:email, "has already been taken") + end + end + # [Find Recommendations - Story 3.9] # Returns a suggested problem to solve for this user # Parameters: None diff --git a/tutor/app/models/teaching_assistant.rb b/tutor/app/models/teaching_assistant.rb index f3d4a104..5b313511 100644 --- a/tutor/app/models/teaching_assistant.rb +++ b/tutor/app/models/teaching_assistant.rb @@ -7,6 +7,7 @@ class TeachingAssistant < ActiveRecord::Base mount_uploader :profile_image, ProfileImageUploader #Validations + validate :duplicate_email validates :name, presence: true validates_format_of :name, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z|\A\z/ validates :graduated_from, presence: true @@ -29,8 +30,11 @@ class TeachingAssistant < ActiveRecord::Base has_many :test_cases, as: :owner has_many :hints, as: :ownert - #Scoops - #Methods + def duplicate_email + if Student.find_by email: email or Lecturer.find_by email: email + errors.add(:email, "has already been taken") + end + end end From e55f9ce09da2b6c453de1f0f9a7574b5a1dc81d9 Mon Sep 17 00:00:00 2001 From: Linsara Date: Sat, 19 Apr 2014 17:46:19 +0200 Subject: [PATCH 028/526] Issue #182 different drag and drop technique --- tutor/app/controllers/tracks_controller.rb | 4 + tutor/app/views/tracks/index.html.erb | 43 + tutor/app/views/tracks/show.html.erb | 2 + .../vendor/assets/javascripts/jquery-2.1.0.js | 9111 +++++++++++++++++ .../assets/javascripts/jquery.sortable.js | 81 + 5 files changed, 9241 insertions(+) create mode 100644 tutor/app/views/tracks/index.html.erb create mode 100644 tutor/vendor/assets/javascripts/jquery-2.1.0.js create mode 100644 tutor/vendor/assets/javascripts/jquery.sortable.js diff --git a/tutor/app/controllers/tracks_controller.rb b/tutor/app/controllers/tracks_controller.rb index 9a19e3e7..956acd67 100644 --- a/tutor/app/controllers/tracks_controller.rb +++ b/tutor/app/controllers/tracks_controller.rb @@ -70,4 +70,8 @@ def create def permitCreate params.require(:Track).permit(:topic_id , :title , :difficulty) end + + def index + @tracks = Track.all + end end \ No newline at end of file diff --git a/tutor/app/views/tracks/index.html.erb b/tutor/app/views/tracks/index.html.erb new file mode 100644 index 00000000..9e0913f2 --- /dev/null +++ b/tutor/app/views/tracks/index.html.erb @@ -0,0 +1,43 @@ + + +<%= javascript_include_tag 'jquery-2.1.0.js' %> +<%= javascript_include_tag 'jquery.sortable.js'%> + + + +
    + <%- @tracks.each do |track| %> +
  • <%= track.title %>
  • + <% end %> +
+ + + diff --git a/tutor/app/views/tracks/show.html.erb b/tutor/app/views/tracks/show.html.erb index aeb5a7e4..5ea6d7b4 100644 --- a/tutor/app/views/tracks/show.html.erb +++ b/tutor/app/views/tracks/show.html.erb @@ -35,6 +35,8 @@ + <%= button_to "Edit Track Rating", action: "index" %> + diff --git a/tutor/vendor/assets/javascripts/jquery-2.1.0.js b/tutor/vendor/assets/javascripts/jquery-2.1.0.js new file mode 100644 index 00000000..f7f42277 --- /dev/null +++ b/tutor/vendor/assets/javascripts/jquery-2.1.0.js @@ -0,0 +1,9111 @@ +/*! + * jQuery JavaScript Library v2.1.0 + * http://jquery.com/ + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * + * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: 2014-01-23T21:10Z + */ + +(function( global, factory ) { + + if ( typeof module === "object" && typeof module.exports === "object" ) { + // For CommonJS and CommonJS-like environments where a proper window is present, + // execute the factory and get jQuery + // For environments that do not inherently posses a window with a document + // (such as Node.js), expose a jQuery-making factory as module.exports + // This accentuates the need for the creation of a real window + // e.g. var jQuery = require("jquery")(window); + // See ticket #14549 for more info + module.exports = global.document ? + factory( global, true ) : + function( w ) { + if ( !w.document ) { + throw new Error( "jQuery requires a window with a document" ); + } + return factory( w ); + }; + } else { + factory( global ); + } + +// Pass this if window is not defined yet +}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { + +// Can't do this because several apps including ASP.NET trace +// the stack via arguments.caller.callee and Firefox dies if +// you try to trace through "use strict" call chains. (#13335) +// Support: Firefox 18+ +// + +var arr = []; + +var slice = arr.slice; + +var concat = arr.concat; + +var push = arr.push; + +var indexOf = arr.indexOf; + +var class2type = {}; + +var toString = class2type.toString; + +var hasOwn = class2type.hasOwnProperty; + +var trim = "".trim; + +var support = {}; + + + +var + // Use the correct document accordingly with window argument (sandbox) + document = window.document, + + version = "2.1.0", + + // Define a local copy of jQuery + jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + // Need init if jQuery is called (just allow error to be thrown if not included) + return new jQuery.fn.init( selector, context ); + }, + + // Matches dashed string for camelizing + rmsPrefix = /^-ms-/, + rdashAlpha = /-([\da-z])/gi, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return letter.toUpperCase(); + }; + +jQuery.fn = jQuery.prototype = { + // The current version of jQuery being used + jquery: version, + + constructor: jQuery, + + // Start with an empty selector + selector: "", + + // The default length of a jQuery object is 0 + length: 0, + + toArray: function() { + return slice.call( this ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num != null ? + + // Return a 'clean' array + ( num < 0 ? this[ num + this.length ] : this[ num ] ) : + + // Return just the object + slice.call( this ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems ) { + + // Build a new jQuery matched element set + var ret = jQuery.merge( this.constructor(), elems ); + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + ret.context = this.context; + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ) ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + eq: function( i ) { + var len = this.length, + j = +i + ( i < 0 ? len : 0 ); + return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: arr.sort, + splice: arr.splice +}; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + + // skip the boolean and the target + target = arguments[ i ] || {}; + i++; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( i === length ) { + target = this; + i--; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + // Unique for each copy of jQuery on the page + expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), + + // Assume jQuery is ready without the ready module + isReady: true, + + error: function( msg ) { + throw new Error( msg ); + }, + + noop: function() {}, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray, + + isWindow: function( obj ) { + return obj != null && obj === obj.window; + }, + + isNumeric: function( obj ) { + // parseFloat NaNs numeric-cast false positives (null|true|false|"") + // ...but misinterprets leading-number strings, particularly hex literals ("0x...") + // subtraction forces infinities to NaN + return obj - parseFloat( obj ) >= 0; + }, + + isPlainObject: function( obj ) { + // Not plain objects: + // - Any object or value whose internal [[Class]] property is not "[object Object]" + // - DOM nodes + // - window + if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + // Support: Firefox <20 + // The try/catch suppresses exceptions thrown when attempting to access + // the "constructor" property of certain host objects, ie. |window.location| + // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 + try { + if ( obj.constructor && + !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) { + return false; + } + } catch ( e ) { + return false; + } + + // If the function hasn't returned already, we're confident that + // |obj| is a plain object, created by {} or constructed with new Object + return true; + }, + + isEmptyObject: function( obj ) { + var name; + for ( name in obj ) { + return false; + } + return true; + }, + + type: function( obj ) { + if ( obj == null ) { + return obj + ""; + } + // Support: Android < 4.0, iOS < 6 (functionish RegExp) + return typeof obj === "object" || typeof obj === "function" ? + class2type[ toString.call(obj) ] || "object" : + typeof obj; + }, + + // Evaluates a script in a global context + globalEval: function( code ) { + var script, + indirect = eval; + + code = jQuery.trim( code ); + + if ( code ) { + // If the code includes a valid, prologue position + // strict mode pragma, execute code by injecting a + // script tag into the document. + if ( code.indexOf("use strict") === 1 ) { + script = document.createElement("script"); + script.text = code; + document.head.appendChild( script ).parentNode.removeChild( script ); + } else { + // Otherwise, avoid the DOM node creation, insertion + // and removal by using an indirect global eval + indirect( code ); + } + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + }, + + // args is for internal usage only + each: function( obj, callback, args ) { + var value, + i = 0, + length = obj.length, + isArray = isArraylike( obj ); + + if ( args ) { + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback.apply( obj[ i ], args ); + + if ( value === false ) { + break; + } + } + } else { + for ( i in obj ) { + value = callback.apply( obj[ i ], args ); + + if ( value === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback.call( obj[ i ], i, obj[ i ] ); + + if ( value === false ) { + break; + } + } + } else { + for ( i in obj ) { + value = callback.call( obj[ i ], i, obj[ i ] ); + + if ( value === false ) { + break; + } + } + } + } + + return obj; + }, + + trim: function( text ) { + return text == null ? "" : trim.call( text ); + }, + + // results is for internal usage only + makeArray: function( arr, results ) { + var ret = results || []; + + if ( arr != null ) { + if ( isArraylike( Object(arr) ) ) { + jQuery.merge( ret, + typeof arr === "string" ? + [ arr ] : arr + ); + } else { + push.call( ret, arr ); + } + } + + return ret; + }, + + inArray: function( elem, arr, i ) { + return arr == null ? -1 : indexOf.call( arr, elem, i ); + }, + + merge: function( first, second ) { + var len = +second.length, + j = 0, + i = first.length; + + for ( ; j < len; j++ ) { + first[ i++ ] = second[ j ]; + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, invert ) { + var callbackInverse, + matches = [], + i = 0, + length = elems.length, + callbackExpect = !invert; + + // Go through the array, only saving the items + // that pass the validator function + for ( ; i < length; i++ ) { + callbackInverse = !callback( elems[ i ], i ); + if ( callbackInverse !== callbackExpect ) { + matches.push( elems[ i ] ); + } + } + + return matches; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, + i = 0, + length = elems.length, + isArray = isArraylike( elems ), + ret = []; + + // Go through the array, translating each of the items to their new values + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + + // Go through every key on the object, + } else { + for ( i in elems ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + } + + // Flatten any nested arrays + return concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + var tmp, args, proxy; + + if ( typeof context === "string" ) { + tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + args = slice.call( arguments, 2 ); + proxy = function() { + return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || jQuery.guid++; + + return proxy; + }, + + now: Date.now, + + // jQuery.support is not used in Core but other projects attach their + // properties to it so it needs to exist. + support: support +}); + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +function isArraylike( obj ) { + var length = obj.length, + type = jQuery.type( obj ); + + if ( type === "function" || jQuery.isWindow( obj ) ) { + return false; + } + + if ( obj.nodeType === 1 && length ) { + return true; + } + + return type === "array" || length === 0 || + typeof length === "number" && length > 0 && ( length - 1 ) in obj; +} +var Sizzle = +/*! + * Sizzle CSS Selector Engine v1.10.16 + * http://sizzlejs.com/ + * + * Copyright 2013 jQuery Foundation, Inc. and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: 2014-01-13 + */ +(function( window ) { + +var i, + support, + Expr, + getText, + isXML, + compile, + outermostContext, + sortInput, + hasDuplicate, + + // Local document vars + setDocument, + document, + docElem, + documentIsHTML, + rbuggyQSA, + rbuggyMatches, + matches, + contains, + + // Instance-specific data + expando = "sizzle" + -(new Date()), + preferredDoc = window.document, + dirruns = 0, + done = 0, + classCache = createCache(), + tokenCache = createCache(), + compilerCache = createCache(), + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + } + return 0; + }, + + // General-purpose constants + strundefined = typeof undefined, + MAX_NEGATIVE = 1 << 31, + + // Instance methods + hasOwn = ({}).hasOwnProperty, + arr = [], + pop = arr.pop, + push_native = arr.push, + push = arr.push, + slice = arr.slice, + // Use a stripped-down indexOf if we can't use a native one + indexOf = arr.indexOf || function( elem ) { + var i = 0, + len = this.length; + for ( ; i < len; i++ ) { + if ( this[i] === elem ) { + return i; + } + } + return -1; + }, + + booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", + + // Regular expressions + + // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace + whitespace = "[\\x20\\t\\r\\n\\f]", + // http://www.w3.org/TR/css3-syntax/#characters + characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", + + // Loosely modeled on CSS identifier characters + // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors + // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier + identifier = characterEncoding.replace( "w", "w#" ), + + // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors + attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + + "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", + + // Prefer arguments quoted, + // then not containing pseudos/brackets, + // then attribute selectors/non-parenthetical expressions, + // then anything else + // These preferences are here to reduce the number of selectors + // needing tokenize in the PSEUDO preFilter + pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)", + + // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter + rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), + + rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), + rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), + + rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), + + rpseudo = new RegExp( pseudos ), + ridentifier = new RegExp( "^" + identifier + "$" ), + + matchExpr = { + "ID": new RegExp( "^#(" + characterEncoding + ")" ), + "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), + "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), + "ATTR": new RegExp( "^" + attributes ), + "PSEUDO": new RegExp( "^" + pseudos ), + "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), + "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), + // For use in libraries implementing .is() + // We use this for POS matching in `select` + "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) + }, + + rinputs = /^(?:input|select|textarea|button)$/i, + rheader = /^h\d$/i, + + rnative = /^[^{]+\{\s*\[native \w/, + + // Easily-parseable/retrievable ID or TAG or CLASS selectors + rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, + + rsibling = /[+~]/, + rescape = /'|\\/g, + + // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters + runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), + funescape = function( _, escaped, escapedWhitespace ) { + var high = "0x" + escaped - 0x10000; + // NaN means non-codepoint + // Support: Firefox + // Workaround erroneous numeric interpretation of +"0x" + return high !== high || escapedWhitespace ? + escaped : + high < 0 ? + // BMP codepoint + String.fromCharCode( high + 0x10000 ) : + // Supplemental Plane codepoint (surrogate pair) + String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); + }; + +// Optimize for push.apply( _, NodeList ) +try { + push.apply( + (arr = slice.call( preferredDoc.childNodes )), + preferredDoc.childNodes + ); + // Support: Android<4.0 + // Detect silently failing push.apply + arr[ preferredDoc.childNodes.length ].nodeType; +} catch ( e ) { + push = { apply: arr.length ? + + // Leverage slice if possible + function( target, els ) { + push_native.apply( target, slice.call(els) ); + } : + + // Support: IE<9 + // Otherwise append directly + function( target, els ) { + var j = target.length, + i = 0; + // Can't trust NodeList.length + while ( (target[j++] = els[i++]) ) {} + target.length = j - 1; + } + }; +} + +function Sizzle( selector, context, results, seed ) { + var match, elem, m, nodeType, + // QSA vars + i, groups, old, nid, newContext, newSelector; + + if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { + setDocument( context ); + } + + context = context || document; + results = results || []; + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { + return []; + } + + if ( documentIsHTML && !seed ) { + + // Shortcuts + if ( (match = rquickExpr.exec( selector )) ) { + // Speed-up: Sizzle("#ID") + if ( (m = match[1]) ) { + if ( nodeType === 9 ) { + elem = context.getElementById( m ); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document (jQuery #6963) + if ( elem && elem.parentNode ) { + // Handle the case where IE, Opera, and Webkit return items + // by name instead of ID + if ( elem.id === m ) { + results.push( elem ); + return results; + } + } else { + return results; + } + } else { + // Context is not a document + if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && + contains( context, elem ) && elem.id === m ) { + results.push( elem ); + return results; + } + } + + // Speed-up: Sizzle("TAG") + } else if ( match[2] ) { + push.apply( results, context.getElementsByTagName( selector ) ); + return results; + + // Speed-up: Sizzle(".CLASS") + } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) { + push.apply( results, context.getElementsByClassName( m ) ); + return results; + } + } + + // QSA path + if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { + nid = old = expando; + newContext = context; + newSelector = nodeType === 9 && selector; + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + groups = tokenize( selector ); + + if ( (old = context.getAttribute("id")) ) { + nid = old.replace( rescape, "\\$&" ); + } else { + context.setAttribute( "id", nid ); + } + nid = "[id='" + nid + "'] "; + + i = groups.length; + while ( i-- ) { + groups[i] = nid + toSelector( groups[i] ); + } + newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context; + newSelector = groups.join(","); + } + + if ( newSelector ) { + try { + push.apply( results, + newContext.querySelectorAll( newSelector ) + ); + return results; + } catch(qsaError) { + } finally { + if ( !old ) { + context.removeAttribute("id"); + } + } + } + } + } + + // All others + return select( selector.replace( rtrim, "$1" ), context, results, seed ); +} + +/** + * Create key-value caches of limited size + * @returns {Function(string, Object)} Returns the Object data after storing it on itself with + * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) + * deleting the oldest entry + */ +function createCache() { + var keys = []; + + function cache( key, value ) { + // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) + if ( keys.push( key + " " ) > Expr.cacheLength ) { + // Only keep the most recent entries + delete cache[ keys.shift() ]; + } + return (cache[ key + " " ] = value); + } + return cache; +} + +/** + * Mark a function for special use by Sizzle + * @param {Function} fn The function to mark + */ +function markFunction( fn ) { + fn[ expando ] = true; + return fn; +} + +/** + * Support testing using an element + * @param {Function} fn Passed the created div and expects a boolean result + */ +function assert( fn ) { + var div = document.createElement("div"); + + try { + return !!fn( div ); + } catch (e) { + return false; + } finally { + // Remove from its parent by default + if ( div.parentNode ) { + div.parentNode.removeChild( div ); + } + // release memory in IE + div = null; + } +} + +/** + * Adds the same handler for all of the specified attrs + * @param {String} attrs Pipe-separated list of attributes + * @param {Function} handler The method that will be applied + */ +function addHandle( attrs, handler ) { + var arr = attrs.split("|"), + i = attrs.length; + + while ( i-- ) { + Expr.attrHandle[ arr[i] ] = handler; + } +} + +/** + * Checks document order of two siblings + * @param {Element} a + * @param {Element} b + * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b + */ +function siblingCheck( a, b ) { + var cur = b && a, + diff = cur && a.nodeType === 1 && b.nodeType === 1 && + ( ~b.sourceIndex || MAX_NEGATIVE ) - + ( ~a.sourceIndex || MAX_NEGATIVE ); + + // Use IE sourceIndex if available on both nodes + if ( diff ) { + return diff; + } + + // Check if b follows a + if ( cur ) { + while ( (cur = cur.nextSibling) ) { + if ( cur === b ) { + return -1; + } + } + } + + return a ? 1 : -1; +} + +/** + * Returns a function to use in pseudos for input types + * @param {String} type + */ +function createInputPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for buttons + * @param {String} type + */ +function createButtonPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for positionals + * @param {Function} fn + */ +function createPositionalPseudo( fn ) { + return markFunction(function( argument ) { + argument = +argument; + return markFunction(function( seed, matches ) { + var j, + matchIndexes = fn( [], seed.length, argument ), + i = matchIndexes.length; + + // Match elements found at the specified indexes + while ( i-- ) { + if ( seed[ (j = matchIndexes[i]) ] ) { + seed[j] = !(matches[j] = seed[j]); + } + } + }); + }); +} + +/** + * Checks a node for validity as a Sizzle context + * @param {Element|Object=} context + * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value + */ +function testContext( context ) { + return context && typeof context.getElementsByTagName !== strundefined && context; +} + +// Expose support vars for convenience +support = Sizzle.support = {}; + +/** + * Detects XML nodes + * @param {Element|Object} elem An element or a document + * @returns {Boolean} True iff elem is a non-HTML XML node + */ +isXML = Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = elem && (elem.ownerDocument || elem).documentElement; + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +/** + * Sets document-related variables once based on the current document + * @param {Element|Object} [doc] An element or document object to use to set the document + * @returns {Object} Returns the current document + */ +setDocument = Sizzle.setDocument = function( node ) { + var hasCompare, + doc = node ? node.ownerDocument || node : preferredDoc, + parent = doc.defaultView; + + // If no document and documentElement is available, return + if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { + return document; + } + + // Set our document + document = doc; + docElem = doc.documentElement; + + // Support tests + documentIsHTML = !isXML( doc ); + + // Support: IE>8 + // If iframe document is assigned to "document" variable and if iframe has been reloaded, + // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 + // IE6-8 do not support the defaultView property so parent will be undefined + if ( parent && parent !== parent.top ) { + // IE11 does not have attachEvent, so all must suffer + if ( parent.addEventListener ) { + parent.addEventListener( "unload", function() { + setDocument(); + }, false ); + } else if ( parent.attachEvent ) { + parent.attachEvent( "onunload", function() { + setDocument(); + }); + } + } + + /* Attributes + ---------------------------------------------------------------------- */ + + // Support: IE<8 + // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans) + support.attributes = assert(function( div ) { + div.className = "i"; + return !div.getAttribute("className"); + }); + + /* getElement(s)By* + ---------------------------------------------------------------------- */ + + // Check if getElementsByTagName("*") returns only elements + support.getElementsByTagName = assert(function( div ) { + div.appendChild( doc.createComment("") ); + return !div.getElementsByTagName("*").length; + }); + + // Check if getElementsByClassName can be trusted + support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) { + div.innerHTML = "
"; + + // Support: Safari<4 + // Catch class over-caching + div.firstChild.className = "i"; + // Support: Opera<10 + // Catch gEBCN failure to find non-leading classes + return div.getElementsByClassName("i").length === 2; + }); + + // Support: IE<10 + // Check if getElementById returns elements by name + // The broken getElementById methods don't pick up programatically-set names, + // so use a roundabout getElementsByName test + support.getById = assert(function( div ) { + docElem.appendChild( div ).id = expando; + return !doc.getElementsByName || !doc.getElementsByName( expando ).length; + }); + + // ID find and filter + if ( support.getById ) { + Expr.find["ID"] = function( id, context ) { + if ( typeof context.getElementById !== strundefined && documentIsHTML ) { + var m = context.getElementById( id ); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + }; + Expr.filter["ID"] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + return elem.getAttribute("id") === attrId; + }; + }; + } else { + // Support: IE6/7 + // getElementById is not reliable as a find shortcut + delete Expr.find["ID"]; + + Expr.filter["ID"] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); + return node && node.value === attrId; + }; + }; + } + + // Tag + Expr.find["TAG"] = support.getElementsByTagName ? + function( tag, context ) { + if ( typeof context.getElementsByTagName !== strundefined ) { + return context.getElementsByTagName( tag ); + } + } : + function( tag, context ) { + var elem, + tmp = [], + i = 0, + results = context.getElementsByTagName( tag ); + + // Filter out possible comments + if ( tag === "*" ) { + while ( (elem = results[i++]) ) { + if ( elem.nodeType === 1 ) { + tmp.push( elem ); + } + } + + return tmp; + } + return results; + }; + + // Class + Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { + if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) { + return context.getElementsByClassName( className ); + } + }; + + /* QSA/matchesSelector + ---------------------------------------------------------------------- */ + + // QSA and matchesSelector support + + // matchesSelector(:active) reports false when true (IE9/Opera 11.5) + rbuggyMatches = []; + + // qSa(:focus) reports false when true (Chrome 21) + // We allow this because of a bug in IE8/9 that throws an error + // whenever `document.activeElement` is accessed on an iframe + // So, we allow :focus to pass through QSA all the time to avoid the IE error + // See http://bugs.jquery.com/ticket/13378 + rbuggyQSA = []; + + if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { + // Build QSA regex + // Regex strategy adopted from Diego Perini + assert(function( div ) { + // Select is set to empty string on purpose + // This is to test IE's treatment of not explicitly + // setting a boolean content attribute, + // since its presence should be enough + // http://bugs.jquery.com/ticket/12359 + div.innerHTML = ""; + + // Support: IE8, Opera 10-12 + // Nothing should be selected when empty strings follow ^= or $= or *= + if ( div.querySelectorAll("[t^='']").length ) { + rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); + } + + // Support: IE8 + // Boolean attributes and "value" are not treated correctly + if ( !div.querySelectorAll("[selected]").length ) { + rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); + } + + // Webkit/Opera - :checked should return selected option elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + // IE8 throws error here and will not see later tests + if ( !div.querySelectorAll(":checked").length ) { + rbuggyQSA.push(":checked"); + } + }); + + assert(function( div ) { + // Support: Windows 8 Native Apps + // The type and name attributes are restricted during .innerHTML assignment + var input = doc.createElement("input"); + input.setAttribute( "type", "hidden" ); + div.appendChild( input ).setAttribute( "name", "D" ); + + // Support: IE8 + // Enforce case-sensitivity of name attribute + if ( div.querySelectorAll("[name=d]").length ) { + rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); + } + + // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) + // IE8 throws error here and will not see later tests + if ( !div.querySelectorAll(":enabled").length ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } + + // Opera 10-11 does not throw on post-comma invalid pseudos + div.querySelectorAll("*,:x"); + rbuggyQSA.push(",.*:"); + }); + } + + if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector || + docElem.mozMatchesSelector || + docElem.oMatchesSelector || + docElem.msMatchesSelector) )) ) { + + assert(function( div ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9) + support.disconnectedMatch = matches.call( div, "div" ); + + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( div, "[s!='']:x" ); + rbuggyMatches.push( "!=", pseudos ); + }); + } + + rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); + rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); + + /* Contains + ---------------------------------------------------------------------- */ + hasCompare = rnative.test( docElem.compareDocumentPosition ); + + // Element contains another + // Purposefully does not implement inclusive descendent + // As in, an element does not contain itself + contains = hasCompare || rnative.test( docElem.contains ) ? + function( a, b ) { + var adown = a.nodeType === 9 ? a.documentElement : a, + bup = b && b.parentNode; + return a === bup || !!( bup && bup.nodeType === 1 && ( + adown.contains ? + adown.contains( bup ) : + a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 + )); + } : + function( a, b ) { + if ( b ) { + while ( (b = b.parentNode) ) { + if ( b === a ) { + return true; + } + } + } + return false; + }; + + /* Sorting + ---------------------------------------------------------------------- */ + + // Document order sorting + sortOrder = hasCompare ? + function( a, b ) { + + // Flag for duplicate removal + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + // Sort on method existence if only one input has compareDocumentPosition + var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; + if ( compare ) { + return compare; + } + + // Calculate position if both inputs belong to the same document + compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? + a.compareDocumentPosition( b ) : + + // Otherwise we know they are disconnected + 1; + + // Disconnected nodes + if ( compare & 1 || + (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { + + // Choose the first element that is related to our preferred document + if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { + return -1; + } + if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { + return 1; + } + + // Maintain original order + return sortInput ? + ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : + 0; + } + + return compare & 4 ? -1 : 1; + } : + function( a, b ) { + // Exit early if the nodes are identical + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + var cur, + i = 0, + aup = a.parentNode, + bup = b.parentNode, + ap = [ a ], + bp = [ b ]; + + // Parentless nodes are either documents or disconnected + if ( !aup || !bup ) { + return a === doc ? -1 : + b === doc ? 1 : + aup ? -1 : + bup ? 1 : + sortInput ? + ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : + 0; + + // If the nodes are siblings, we can do a quick check + } else if ( aup === bup ) { + return siblingCheck( a, b ); + } + + // Otherwise we need full lists of their ancestors for comparison + cur = a; + while ( (cur = cur.parentNode) ) { + ap.unshift( cur ); + } + cur = b; + while ( (cur = cur.parentNode) ) { + bp.unshift( cur ); + } + + // Walk down the tree looking for a discrepancy + while ( ap[i] === bp[i] ) { + i++; + } + + return i ? + // Do a sibling check if the nodes have a common ancestor + siblingCheck( ap[i], bp[i] ) : + + // Otherwise nodes in our document sort first + ap[i] === preferredDoc ? -1 : + bp[i] === preferredDoc ? 1 : + 0; + }; + + return doc; +}; + +Sizzle.matches = function( expr, elements ) { + return Sizzle( expr, null, null, elements ); +}; + +Sizzle.matchesSelector = function( elem, expr ) { + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } + + // Make sure that attribute selectors are quoted + expr = expr.replace( rattributeQuotes, "='$1']" ); + + if ( support.matchesSelector && documentIsHTML && + ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && + ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { + + try { + var ret = matches.call( elem, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || support.disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9 + elem.document && elem.document.nodeType !== 11 ) { + return ret; + } + } catch(e) {} + } + + return Sizzle( expr, document, null, [elem] ).length > 0; +}; + +Sizzle.contains = function( context, elem ) { + // Set document vars if needed + if ( ( context.ownerDocument || context ) !== document ) { + setDocument( context ); + } + return contains( context, elem ); +}; + +Sizzle.attr = function( elem, name ) { + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } + + var fn = Expr.attrHandle[ name.toLowerCase() ], + // Don't get fooled by Object.prototype properties (jQuery #13807) + val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? + fn( elem, name, !documentIsHTML ) : + undefined; + + return val !== undefined ? + val : + support.attributes || !documentIsHTML ? + elem.getAttribute( name ) : + (val = elem.getAttributeNode(name)) && val.specified ? + val.value : + null; +}; + +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +/** + * Document sorting and removing duplicates + * @param {ArrayLike} results + */ +Sizzle.uniqueSort = function( results ) { + var elem, + duplicates = [], + j = 0, + i = 0; + + // Unless we *know* we can detect duplicates, assume their presence + hasDuplicate = !support.detectDuplicates; + sortInput = !support.sortStable && results.slice( 0 ); + results.sort( sortOrder ); + + if ( hasDuplicate ) { + while ( (elem = results[i++]) ) { + if ( elem === results[ i ] ) { + j = duplicates.push( i ); + } + } + while ( j-- ) { + results.splice( duplicates[ j ], 1 ); + } + } + + // Clear input after sorting to release objects + // See https://github.com/jquery/sizzle/pull/225 + sortInput = null; + + return results; +}; + +/** + * Utility function for retrieving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +getText = Sizzle.getText = function( elem ) { + var node, + ret = "", + i = 0, + nodeType = elem.nodeType; + + if ( !nodeType ) { + // If no nodeType, this is expected to be an array + while ( (node = elem[i++]) ) { + // Do not traverse comment nodes + ret += getText( node ); + } + } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + // Use textContent for elements + // innerText usage removed for consistency of new lines (jQuery #11153) + if ( typeof elem.textContent === "string" ) { + return elem.textContent; + } else { + // Traverse its children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + // Do not include comment or processing instruction nodes + + return ret; +}; + +Expr = Sizzle.selectors = { + + // Can be adjusted by the user + cacheLength: 50, + + createPseudo: markFunction, + + match: matchExpr, + + attrHandle: {}, + + find: {}, + + relative: { + ">": { dir: "parentNode", first: true }, + " ": { dir: "parentNode" }, + "+": { dir: "previousSibling", first: true }, + "~": { dir: "previousSibling" } + }, + + preFilter: { + "ATTR": function( match ) { + match[1] = match[1].replace( runescape, funescape ); + + // Move the given value to match[3] whether quoted or unquoted + match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape ); + + if ( match[2] === "~=" ) { + match[3] = " " + match[3] + " "; + } + + return match.slice( 0, 4 ); + }, + + "CHILD": function( match ) { + /* matches from matchExpr["CHILD"] + 1 type (only|nth|...) + 2 what (child|of-type) + 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) + 4 xn-component of xn+y argument ([+-]?\d*n|) + 5 sign of xn-component + 6 x of xn-component + 7 sign of y-component + 8 y of y-component + */ + match[1] = match[1].toLowerCase(); + + if ( match[1].slice( 0, 3 ) === "nth" ) { + // nth-* requires argument + if ( !match[3] ) { + Sizzle.error( match[0] ); + } + + // numeric x and y parameters for Expr.filter.CHILD + // remember that false/true cast respectively to 0/1 + match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); + match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); + + // other types prohibit arguments + } else if ( match[3] ) { + Sizzle.error( match[0] ); + } + + return match; + }, + + "PSEUDO": function( match ) { + var excess, + unquoted = !match[5] && match[2]; + + if ( matchExpr["CHILD"].test( match[0] ) ) { + return null; + } + + // Accept quoted arguments as-is + if ( match[3] && match[4] !== undefined ) { + match[2] = match[4]; + + // Strip excess characters from unquoted arguments + } else if ( unquoted && rpseudo.test( unquoted ) && + // Get excess from tokenize (recursively) + (excess = tokenize( unquoted, true )) && + // advance to the next closing parenthesis + (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { + + // excess is a negative index + match[0] = match[0].slice( 0, excess ); + match[2] = unquoted.slice( 0, excess ); + } + + // Return only captures needed by the pseudo filter method (type and argument) + return match.slice( 0, 3 ); + } + }, + + filter: { + + "TAG": function( nodeNameSelector ) { + var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); + return nodeNameSelector === "*" ? + function() { return true; } : + function( elem ) { + return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; + }; + }, + + "CLASS": function( className ) { + var pattern = classCache[ className + " " ]; + + return pattern || + (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && + classCache( className, function( elem ) { + return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" ); + }); + }, + + "ATTR": function( name, operator, check ) { + return function( elem ) { + var result = Sizzle.attr( elem, name ); + + if ( result == null ) { + return operator === "!="; + } + if ( !operator ) { + return true; + } + + result += ""; + + return operator === "=" ? result === check : + operator === "!=" ? result !== check : + operator === "^=" ? check && result.indexOf( check ) === 0 : + operator === "*=" ? check && result.indexOf( check ) > -1 : + operator === "$=" ? check && result.slice( -check.length ) === check : + operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : + operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : + false; + }; + }, + + "CHILD": function( type, what, argument, first, last ) { + var simple = type.slice( 0, 3 ) !== "nth", + forward = type.slice( -4 ) !== "last", + ofType = what === "of-type"; + + return first === 1 && last === 0 ? + + // Shortcut for :nth-*(n) + function( elem ) { + return !!elem.parentNode; + } : + + function( elem, context, xml ) { + var cache, outerCache, node, diff, nodeIndex, start, + dir = simple !== forward ? "nextSibling" : "previousSibling", + parent = elem.parentNode, + name = ofType && elem.nodeName.toLowerCase(), + useCache = !xml && !ofType; + + if ( parent ) { + + // :(first|last|only)-(child|of-type) + if ( simple ) { + while ( dir ) { + node = elem; + while ( (node = node[ dir ]) ) { + if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { + return false; + } + } + // Reverse direction for :only-* (if we haven't yet done so) + start = dir = type === "only" && !start && "nextSibling"; + } + return true; + } + + start = [ forward ? parent.firstChild : parent.lastChild ]; + + // non-xml :nth-child(...) stores cache data on `parent` + if ( forward && useCache ) { + // Seek `elem` from a previously-cached index + outerCache = parent[ expando ] || (parent[ expando ] = {}); + cache = outerCache[ type ] || []; + nodeIndex = cache[0] === dirruns && cache[1]; + diff = cache[0] === dirruns && cache[2]; + node = nodeIndex && parent.childNodes[ nodeIndex ]; + + while ( (node = ++nodeIndex && node && node[ dir ] || + + // Fallback to seeking `elem` from the start + (diff = nodeIndex = 0) || start.pop()) ) { + + // When found, cache indexes on `parent` and break + if ( node.nodeType === 1 && ++diff && node === elem ) { + outerCache[ type ] = [ dirruns, nodeIndex, diff ]; + break; + } + } + + // Use previously-cached element index if available + } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { + diff = cache[1]; + + // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) + } else { + // Use the same loop as above to seek `elem` from the start + while ( (node = ++nodeIndex && node && node[ dir ] || + (diff = nodeIndex = 0) || start.pop()) ) { + + if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { + // Cache the index of each encountered element + if ( useCache ) { + (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; + } + + if ( node === elem ) { + break; + } + } + } + } + + // Incorporate the offset, then check against cycle size + diff -= last; + return diff === first || ( diff % first === 0 && diff / first >= 0 ); + } + }; + }, + + "PSEUDO": function( pseudo, argument ) { + // pseudo-class names are case-insensitive + // http://www.w3.org/TR/selectors/#pseudo-classes + // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters + // Remember that setFilters inherits from pseudos + var args, + fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || + Sizzle.error( "unsupported pseudo: " + pseudo ); + + // The user may use createPseudo to indicate that + // arguments are needed to create the filter function + // just as Sizzle does + if ( fn[ expando ] ) { + return fn( argument ); + } + + // But maintain support for old signatures + if ( fn.length > 1 ) { + args = [ pseudo, pseudo, "", argument ]; + return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? + markFunction(function( seed, matches ) { + var idx, + matched = fn( seed, argument ), + i = matched.length; + while ( i-- ) { + idx = indexOf.call( seed, matched[i] ); + seed[ idx ] = !( matches[ idx ] = matched[i] ); + } + }) : + function( elem ) { + return fn( elem, 0, args ); + }; + } + + return fn; + } + }, + + pseudos: { + // Potentially complex pseudos + "not": markFunction(function( selector ) { + // Trim the selector passed to compile + // to avoid treating leading and trailing + // spaces as combinators + var input = [], + results = [], + matcher = compile( selector.replace( rtrim, "$1" ) ); + + return matcher[ expando ] ? + markFunction(function( seed, matches, context, xml ) { + var elem, + unmatched = matcher( seed, null, xml, [] ), + i = seed.length; + + // Match elements unmatched by `matcher` + while ( i-- ) { + if ( (elem = unmatched[i]) ) { + seed[i] = !(matches[i] = elem); + } + } + }) : + function( elem, context, xml ) { + input[0] = elem; + matcher( input, null, xml, results ); + return !results.pop(); + }; + }), + + "has": markFunction(function( selector ) { + return function( elem ) { + return Sizzle( selector, elem ).length > 0; + }; + }), + + "contains": markFunction(function( text ) { + return function( elem ) { + return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; + }; + }), + + // "Whether an element is represented by a :lang() selector + // is based solely on the element's language value + // being equal to the identifier C, + // or beginning with the identifier C immediately followed by "-". + // The matching of C against the element's language value is performed case-insensitively. + // The identifier C does not have to be a valid language name." + // http://www.w3.org/TR/selectors/#lang-pseudo + "lang": markFunction( function( lang ) { + // lang value must be a valid identifier + if ( !ridentifier.test(lang || "") ) { + Sizzle.error( "unsupported lang: " + lang ); + } + lang = lang.replace( runescape, funescape ).toLowerCase(); + return function( elem ) { + var elemLang; + do { + if ( (elemLang = documentIsHTML ? + elem.lang : + elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { + + elemLang = elemLang.toLowerCase(); + return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; + } + } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); + return false; + }; + }), + + // Miscellaneous + "target": function( elem ) { + var hash = window.location && window.location.hash; + return hash && hash.slice( 1 ) === elem.id; + }, + + "root": function( elem ) { + return elem === docElem; + }, + + "focus": function( elem ) { + return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); + }, + + // Boolean properties + "enabled": function( elem ) { + return elem.disabled === false; + }, + + "disabled": function( elem ) { + return elem.disabled === true; + }, + + "checked": function( elem ) { + // In CSS3, :checked should return both checked and selected elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + var nodeName = elem.nodeName.toLowerCase(); + return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); + }, + + "selected": function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + // Contents + "empty": function( elem ) { + // http://www.w3.org/TR/selectors/#empty-pseudo + // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), + // but not by others (comment: 8; processing instruction: 7; etc.) + // nodeType < 6 works because attributes (2) do not appear as children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + if ( elem.nodeType < 6 ) { + return false; + } + } + return true; + }, + + "parent": function( elem ) { + return !Expr.pseudos["empty"]( elem ); + }, + + // Element/input types + "header": function( elem ) { + return rheader.test( elem.nodeName ); + }, + + "input": function( elem ) { + return rinputs.test( elem.nodeName ); + }, + + "button": function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === "button" || name === "button"; + }, + + "text": function( elem ) { + var attr; + return elem.nodeName.toLowerCase() === "input" && + elem.type === "text" && + + // Support: IE<8 + // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" + ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); + }, + + // Position-in-collection + "first": createPositionalPseudo(function() { + return [ 0 ]; + }), + + "last": createPositionalPseudo(function( matchIndexes, length ) { + return [ length - 1 ]; + }), + + "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { + return [ argument < 0 ? argument + length : argument ]; + }), + + "even": createPositionalPseudo(function( matchIndexes, length ) { + var i = 0; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "odd": createPositionalPseudo(function( matchIndexes, length ) { + var i = 1; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; --i >= 0; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; ++i < length; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }) + } +}; + +Expr.pseudos["nth"] = Expr.pseudos["eq"]; + +// Add button/input type pseudos +for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { + Expr.pseudos[ i ] = createInputPseudo( i ); +} +for ( i in { submit: true, reset: true } ) { + Expr.pseudos[ i ] = createButtonPseudo( i ); +} + +// Easy API for creating new setFilters +function setFilters() {} +setFilters.prototype = Expr.filters = Expr.pseudos; +Expr.setFilters = new setFilters(); + +function tokenize( selector, parseOnly ) { + var matched, match, tokens, type, + soFar, groups, preFilters, + cached = tokenCache[ selector + " " ]; + + if ( cached ) { + return parseOnly ? 0 : cached.slice( 0 ); + } + + soFar = selector; + groups = []; + preFilters = Expr.preFilter; + + while ( soFar ) { + + // Comma and first run + if ( !matched || (match = rcomma.exec( soFar )) ) { + if ( match ) { + // Don't consume trailing commas as valid + soFar = soFar.slice( match[0].length ) || soFar; + } + groups.push( (tokens = []) ); + } + + matched = false; + + // Combinators + if ( (match = rcombinators.exec( soFar )) ) { + matched = match.shift(); + tokens.push({ + value: matched, + // Cast descendant combinators to space + type: match[0].replace( rtrim, " " ) + }); + soFar = soFar.slice( matched.length ); + } + + // Filters + for ( type in Expr.filter ) { + if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || + (match = preFilters[ type ]( match ))) ) { + matched = match.shift(); + tokens.push({ + value: matched, + type: type, + matches: match + }); + soFar = soFar.slice( matched.length ); + } + } + + if ( !matched ) { + break; + } + } + + // Return the length of the invalid excess + // if we're just parsing + // Otherwise, throw an error or return tokens + return parseOnly ? + soFar.length : + soFar ? + Sizzle.error( selector ) : + // Cache the tokens + tokenCache( selector, groups ).slice( 0 ); +} + +function toSelector( tokens ) { + var i = 0, + len = tokens.length, + selector = ""; + for ( ; i < len; i++ ) { + selector += tokens[i].value; + } + return selector; +} + +function addCombinator( matcher, combinator, base ) { + var dir = combinator.dir, + checkNonElements = base && dir === "parentNode", + doneName = done++; + + return combinator.first ? + // Check against closest ancestor/preceding element + function( elem, context, xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + return matcher( elem, context, xml ); + } + } + } : + + // Check against all ancestor/preceding elements + function( elem, context, xml ) { + var oldCache, outerCache, + newCache = [ dirruns, doneName ]; + + // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching + if ( xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + if ( matcher( elem, context, xml ) ) { + return true; + } + } + } + } else { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + outerCache = elem[ expando ] || (elem[ expando ] = {}); + if ( (oldCache = outerCache[ dir ]) && + oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { + + // Assign to newCache so results back-propagate to previous elements + return (newCache[ 2 ] = oldCache[ 2 ]); + } else { + // Reuse newcache so results back-propagate to previous elements + outerCache[ dir ] = newCache; + + // A match means we're done; a fail means we have to keep checking + if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { + return true; + } + } + } + } + } + }; +} + +function elementMatcher( matchers ) { + return matchers.length > 1 ? + function( elem, context, xml ) { + var i = matchers.length; + while ( i-- ) { + if ( !matchers[i]( elem, context, xml ) ) { + return false; + } + } + return true; + } : + matchers[0]; +} + +function condense( unmatched, map, filter, context, xml ) { + var elem, + newUnmatched = [], + i = 0, + len = unmatched.length, + mapped = map != null; + + for ( ; i < len; i++ ) { + if ( (elem = unmatched[i]) ) { + if ( !filter || filter( elem, context, xml ) ) { + newUnmatched.push( elem ); + if ( mapped ) { + map.push( i ); + } + } + } + } + + return newUnmatched; +} + +function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { + if ( postFilter && !postFilter[ expando ] ) { + postFilter = setMatcher( postFilter ); + } + if ( postFinder && !postFinder[ expando ] ) { + postFinder = setMatcher( postFinder, postSelector ); + } + return markFunction(function( seed, results, context, xml ) { + var temp, i, elem, + preMap = [], + postMap = [], + preexisting = results.length, + + // Get initial elements from seed or context + elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), + + // Prefilter to get matcher input, preserving a map for seed-results synchronization + matcherIn = preFilter && ( seed || !selector ) ? + condense( elems, preMap, preFilter, context, xml ) : + elems, + + matcherOut = matcher ? + // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, + postFinder || ( seed ? preFilter : preexisting || postFilter ) ? + + // ...intermediate processing is necessary + [] : + + // ...otherwise use results directly + results : + matcherIn; + + // Find primary matches + if ( matcher ) { + matcher( matcherIn, matcherOut, context, xml ); + } + + // Apply postFilter + if ( postFilter ) { + temp = condense( matcherOut, postMap ); + postFilter( temp, [], context, xml ); + + // Un-match failing elements by moving them back to matcherIn + i = temp.length; + while ( i-- ) { + if ( (elem = temp[i]) ) { + matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); + } + } + } + + if ( seed ) { + if ( postFinder || preFilter ) { + if ( postFinder ) { + // Get the final matcherOut by condensing this intermediate into postFinder contexts + temp = []; + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) ) { + // Restore matcherIn since elem is not yet a final match + temp.push( (matcherIn[i] = elem) ); + } + } + postFinder( null, (matcherOut = []), temp, xml ); + } + + // Move matched elements from seed to results to keep them synchronized + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) && + (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { + + seed[temp] = !(results[temp] = elem); + } + } + } + + // Add elements to results, through postFinder if defined + } else { + matcherOut = condense( + matcherOut === results ? + matcherOut.splice( preexisting, matcherOut.length ) : + matcherOut + ); + if ( postFinder ) { + postFinder( null, results, matcherOut, xml ); + } else { + push.apply( results, matcherOut ); + } + } + }); +} + +function matcherFromTokens( tokens ) { + var checkContext, matcher, j, + len = tokens.length, + leadingRelative = Expr.relative[ tokens[0].type ], + implicitRelative = leadingRelative || Expr.relative[" "], + i = leadingRelative ? 1 : 0, + + // The foundational matcher ensures that elements are reachable from top-level context(s) + matchContext = addCombinator( function( elem ) { + return elem === checkContext; + }, implicitRelative, true ), + matchAnyContext = addCombinator( function( elem ) { + return indexOf.call( checkContext, elem ) > -1; + }, implicitRelative, true ), + matchers = [ function( elem, context, xml ) { + return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( + (checkContext = context).nodeType ? + matchContext( elem, context, xml ) : + matchAnyContext( elem, context, xml ) ); + } ]; + + for ( ; i < len; i++ ) { + if ( (matcher = Expr.relative[ tokens[i].type ]) ) { + matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; + } else { + matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); + + // Return special upon seeing a positional matcher + if ( matcher[ expando ] ) { + // Find the next relative operator (if any) for proper handling + j = ++i; + for ( ; j < len; j++ ) { + if ( Expr.relative[ tokens[j].type ] ) { + break; + } + } + return setMatcher( + i > 1 && elementMatcher( matchers ), + i > 1 && toSelector( + // If the preceding token was a descendant combinator, insert an implicit any-element `*` + tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) + ).replace( rtrim, "$1" ), + matcher, + i < j && matcherFromTokens( tokens.slice( i, j ) ), + j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), + j < len && toSelector( tokens ) + ); + } + matchers.push( matcher ); + } + } + + return elementMatcher( matchers ); +} + +function matcherFromGroupMatchers( elementMatchers, setMatchers ) { + var bySet = setMatchers.length > 0, + byElement = elementMatchers.length > 0, + superMatcher = function( seed, context, xml, results, outermost ) { + var elem, j, matcher, + matchedCount = 0, + i = "0", + unmatched = seed && [], + setMatched = [], + contextBackup = outermostContext, + // We must always have either seed elements or outermost context + elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), + // Use integer dirruns iff this is the outermost matcher + dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), + len = elems.length; + + if ( outermost ) { + outermostContext = context !== document && context; + } + + // Add elements passing elementMatchers directly to results + // Keep `i` a string if there are no elements so `matchedCount` will be "00" below + // Support: IE<9, Safari + // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id + for ( ; i !== len && (elem = elems[i]) != null; i++ ) { + if ( byElement && elem ) { + j = 0; + while ( (matcher = elementMatchers[j++]) ) { + if ( matcher( elem, context, xml ) ) { + results.push( elem ); + break; + } + } + if ( outermost ) { + dirruns = dirrunsUnique; + } + } + + // Track unmatched elements for set filters + if ( bySet ) { + // They will have gone through all possible matchers + if ( (elem = !matcher && elem) ) { + matchedCount--; + } + + // Lengthen the array for every element, matched or not + if ( seed ) { + unmatched.push( elem ); + } + } + } + + // Apply set filters to unmatched elements + matchedCount += i; + if ( bySet && i !== matchedCount ) { + j = 0; + while ( (matcher = setMatchers[j++]) ) { + matcher( unmatched, setMatched, context, xml ); + } + + if ( seed ) { + // Reintegrate element matches to eliminate the need for sorting + if ( matchedCount > 0 ) { + while ( i-- ) { + if ( !(unmatched[i] || setMatched[i]) ) { + setMatched[i] = pop.call( results ); + } + } + } + + // Discard index placeholder values to get only actual matches + setMatched = condense( setMatched ); + } + + // Add matches to results + push.apply( results, setMatched ); + + // Seedless set matches succeeding multiple successful matchers stipulate sorting + if ( outermost && !seed && setMatched.length > 0 && + ( matchedCount + setMatchers.length ) > 1 ) { + + Sizzle.uniqueSort( results ); + } + } + + // Override manipulation of globals by nested matchers + if ( outermost ) { + dirruns = dirrunsUnique; + outermostContext = contextBackup; + } + + return unmatched; + }; + + return bySet ? + markFunction( superMatcher ) : + superMatcher; +} + +compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { + var i, + setMatchers = [], + elementMatchers = [], + cached = compilerCache[ selector + " " ]; + + if ( !cached ) { + // Generate a function of recursive functions that can be used to check each element + if ( !group ) { + group = tokenize( selector ); + } + i = group.length; + while ( i-- ) { + cached = matcherFromTokens( group[i] ); + if ( cached[ expando ] ) { + setMatchers.push( cached ); + } else { + elementMatchers.push( cached ); + } + } + + // Cache the compiled function + cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); + } + return cached; +}; + +function multipleContexts( selector, contexts, results ) { + var i = 0, + len = contexts.length; + for ( ; i < len; i++ ) { + Sizzle( selector, contexts[i], results ); + } + return results; +} + +function select( selector, context, results, seed ) { + var i, tokens, token, type, find, + match = tokenize( selector ); + + if ( !seed ) { + // Try to minimize operations if there is only one group + if ( match.length === 1 ) { + + // Take a shortcut and set the context if the root selector is an ID + tokens = match[0] = match[0].slice( 0 ); + if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && + support.getById && context.nodeType === 9 && documentIsHTML && + Expr.relative[ tokens[1].type ] ) { + + context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; + if ( !context ) { + return results; + } + selector = selector.slice( tokens.shift().value.length ); + } + + // Fetch a seed set for right-to-left matching + i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; + while ( i-- ) { + token = tokens[i]; + + // Abort if we hit a combinator + if ( Expr.relative[ (type = token.type) ] ) { + break; + } + if ( (find = Expr.find[ type ]) ) { + // Search, expanding context for leading sibling combinators + if ( (seed = find( + token.matches[0].replace( runescape, funescape ), + rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context + )) ) { + + // If seed is empty or no tokens remain, we can return early + tokens.splice( i, 1 ); + selector = seed.length && toSelector( tokens ); + if ( !selector ) { + push.apply( results, seed ); + return results; + } + + break; + } + } + } + } + } + + // Compile and execute a filtering function + // Provide `match` to avoid retokenization if we modified the selector above + compile( selector, match )( + seed, + context, + !documentIsHTML, + results, + rsibling.test( selector ) && testContext( context.parentNode ) || context + ); + return results; +} + +// One-time assignments + +// Sort stability +support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; + +// Support: Chrome<14 +// Always assume duplicates if they aren't passed to the comparison function +support.detectDuplicates = !!hasDuplicate; + +// Initialize against the default document +setDocument(); + +// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) +// Detached nodes confoundingly follow *each other* +support.sortDetached = assert(function( div1 ) { + // Should return 1, but returns 4 (following) + return div1.compareDocumentPosition( document.createElement("div") ) & 1; +}); + +// Support: IE<8 +// Prevent attribute/property "interpolation" +// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx +if ( !assert(function( div ) { + div.innerHTML = ""; + return div.firstChild.getAttribute("href") === "#" ; +}) ) { + addHandle( "type|href|height|width", function( elem, name, isXML ) { + if ( !isXML ) { + return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); + } + }); +} + +// Support: IE<9 +// Use defaultValue in place of getAttribute("value") +if ( !support.attributes || !assert(function( div ) { + div.innerHTML = ""; + div.firstChild.setAttribute( "value", "" ); + return div.firstChild.getAttribute( "value" ) === ""; +}) ) { + addHandle( "value", function( elem, name, isXML ) { + if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { + return elem.defaultValue; + } + }); +} + +// Support: IE<9 +// Use getAttributeNode to fetch booleans when getAttribute lies +if ( !assert(function( div ) { + return div.getAttribute("disabled") == null; +}) ) { + addHandle( booleans, function( elem, name, isXML ) { + var val; + if ( !isXML ) { + return elem[ name ] === true ? name.toLowerCase() : + (val = elem.getAttributeNode( name )) && val.specified ? + val.value : + null; + } + }); +} + +return Sizzle; + +})( window ); + + + +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.pseudos; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + + +var rneedsContext = jQuery.expr.match.needsContext; + +var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); + + + +var risSimple = /^.[^:#\[\.,]*$/; + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, not ) { + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep( elements, function( elem, i ) { + /* jshint -W018 */ + return !!qualifier.call( elem, i, elem ) !== not; + }); + + } + + if ( qualifier.nodeType ) { + return jQuery.grep( elements, function( elem ) { + return ( elem === qualifier ) !== not; + }); + + } + + if ( typeof qualifier === "string" ) { + if ( risSimple.test( qualifier ) ) { + return jQuery.filter( qualifier, elements, not ); + } + + qualifier = jQuery.filter( qualifier, elements ); + } + + return jQuery.grep( elements, function( elem ) { + return ( indexOf.call( qualifier, elem ) >= 0 ) !== not; + }); +} + +jQuery.filter = function( expr, elems, not ) { + var elem = elems[ 0 ]; + + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 && elem.nodeType === 1 ? + jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : + jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { + return elem.nodeType === 1; + })); +}; + +jQuery.fn.extend({ + find: function( selector ) { + var i, + len = this.length, + ret = [], + self = this; + + if ( typeof selector !== "string" ) { + return this.pushStack( jQuery( selector ).filter(function() { + for ( i = 0; i < len; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }) ); + } + + for ( i = 0; i < len; i++ ) { + jQuery.find( selector, self[ i ], ret ); + } + + // Needed because $( selector, context ) becomes $( context ).find( selector ) + ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); + ret.selector = this.selector ? this.selector + " " + selector : selector; + return ret; + }, + filter: function( selector ) { + return this.pushStack( winnow(this, selector || [], false) ); + }, + not: function( selector ) { + return this.pushStack( winnow(this, selector || [], true) ); + }, + is: function( selector ) { + return !!winnow( + this, + + // If this is a positional/relative selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + typeof selector === "string" && rneedsContext.test( selector ) ? + jQuery( selector ) : + selector || [], + false + ).length; + } +}); + + +// Initialize a jQuery object + + +// A central reference to the root jQuery(document) +var rootjQuery, + + // A simple way to check for HTML strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + // Strict HTML recognition (#11290: must start with <) + rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, + + init = jQuery.fn.init = function( selector, context ) { + var match, elem; + + // HANDLE: $(""), $(null), $(undefined), $(false) + if ( !selector ) { + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = rquickExpr.exec( selector ); + } + + // Match html or make sure no context is specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + + // scripts is true for back-compat + // Intentionally let the error be thrown if parseHTML is not present + jQuery.merge( this, jQuery.parseHTML( + match[1], + context && context.nodeType ? context.ownerDocument || context : document, + true + ) ); + + // HANDLE: $(html, props) + if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { + for ( match in context ) { + // Properties of context are called as methods if possible + if ( jQuery.isFunction( this[ match ] ) ) { + this[ match ]( context[ match ] ); + + // ...and otherwise set as attributes + } else { + this.attr( match, context[ match ] ); + } + } + } + + return this; + + // HANDLE: $(#id) + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || rootjQuery ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(DOMElement) + } else if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return typeof rootjQuery.ready !== "undefined" ? + rootjQuery.ready( selector ) : + // Execute immediately if ready is not present + selector( jQuery ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }; + +// Give the init function the jQuery prototype for later instantiation +init.prototype = jQuery.fn; + +// Initialize central reference +rootjQuery = jQuery( document ); + + +var rparentsprev = /^(?:parents|prev(?:Until|All))/, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.extend({ + dir: function( elem, dir, until ) { + var matched = [], + truncate = until !== undefined; + + while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) { + if ( elem.nodeType === 1 ) { + if ( truncate && jQuery( elem ).is( until ) ) { + break; + } + matched.push( elem ); + } + } + return matched; + }, + + sibling: function( n, elem ) { + var matched = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + matched.push( n ); + } + } + + return matched; + } +}); + +jQuery.fn.extend({ + has: function( target ) { + var targets = jQuery( target, this ), + l = targets.length; + + return this.filter(function() { + var i = 0; + for ( ; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + closest: function( selectors, context ) { + var cur, + i = 0, + l = this.length, + matched = [], + pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( ; i < l; i++ ) { + for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { + // Always skip document fragments + if ( cur.nodeType < 11 && (pos ? + pos.index(cur) > -1 : + + // Don't pass non-elements to Sizzle + cur.nodeType === 1 && + jQuery.find.matchesSelector(cur, selectors)) ) { + + matched.push( cur ); + break; + } + } + } + + return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return indexOf.call( jQuery( elem ), this[ 0 ] ); + } + + // Locate the position of the desired element + return indexOf.call( this, + + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[ 0 ] : elem + ); + }, + + add: function( selector, context ) { + return this.pushStack( + jQuery.unique( + jQuery.merge( this.get(), jQuery( selector, context ) ) + ) + ); + }, + + addBack: function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter(selector) + ); + } +}); + +function sibling( cur, dir ) { + while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {} + return cur; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return sibling( elem, "nextSibling" ); + }, + prev: function( elem ) { + return sibling( elem, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return elem.contentDocument || jQuery.merge( [], elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var matched = jQuery.map( this, fn, until ); + + if ( name.slice( -5 ) !== "Until" ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + matched = jQuery.filter( selector, matched ); + } + + if ( this.length > 1 ) { + // Remove duplicates + if ( !guaranteedUnique[ name ] ) { + jQuery.unique( matched ); + } + + // Reverse order for parents* and prev-derivatives + if ( rparentsprev.test( name ) ) { + matched.reverse(); + } + } + + return this.pushStack( matched ); + }; +}); +var rnotwhite = (/\S+/g); + + + +// String to Object options format cache +var optionsCache = {}; + +// Convert String-formatted options into Object-formatted ones and store in cache +function createOptions( options ) { + var object = optionsCache[ options ] = {}; + jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { + object[ flag ] = true; + }); + return object; +} + +/* + * Create a callback list using the following parameters: + * + * options: an optional list of space-separated options that will change how + * the callback list behaves or a more traditional option object + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible options: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( options ) { + + // Convert options from String-formatted to Object-formatted if needed + // (we check in cache first) + options = typeof options === "string" ? + ( optionsCache[ options ] || createOptions( options ) ) : + jQuery.extend( {}, options ); + + var // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list was already fired + fired, + // Flag to know if list is currently firing + firing, + // First callback to fire (used internally by add and fireWith) + firingStart, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = !options.once && [], + // Fire callbacks + fire = function( data ) { + memory = options.memory && data; + fired = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + firing = true; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { + memory = false; // To prevent further calls using add + break; + } + } + firing = false; + if ( list ) { + if ( stack ) { + if ( stack.length ) { + fire( stack.shift() ); + } + } else if ( memory ) { + list = []; + } else { + self.disable(); + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + // First, we save the current length + var start = list.length; + (function add( args ) { + jQuery.each( args, function( _, arg ) { + var type = jQuery.type( arg ); + if ( type === "function" ) { + if ( !options.unique || !self.has( arg ) ) { + list.push( arg ); + } + } else if ( arg && arg.length && type !== "string" ) { + // Inspect recursively + add( arg ); + } + }); + })( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away + } else if ( memory ) { + firingStart = start; + fire( memory ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + jQuery.each( arguments, function( _, arg ) { + var index; + while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { + list.splice( index, 1 ); + // Handle firing indexes + if ( firing ) { + if ( index <= firingLength ) { + firingLength--; + } + if ( index <= firingIndex ) { + firingIndex--; + } + } + } + }); + } + return this; + }, + // Check if a given callback is in the list. + // If no argument is given, return whether or not list has callbacks attached. + has: function( fn ) { + return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); + }, + // Remove all callbacks from the list + empty: function() { + list = []; + firingLength = 0; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( list && ( !fired || stack ) ) { + args = args || []; + args = [ context, args.slice ? args.slice() : args ]; + if ( firing ) { + stack.push( args ); + } else { + fire( args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!fired; + } + }; + + return self; +}; + + +jQuery.extend({ + + Deferred: function( func ) { + var tuples = [ + // action, add listener, listener list, final state + [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], + [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], + [ "notify", "progress", jQuery.Callbacks("memory") ] + ], + state = "pending", + promise = { + state: function() { + return state; + }, + always: function() { + deferred.done( arguments ).fail( arguments ); + return this; + }, + then: function( /* fnDone, fnFail, fnProgress */ ) { + var fns = arguments; + return jQuery.Deferred(function( newDefer ) { + jQuery.each( tuples, function( i, tuple ) { + var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; + // deferred[ done | fail | progress ] for forwarding actions to newDefer + deferred[ tuple[1] ](function() { + var returned = fn && fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise() + .done( newDefer.resolve ) + .fail( newDefer.reject ) + .progress( newDefer.notify ); + } else { + newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); + } + }); + }); + fns = null; + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + return obj != null ? jQuery.extend( obj, promise ) : promise; + } + }, + deferred = {}; + + // Keep pipe for back-compat + promise.pipe = promise.then; + + // Add list-specific methods + jQuery.each( tuples, function( i, tuple ) { + var list = tuple[ 2 ], + stateString = tuple[ 3 ]; + + // promise[ done | fail | progress ] = list.add + promise[ tuple[1] ] = list.add; + + // Handle state + if ( stateString ) { + list.add(function() { + // state = [ resolved | rejected ] + state = stateString; + + // [ reject_list | resolve_list ].disable; progress_list.lock + }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); + } + + // deferred[ resolve | reject | notify ] + deferred[ tuple[0] ] = function() { + deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); + return this; + }; + deferred[ tuple[0] + "With" ] = list.fireWith; + }); + + // Make the deferred a promise + promise.promise( deferred ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( subordinate /* , ..., subordinateN */ ) { + var i = 0, + resolveValues = slice.call( arguments ), + length = resolveValues.length, + + // the count of uncompleted subordinates + remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, + + // the master Deferred. If resolveValues consist of only a single Deferred, just use that. + deferred = remaining === 1 ? subordinate : jQuery.Deferred(), + + // Update function for both resolve and progress values + updateFunc = function( i, contexts, values ) { + return function( value ) { + contexts[ i ] = this; + values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; + if ( values === progressValues ) { + deferred.notifyWith( contexts, values ); + } else if ( !( --remaining ) ) { + deferred.resolveWith( contexts, values ); + } + }; + }, + + progressValues, progressContexts, resolveContexts; + + // add listeners to Deferred subordinates; treat others as resolved + if ( length > 1 ) { + progressValues = new Array( length ); + progressContexts = new Array( length ); + resolveContexts = new Array( length ); + for ( ; i < length; i++ ) { + if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { + resolveValues[ i ].promise() + .done( updateFunc( i, resolveContexts, resolveValues ) ) + .fail( deferred.reject ) + .progress( updateFunc( i, progressContexts, progressValues ) ); + } else { + --remaining; + } + } + } + + // if we're not waiting on anything, resolve the master + if ( !remaining ) { + deferred.resolveWith( resolveContexts, resolveValues ); + } + + return deferred.promise(); + } +}); + + +// The deferred used on DOM ready +var readyList; + +jQuery.fn.ready = function( fn ) { + // Add the callback + jQuery.ready.promise().done( fn ); + + return this; +}; + +jQuery.extend({ + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { + return; + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger("ready").off("ready"); + } + } +}); + +/** + * The ready event handler and self cleanup method + */ +function completed() { + document.removeEventListener( "DOMContentLoaded", completed, false ); + window.removeEventListener( "load", completed, false ); + jQuery.ready(); +} + +jQuery.ready.promise = function( obj ) { + if ( !readyList ) { + + readyList = jQuery.Deferred(); + + // Catch cases where $(document).ready() is called after the browser event has already occurred. + // we once tried to use readyState "interactive" here, but it caused issues like the one + // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + setTimeout( jQuery.ready ); + + } else { + + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", completed, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", completed, false ); + } + } + return readyList.promise( obj ); +}; + +// Kick off the DOM ready check even if the user does not +jQuery.ready.promise(); + + + + +// Multifunctional method to get and set values of a collection +// The value/s can optionally be executed if it's a function +var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { + var i = 0, + len = elems.length, + bulk = key == null; + + // Sets many values + if ( jQuery.type( key ) === "object" ) { + chainable = true; + for ( i in key ) { + jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); + } + + // Sets one value + } else if ( value !== undefined ) { + chainable = true; + + if ( !jQuery.isFunction( value ) ) { + raw = true; + } + + if ( bulk ) { + // Bulk operations run against the entire set + if ( raw ) { + fn.call( elems, value ); + fn = null; + + // ...except when executing function values + } else { + bulk = fn; + fn = function( elem, key, value ) { + return bulk.call( jQuery( elem ), value ); + }; + } + } + + if ( fn ) { + for ( ; i < len; i++ ) { + fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); + } + } + } + + return chainable ? + elems : + + // Gets + bulk ? + fn.call( elems ) : + len ? fn( elems[0], key ) : emptyGet; +}; + + +/** + * Determines whether an object can have data + */ +jQuery.acceptData = function( owner ) { + // Accepts only: + // - Node + // - Node.ELEMENT_NODE + // - Node.DOCUMENT_NODE + // - Object + // - Any + /* jshint -W018 */ + return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); +}; + + +function Data() { + // Support: Android < 4, + // Old WebKit does not have Object.preventExtensions/freeze method, + // return new empty object instead with no [[set]] accessor + Object.defineProperty( this.cache = {}, 0, { + get: function() { + return {}; + } + }); + + this.expando = jQuery.expando + Math.random(); +} + +Data.uid = 1; +Data.accepts = jQuery.acceptData; + +Data.prototype = { + key: function( owner ) { + // We can accept data for non-element nodes in modern browsers, + // but we should not, see #8335. + // Always return the key for a frozen object. + if ( !Data.accepts( owner ) ) { + return 0; + } + + var descriptor = {}, + // Check if the owner object already has a cache key + unlock = owner[ this.expando ]; + + // If not, create one + if ( !unlock ) { + unlock = Data.uid++; + + // Secure it in a non-enumerable, non-writable property + try { + descriptor[ this.expando ] = { value: unlock }; + Object.defineProperties( owner, descriptor ); + + // Support: Android < 4 + // Fallback to a less secure definition + } catch ( e ) { + descriptor[ this.expando ] = unlock; + jQuery.extend( owner, descriptor ); + } + } + + // Ensure the cache object + if ( !this.cache[ unlock ] ) { + this.cache[ unlock ] = {}; + } + + return unlock; + }, + set: function( owner, data, value ) { + var prop, + // There may be an unlock assigned to this node, + // if there is no entry for this "owner", create one inline + // and set the unlock as though an owner entry had always existed + unlock = this.key( owner ), + cache = this.cache[ unlock ]; + + // Handle: [ owner, key, value ] args + if ( typeof data === "string" ) { + cache[ data ] = value; + + // Handle: [ owner, { properties } ] args + } else { + // Fresh assignments by object are shallow copied + if ( jQuery.isEmptyObject( cache ) ) { + jQuery.extend( this.cache[ unlock ], data ); + // Otherwise, copy the properties one-by-one to the cache object + } else { + for ( prop in data ) { + cache[ prop ] = data[ prop ]; + } + } + } + return cache; + }, + get: function( owner, key ) { + // Either a valid cache is found, or will be created. + // New caches will be created and the unlock returned, + // allowing direct access to the newly created + // empty data object. A valid owner object must be provided. + var cache = this.cache[ this.key( owner ) ]; + + return key === undefined ? + cache : cache[ key ]; + }, + access: function( owner, key, value ) { + var stored; + // In cases where either: + // + // 1. No key was specified + // 2. A string key was specified, but no value provided + // + // Take the "read" path and allow the get method to determine + // which value to return, respectively either: + // + // 1. The entire cache object + // 2. The data stored at the key + // + if ( key === undefined || + ((key && typeof key === "string") && value === undefined) ) { + + stored = this.get( owner, key ); + + return stored !== undefined ? + stored : this.get( owner, jQuery.camelCase(key) ); + } + + // [*]When the key is not a string, or both a key and value + // are specified, set or extend (existing objects) with either: + // + // 1. An object of properties + // 2. A key and value + // + this.set( owner, key, value ); + + // Since the "set" path can have two possible entry points + // return the expected data based on which path was taken[*] + return value !== undefined ? value : key; + }, + remove: function( owner, key ) { + var i, name, camel, + unlock = this.key( owner ), + cache = this.cache[ unlock ]; + + if ( key === undefined ) { + this.cache[ unlock ] = {}; + + } else { + // Support array or space separated string of keys + if ( jQuery.isArray( key ) ) { + // If "name" is an array of keys... + // When data is initially created, via ("key", "val") signature, + // keys will be converted to camelCase. + // Since there is no way to tell _how_ a key was added, remove + // both plain key and camelCase key. #12786 + // This will only penalize the array argument path. + name = key.concat( key.map( jQuery.camelCase ) ); + } else { + camel = jQuery.camelCase( key ); + // Try the string as a key before any manipulation + if ( key in cache ) { + name = [ key, camel ]; + } else { + // If a key with the spaces exists, use it. + // Otherwise, create an array by matching non-whitespace + name = camel; + name = name in cache ? + [ name ] : ( name.match( rnotwhite ) || [] ); + } + } + + i = name.length; + while ( i-- ) { + delete cache[ name[ i ] ]; + } + } + }, + hasData: function( owner ) { + return !jQuery.isEmptyObject( + this.cache[ owner[ this.expando ] ] || {} + ); + }, + discard: function( owner ) { + if ( owner[ this.expando ] ) { + delete this.cache[ owner[ this.expando ] ]; + } + } +}; +var data_priv = new Data(); + +var data_user = new Data(); + + + +/* + Implementation Summary + + 1. Enforce API surface and semantic compatibility with 1.9.x branch + 2. Improve the module's maintainability by reducing the storage + paths to a single mechanism. + 3. Use the same single mechanism to support "private" and "user" data. + 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) + 5. Avoid exposing implementation details on user objects (eg. expando properties) + 6. Provide a clear path for implementation upgrade to WeakMap in 2014 +*/ +var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, + rmultiDash = /([A-Z])/g; + +function dataAttr( elem, key, data ) { + var name; + + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + // Only convert to a number if it doesn't change the string + +data + "" === data ? +data : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + data_user.set( elem, key, data ); + } else { + data = undefined; + } + } + return data; +} + +jQuery.extend({ + hasData: function( elem ) { + return data_user.hasData( elem ) || data_priv.hasData( elem ); + }, + + data: function( elem, name, data ) { + return data_user.access( elem, name, data ); + }, + + removeData: function( elem, name ) { + data_user.remove( elem, name ); + }, + + // TODO: Now that all calls to _data and _removeData have been replaced + // with direct calls to data_priv methods, these can be deprecated. + _data: function( elem, name, data ) { + return data_priv.access( elem, name, data ); + }, + + _removeData: function( elem, name ) { + data_priv.remove( elem, name ); + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var i, name, data, + elem = this[ 0 ], + attrs = elem && elem.attributes; + + // Gets all values + if ( key === undefined ) { + if ( this.length ) { + data = data_user.get( elem ); + + if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) { + i = attrs.length; + while ( i-- ) { + name = attrs[ i ].name; + + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.slice(5) ); + dataAttr( elem, name, data[ name ] ); + } + } + data_priv.set( elem, "hasDataAttrs", true ); + } + } + + return data; + } + + // Sets multiple values + if ( typeof key === "object" ) { + return this.each(function() { + data_user.set( this, key ); + }); + } + + return access( this, function( value ) { + var data, + camelKey = jQuery.camelCase( key ); + + // The calling jQuery object (element matches) is not empty + // (and therefore has an element appears at this[ 0 ]) and the + // `value` parameter was not undefined. An empty jQuery object + // will result in `undefined` for elem = this[ 0 ] which will + // throw an exception if an attempt to read a data cache is made. + if ( elem && value === undefined ) { + // Attempt to get data from the cache + // with the key as-is + data = data_user.get( elem, key ); + if ( data !== undefined ) { + return data; + } + + // Attempt to get data from the cache + // with the key camelized + data = data_user.get( elem, camelKey ); + if ( data !== undefined ) { + return data; + } + + // Attempt to "discover" the data in + // HTML5 custom data-* attrs + data = dataAttr( elem, camelKey, undefined ); + if ( data !== undefined ) { + return data; + } + + // We tried really hard, but the data doesn't exist. + return; + } + + // Set the data... + this.each(function() { + // First, attempt to store a copy or reference of any + // data that might've been store with a camelCased key. + var data = data_user.get( this, camelKey ); + + // For HTML5 data-* attribute interop, we have to + // store property names with dashes in a camelCase form. + // This might not apply to all properties...* + data_user.set( this, camelKey, value ); + + // *... In the case of properties that might _actually_ + // have dashes, we need to also store a copy of that + // unchanged property. + if ( key.indexOf("-") !== -1 && data !== undefined ) { + data_user.set( this, key, value ); + } + }); + }, null, value, arguments.length > 1, null, true ); + }, + + removeData: function( key ) { + return this.each(function() { + data_user.remove( this, key ); + }); + } +}); + + +jQuery.extend({ + queue: function( elem, type, data ) { + var queue; + + if ( elem ) { + type = ( type || "fx" ) + "queue"; + queue = data_priv.get( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !queue || jQuery.isArray( data ) ) { + queue = data_priv.access( elem, type, jQuery.makeArray(data) ); + } else { + queue.push( data ); + } + } + return queue || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + startLength = queue.length, + fn = queue.shift(), + hooks = jQuery._queueHooks( elem, type ), + next = function() { + jQuery.dequeue( elem, type ); + }; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + startLength--; + } + + if ( fn ) { + + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + // clear up the last queue stop function + delete hooks.stop; + fn.call( elem, next, hooks ); + } + + if ( !startLength && hooks ) { + hooks.empty.fire(); + } + }, + + // not intended for public consumption - generates a queueHooks object, or returns the current one + _queueHooks: function( elem, type ) { + var key = type + "queueHooks"; + return data_priv.get( elem, key ) || data_priv.access( elem, key, { + empty: jQuery.Callbacks("once memory").add(function() { + data_priv.remove( elem, [ type + "queue", key ] ); + }) + }); + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + var setter = 2; + + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + setter--; + } + + if ( arguments.length < setter ) { + return jQuery.queue( this[0], type ); + } + + return data === undefined ? + this : + this.each(function() { + var queue = jQuery.queue( this, type, data ); + + // ensure a hooks for this queue + jQuery._queueHooks( this, type ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, obj ) { + var tmp, + count = 1, + defer = jQuery.Deferred(), + elements = this, + i = this.length, + resolve = function() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + }; + + if ( typeof type !== "string" ) { + obj = type; + type = undefined; + } + type = type || "fx"; + + while ( i-- ) { + tmp = data_priv.get( elements[ i ], type + "queueHooks" ); + if ( tmp && tmp.empty ) { + count++; + tmp.empty.add( resolve ); + } + } + resolve(); + return defer.promise( obj ); + } +}); +var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; + +var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; + +var isHidden = function( elem, el ) { + // isHidden might be called from jQuery#filter function; + // in that case, element will be second argument + elem = el || elem; + return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); + }; + +var rcheckableType = (/^(?:checkbox|radio)$/i); + + + +(function() { + var fragment = document.createDocumentFragment(), + div = fragment.appendChild( document.createElement( "div" ) ); + + // #11217 - WebKit loses check when the name is after the checked attribute + div.innerHTML = ""; + + // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 + // old WebKit doesn't clone checked state correctly in fragments + support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Make sure textarea (and checkbox) defaultValue is properly cloned + // Support: IE9-IE11+ + div.innerHTML = ""; + support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; +})(); +var strundefined = typeof undefined; + + + +support.focusinBubbles = "onfocusin" in window; + + +var + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|contextmenu)|click/, + rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; + +function returnTrue() { + return true; +} + +function returnFalse() { + return false; +} + +function safeActiveElement() { + try { + return document.activeElement; + } catch ( err ) { } +} + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + global: {}, + + add: function( elem, types, handler, data, selector ) { + + var handleObjIn, eventHandle, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = data_priv.get( elem ); + + // Don't attach events to noData or text/comment nodes (but allow plain objects) + if ( !elemData ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + selector = handleObjIn.selector; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + if ( !(events = elemData.events) ) { + events = elemData.events = {}; + } + if ( !(eventHandle = elemData.handle) ) { + eventHandle = elemData.handle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ? + jQuery.event.dispatch.apply( elem, arguments ) : undefined; + }; + } + + // Handle multiple events separated by a space + types = ( types || "" ).match( rnotwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[t] ) || []; + type = origType = tmp[1]; + namespaces = ( tmp[2] || "" ).split( "." ).sort(); + + // There *must* be a type, no attaching namespace-only handlers + if ( !type ) { + continue; + } + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: origType, + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + needsContext: selector && jQuery.expr.match.needsContext.test( selector ), + namespace: namespaces.join(".") + }, handleObjIn ); + + // Init the event handler queue if we're the first + if ( !(handlers = events[ type ]) ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener if the special events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + }, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + + var j, origCount, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = data_priv.hasData( elem ) && data_priv.get( elem ); + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = ( types || "" ).match( rnotwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[t] ) || []; + type = origType = tmp[1]; + namespaces = ( tmp[2] || "" ).split( "." ).sort(); + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector ? special.delegateType : special.bindType ) || type; + handlers = events[ type ] || []; + tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); + + // Remove matching events + origCount = j = handlers.length; + while ( j-- ) { + handleObj = handlers[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !tmp || tmp.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + handlers.splice( j, 1 ); + + if ( handleObj.selector ) { + handlers.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( origCount && !handlers.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + delete elemData.handle; + data_priv.remove( elem, "events" ); + } + }, + + trigger: function( event, data, elem, onlyHandlers ) { + + var i, cur, tmp, bubbleType, ontype, handle, special, + eventPath = [ elem || document ], + type = hasOwn.call( event, "type" ) ? event.type : event, + namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; + + cur = tmp = elem = elem || document; + + // Don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf(".") >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + ontype = type.indexOf(":") < 0 && "on" + type; + + // Caller can pass in a jQuery.Event object, Object, or just an event type string + event = event[ jQuery.expando ] ? + event : + new jQuery.Event( type, typeof event === "object" && event ); + + // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) + event.isTrigger = onlyHandlers ? 2 : 3; + event.namespace = namespaces.join("."); + event.namespace_re = event.namespace ? + new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : + null; + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data == null ? + [ event ] : + jQuery.makeArray( data, [ event ] ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + if ( !rfocusMorph.test( bubbleType + type ) ) { + cur = cur.parentNode; + } + for ( ; cur; cur = cur.parentNode ) { + eventPath.push( cur ); + tmp = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( tmp === (elem.ownerDocument || document) ) { + eventPath.push( tmp.defaultView || tmp.parentWindow || window ); + } + } + + // Fire handlers on the event path + i = 0; + while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { + + event.type = i > 1 ? + bubbleType : + special.bindType || type; + + // jQuery handler + handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + + // Native handler + handle = ontype && cur[ ontype ]; + if ( handle && handle.apply && jQuery.acceptData( cur ) ) { + event.result = handle.apply( cur, data ); + if ( event.result === false ) { + event.preventDefault(); + } + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && + jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Don't do default actions on window, that's where global variables be (#6170) + if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + tmp = elem[ ontype ]; + + if ( tmp ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + elem[ type ](); + jQuery.event.triggered = undefined; + + if ( tmp ) { + elem[ ontype ] = tmp; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event ); + + var i, j, ret, matched, handleObj, + handlerQueue = [], + args = slice.call( arguments ), + handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [], + special = jQuery.event.special[ event.type ] || {}; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Call the preDispatch hook for the mapped type, and let it bail if desired + if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { + return; + } + + // Determine handlers + handlerQueue = jQuery.event.handlers.call( this, event, handlers ); + + // Run delegates first; they may want to stop propagation beneath us + i = 0; + while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { + event.currentTarget = matched.elem; + + j = 0; + while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { + + // Triggered event must either 1) have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { + + event.handleObj = handleObj; + event.data = handleObj.data; + + ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) + .apply( matched.elem, args ); + + if ( ret !== undefined ) { + if ( (event.result = ret) === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + // Call the postDispatch hook for the mapped type + if ( special.postDispatch ) { + special.postDispatch.call( this, event ); + } + + return event.result; + }, + + handlers: function( event, handlers ) { + var i, matches, sel, handleObj, + handlerQueue = [], + delegateCount = handlers.delegateCount, + cur = event.target; + + // Find delegate handlers + // Black-hole SVG instance trees (#13180) + // Avoid non-left-click bubbling in Firefox (#3861) + if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { + + for ( ; cur !== this; cur = cur.parentNode || this ) { + + // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) + if ( cur.disabled !== true || event.type !== "click" ) { + matches = []; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + + // Don't conflict with Object.prototype properties (#13203) + sel = handleObj.selector + " "; + + if ( matches[ sel ] === undefined ) { + matches[ sel ] = handleObj.needsContext ? + jQuery( sel, this ).index( cur ) >= 0 : + jQuery.find( sel, this, null, [ cur ] ).length; + } + if ( matches[ sel ] ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, handlers: matches }); + } + } + } + } + + // Add the remaining (directly-bound) handlers + if ( delegateCount < handlers.length ) { + handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); + } + + return handlerQueue; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, copy, + type = event.type, + originalEvent = event, + fixHook = this.fixHooks[ type ]; + + if ( !fixHook ) { + this.fixHooks[ type ] = fixHook = + rmouseEvent.test( type ) ? this.mouseHooks : + rkeyEvent.test( type ) ? this.keyHooks : + {}; + } + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = new jQuery.Event( originalEvent ); + + i = copy.length; + while ( i-- ) { + prop = copy[ i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Support: Cordova 2.5 (WebKit) (#13255) + // All events should have a target; Cordova deviceready doesn't + if ( !event.target ) { + event.target = document; + } + + // Support: Safari 6.0+, Chrome < 28 + // Target should not be a text node (#504, #13143) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; + }, + + special: { + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + focus: { + // Fire native event if possible so blur/focus sequence is correct + trigger: function() { + if ( this !== safeActiveElement() && this.focus ) { + this.focus(); + return false; + } + }, + delegateType: "focusin" + }, + blur: { + trigger: function() { + if ( this === safeActiveElement() && this.blur ) { + this.blur(); + return false; + } + }, + delegateType: "focusout" + }, + click: { + // For checkbox, fire native event so checked state will be right + trigger: function() { + if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { + this.click(); + return false; + } + }, + + // For cross-browser consistency, don't fire native .click() on links + _default: function( event ) { + return jQuery.nodeName( event.target, "a" ); + } + }, + + beforeunload: { + postDispatch: function( event ) { + + // Support: Firefox 20+ + // Firefox doesn't alert if the returnValue field is not set. + if ( event.result !== undefined ) { + event.originalEvent.returnValue = event.result; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { + type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } +}; + +jQuery.removeEvent = function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } +}; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = src.defaultPrevented || + // Support: Android < 4.0 + src.defaultPrevented === undefined && + src.getPreventDefault && src.getPreventDefault() ? + returnTrue : + returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse, + + preventDefault: function() { + var e = this.originalEvent; + + this.isDefaultPrevented = returnTrue; + + if ( e && e.preventDefault ) { + e.preventDefault(); + } + }, + stopPropagation: function() { + var e = this.originalEvent; + + this.isPropagationStopped = returnTrue; + + if ( e && e.stopPropagation ) { + e.stopPropagation(); + } + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + } +}; + +// Create mouseenter/leave events using mouseover/out and event-time checks +// Support: Chrome 15+ +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var ret, + target = this, + related = event.relatedTarget, + handleObj = event.handleObj; + + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || (related !== target && !jQuery.contains( target, related )) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +}); + +// Create "bubbling" focus and blur events +// Support: Firefox, Chrome, Safari +if ( !support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler on the document while someone wants focusin/focusout + var handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + var doc = this.ownerDocument || this, + attaches = data_priv.access( doc, fix ); + + if ( !attaches ) { + doc.addEventListener( orig, handler, true ); + } + data_priv.access( doc, fix, ( attaches || 0 ) + 1 ); + }, + teardown: function() { + var doc = this.ownerDocument || this, + attaches = data_priv.access( doc, fix ) - 1; + + if ( !attaches ) { + doc.removeEventListener( orig, handler, true ); + data_priv.remove( doc, fix ); + + } else { + data_priv.access( doc, fix, attaches ); + } + } + }; + }); +} + +jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + // ( types-Object, data ) + data = data || selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on( types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + var handleObj, type; + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + var elem = this[0]; + if ( elem ) { + return jQuery.event.trigger( type, data, elem, true ); + } + } +}); + + +var + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, + rtagName = /<([\w:]+)/, + rhtml = /<|&#?\w+;/, + rnoInnerhtml = /<(?:script|style|link)/i, + // checked="checked" or checked + rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, + rscriptType = /^$|\/(?:java|ecma)script/i, + rscriptTypeMasked = /^true\/(.*)/, + rcleanScript = /^\s*\s*$/g, + + // We have to close these tags to support XHTML (#13200) + wrapMap = { + + // Support: IE 9 + option: [ 1, "" ], + + thead: [ 1, "", "
" ], + col: [ 2, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + + _default: [ 0, "", "" ] + }; + +// Support: IE 9 +wrapMap.optgroup = wrapMap.option; + +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// Support: 1.x compatibility +// Manipulating tables requires a tbody +function manipulationTarget( elem, content ) { + return jQuery.nodeName( elem, "table" ) && + jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? + + elem.getElementsByTagName("tbody")[0] || + elem.appendChild( elem.ownerDocument.createElement("tbody") ) : + elem; +} + +// Replace/restore the type attribute of script elements for safe DOM manipulation +function disableScript( elem ) { + elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type; + return elem; +} +function restoreScript( elem ) { + var match = rscriptTypeMasked.exec( elem.type ); + + if ( match ) { + elem.type = match[ 1 ]; + } else { + elem.removeAttribute("type"); + } + + return elem; +} + +// Mark scripts as having already been evaluated +function setGlobalEval( elems, refElements ) { + var i = 0, + l = elems.length; + + for ( ; i < l; i++ ) { + data_priv.set( + elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" ) + ); + } +} + +function cloneCopyEvent( src, dest ) { + var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; + + if ( dest.nodeType !== 1 ) { + return; + } + + // 1. Copy private data: events, handlers, etc. + if ( data_priv.hasData( src ) ) { + pdataOld = data_priv.access( src ); + pdataCur = data_priv.set( dest, pdataOld ); + events = pdataOld.events; + + if ( events ) { + delete pdataCur.handle; + pdataCur.events = {}; + + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type, events[ type ][ i ] ); + } + } + } + } + + // 2. Copy user data + if ( data_user.hasData( src ) ) { + udataOld = data_user.access( src ); + udataCur = jQuery.extend( {}, udataOld ); + + data_user.set( dest, udataCur ); + } +} + +function getAll( context, tag ) { + var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) : + context.querySelectorAll ? context.querySelectorAll( tag || "*" ) : + []; + + return tag === undefined || tag && jQuery.nodeName( context, tag ) ? + jQuery.merge( [ context ], ret ) : + ret; +} + +// Support: IE >= 9 +function fixInput( src, dest ) { + var nodeName = dest.nodeName.toLowerCase(); + + // Fails to persist the checked state of a cloned checkbox or radio button. + if ( nodeName === "input" && rcheckableType.test( src.type ) ) { + dest.checked = src.checked; + + // Fails to return the selected option to the default selected state when cloning options + } else if ( nodeName === "input" || nodeName === "textarea" ) { + dest.defaultValue = src.defaultValue; + } +} + +jQuery.extend({ + clone: function( elem, dataAndEvents, deepDataAndEvents ) { + var i, l, srcElements, destElements, + clone = elem.cloneNode( true ), + inPage = jQuery.contains( elem.ownerDocument, elem ); + + // Support: IE >= 9 + // Fix Cloning issues + if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && + !jQuery.isXMLDoc( elem ) ) { + + // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 + destElements = getAll( clone ); + srcElements = getAll( elem ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + fixInput( srcElements[ i ], destElements[ i ] ); + } + } + + // Copy the events from the original to the clone + if ( dataAndEvents ) { + if ( deepDataAndEvents ) { + srcElements = srcElements || getAll( elem ); + destElements = destElements || getAll( clone ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + cloneCopyEvent( srcElements[ i ], destElements[ i ] ); + } + } else { + cloneCopyEvent( elem, clone ); + } + } + + // Preserve script evaluation history + destElements = getAll( clone, "script" ); + if ( destElements.length > 0 ) { + setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); + } + + // Return the cloned set + return clone; + }, + + buildFragment: function( elems, context, scripts, selection ) { + var elem, tmp, tag, wrap, contains, j, + fragment = context.createDocumentFragment(), + nodes = [], + i = 0, + l = elems.length; + + for ( ; i < l; i++ ) { + elem = elems[ i ]; + + if ( elem || elem === 0 ) { + + // Add nodes directly + if ( jQuery.type( elem ) === "object" ) { + // Support: QtWebKit + // jQuery.merge because push.apply(_, arraylike) throws + jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); + + // Convert non-html into a text node + } else if ( !rhtml.test( elem ) ) { + nodes.push( context.createTextNode( elem ) ); + + // Convert html into DOM nodes + } else { + tmp = tmp || fragment.appendChild( context.createElement("div") ); + + // Deserialize a standard representation + tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); + wrap = wrapMap[ tag ] || wrapMap._default; + tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1>" ) + wrap[ 2 ]; + + // Descend through wrappers to the right content + j = wrap[ 0 ]; + while ( j-- ) { + tmp = tmp.lastChild; + } + + // Support: QtWebKit + // jQuery.merge because push.apply(_, arraylike) throws + jQuery.merge( nodes, tmp.childNodes ); + + // Remember the top-level container + tmp = fragment.firstChild; + + // Fixes #12346 + // Support: Webkit, IE + tmp.textContent = ""; + } + } + } + + // Remove wrapper from fragment + fragment.textContent = ""; + + i = 0; + while ( (elem = nodes[ i++ ]) ) { + + // #4087 - If origin and destination elements are the same, and this is + // that element, do not do anything + if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { + continue; + } + + contains = jQuery.contains( elem.ownerDocument, elem ); + + // Append to fragment + tmp = getAll( fragment.appendChild( elem ), "script" ); + + // Preserve script evaluation history + if ( contains ) { + setGlobalEval( tmp ); + } + + // Capture executables + if ( scripts ) { + j = 0; + while ( (elem = tmp[ j++ ]) ) { + if ( rscriptType.test( elem.type || "" ) ) { + scripts.push( elem ); + } + } + } + } + + return fragment; + }, + + cleanData: function( elems ) { + var data, elem, events, type, key, j, + special = jQuery.event.special, + i = 0; + + for ( ; (elem = elems[ i ]) !== undefined; i++ ) { + if ( jQuery.acceptData( elem ) ) { + key = elem[ data_priv.expando ]; + + if ( key && (data = data_priv.cache[ key ]) ) { + events = Object.keys( data.events || {} ); + if ( events.length ) { + for ( j = 0; (type = events[j]) !== undefined; j++ ) { + if ( special[ type ] ) { + jQuery.event.remove( elem, type ); + + // This is a shortcut to avoid jQuery.event.remove's overhead + } else { + jQuery.removeEvent( elem, type, data.handle ); + } + } + } + if ( data_priv.cache[ key ] ) { + // Discard any remaining `private` data + delete data_priv.cache[ key ]; + } + } + } + // Discard any remaining `user` data + delete data_user.cache[ elem[ data_user.expando ] ]; + } + } +}); + +jQuery.fn.extend({ + text: function( value ) { + return access( this, function( value ) { + return value === undefined ? + jQuery.text( this ) : + this.empty().each(function() { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + this.textContent = value; + } + }); + }, null, value, arguments.length ); + }, + + append: function() { + return this.domManip( arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.appendChild( elem ); + } + }); + }, + + prepend: function() { + return this.domManip( arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.insertBefore( elem, target.firstChild ); + } + }); + }, + + before: function() { + return this.domManip( arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this ); + } + }); + }, + + after: function() { + return this.domManip( arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this.nextSibling ); + } + }); + }, + + remove: function( selector, keepData /* Internal Use Only */ ) { + var elem, + elems = selector ? jQuery.filter( selector, this ) : this, + i = 0; + + for ( ; (elem = elems[i]) != null; i++ ) { + if ( !keepData && elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem ) ); + } + + if ( elem.parentNode ) { + if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { + setGlobalEval( getAll( elem, "script" ) ); + } + elem.parentNode.removeChild( elem ); + } + } + + return this; + }, + + empty: function() { + var elem, + i = 0; + + for ( ; (elem = this[i]) != null; i++ ) { + if ( elem.nodeType === 1 ) { + + // Prevent memory leaks + jQuery.cleanData( getAll( elem, false ) ); + + // Remove any remaining nodes + elem.textContent = ""; + } + } + + return this; + }, + + clone: function( dataAndEvents, deepDataAndEvents ) { + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; + + return this.map(function() { + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); + }); + }, + + html: function( value ) { + return access( this, function( value ) { + var elem = this[ 0 ] || {}, + i = 0, + l = this.length; + + if ( value === undefined && elem.nodeType === 1 ) { + return elem.innerHTML; + } + + // See if we can take a shortcut and just use innerHTML + if ( typeof value === "string" && !rnoInnerhtml.test( value ) && + !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { + + value = value.replace( rxhtmlTag, "<$1>" ); + + try { + for ( ; i < l; i++ ) { + elem = this[ i ] || {}; + + // Remove element nodes and prevent memory leaks + if ( elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem, false ) ); + elem.innerHTML = value; + } + } + + elem = 0; + + // If using innerHTML throws an exception, use the fallback method + } catch( e ) {} + } + + if ( elem ) { + this.empty().append( value ); + } + }, null, value, arguments.length ); + }, + + replaceWith: function() { + var arg = arguments[ 0 ]; + + // Make the changes, replacing each context element with the new content + this.domManip( arguments, function( elem ) { + arg = this.parentNode; + + jQuery.cleanData( getAll( this ) ); + + if ( arg ) { + arg.replaceChild( elem, this ); + } + }); + + // Force removal if there was no new content (e.g., from empty arguments) + return arg && (arg.length || arg.nodeType) ? this : this.remove(); + }, + + detach: function( selector ) { + return this.remove( selector, true ); + }, + + domManip: function( args, callback ) { + + // Flatten any nested arrays + args = concat.apply( [], args ); + + var fragment, first, scripts, hasScripts, node, doc, + i = 0, + l = this.length, + set = this, + iNoClone = l - 1, + value = args[ 0 ], + isFunction = jQuery.isFunction( value ); + + // We can't cloneNode fragments that contain checked, in WebKit + if ( isFunction || + ( l > 1 && typeof value === "string" && + !support.checkClone && rchecked.test( value ) ) ) { + return this.each(function( index ) { + var self = set.eq( index ); + if ( isFunction ) { + args[ 0 ] = value.call( this, index, self.html() ); + } + self.domManip( args, callback ); + }); + } + + if ( l ) { + fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this ); + first = fragment.firstChild; + + if ( fragment.childNodes.length === 1 ) { + fragment = first; + } + + if ( first ) { + scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); + hasScripts = scripts.length; + + // Use the original fragment for the last item instead of the first because it can end up + // being emptied incorrectly in certain situations (#8070). + for ( ; i < l; i++ ) { + node = fragment; + + if ( i !== iNoClone ) { + node = jQuery.clone( node, true, true ); + + // Keep references to cloned scripts for later restoration + if ( hasScripts ) { + // Support: QtWebKit + // jQuery.merge because push.apply(_, arraylike) throws + jQuery.merge( scripts, getAll( node, "script" ) ); + } + } + + callback.call( this[ i ], node, i ); + } + + if ( hasScripts ) { + doc = scripts[ scripts.length - 1 ].ownerDocument; + + // Reenable scripts + jQuery.map( scripts, restoreScript ); + + // Evaluate executable scripts on first document insertion + for ( i = 0; i < hasScripts; i++ ) { + node = scripts[ i ]; + if ( rscriptType.test( node.type || "" ) && + !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) { + + if ( node.src ) { + // Optional AJAX dependency, but won't run scripts if not present + if ( jQuery._evalUrl ) { + jQuery._evalUrl( node.src ); + } + } else { + jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); + } + } + } + } + } + } + + return this; + } +}); + +jQuery.each({ + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" +}, function( name, original ) { + jQuery.fn[ name ] = function( selector ) { + var elems, + ret = [], + insert = jQuery( selector ), + last = insert.length - 1, + i = 0; + + for ( ; i <= last; i++ ) { + elems = i === last ? this : this.clone( true ); + jQuery( insert[ i ] )[ original ]( elems ); + + // Support: QtWebKit + // .get() because push.apply(_, arraylike) throws + push.apply( ret, elems.get() ); + } + + return this.pushStack( ret ); + }; +}); + + +var iframe, + elemdisplay = {}; + +/** + * Retrieve the actual display of a element + * @param {String} name nodeName of the element + * @param {Object} doc Document object + */ +// Called only from within defaultDisplay +function actualDisplay( name, doc ) { + var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), + + // getDefaultComputedStyle might be reliably used only on attached element + display = window.getDefaultComputedStyle ? + + // Use of this method is a temporary fix (more like optmization) until something better comes along, + // since it was removed from specification and supported only in FF + window.getDefaultComputedStyle( elem[ 0 ] ).display : jQuery.css( elem[ 0 ], "display" ); + + // We don't have any data stored on the element, + // so use "detach" method as fast way to get rid of the element + elem.detach(); + + return display; +} + +/** + * Try to determine the default display value of an element + * @param {String} nodeName + */ +function defaultDisplay( nodeName ) { + var doc = document, + display = elemdisplay[ nodeName ]; + + if ( !display ) { + display = actualDisplay( nodeName, doc ); + + // If the simple way fails, read from inside an iframe + if ( display === "none" || !display ) { + + // Use the already-created iframe if possible + iframe = (iframe || jQuery( "");h.appendTo(a.contentContainer);r=c.outerHeight(!0);s=c.outerWidth(!0);A();h.attr("src",a.loadUrl);k(a.loadCallback);break;case "image":A();b("").load(function(){k(a.loadCallback);G(b(this))}).attr("src",a.loadUrl).hide().appendTo(a.contentContainer);break;default:A(),b('
').load(a.loadUrl,a.loadData,function(){k(a.loadCallback);G(b(this))}).hide().appendTo(a.contentContainer)}}function A(){a.modal&&b('
').css({backgroundColor:a.modalColor,position:"fixed",top:0,right:0,bottom:0,left:0,opacity:0,zIndex:a.zIndex+t}).appendTo(a.appendTo).fadeTo(a.speed,a.opacity);D();c.data("bPopup",a).data("id",e).css({left:"slideIn"==a.transition||"slideBack"==a.transition?"slideBack"==a.transition?g.scrollLeft()+u:-1*(v+s):l(!(!a.follow[0]&&m||f)),position:a.positionStyle||"absolute",top:"slideDown"==a.transition||"slideUp"==a.transition?"slideUp"==a.transition?g.scrollTop()+w:x+-1*r:n(!(!a.follow[1]&&p||f)),"z-index":a.zIndex+t+1}).each(function(){a.appending&&b(this).appendTo(a.appendTo)});H(!0)}function q(){a.modal&&b(".b-modal."+c.data("id")).fadeTo(a.speed,0,function(){b(this).remove()});a.scrollBar||b("html").css("overflow","auto");b(".b-modal."+e).unbind("click");g.unbind("keydown."+e);d.unbind("."+e).data("bPopup",0=c.height()&&(d.height=c.height());b>=c.width()&&(d.width=c.width());r=c.outerHeight(!0);s=c.outerWidth(!0);D();a.contentContainer.css({height:"auto",width:"auto"});d.left=l(!(!a.follow[0]&&m||f));d.top=n(!(!a.follow[1]&&p||f));c.animate(d,250,function(){h.show();B=E()})}function L(){d.data("bPopup",t);c.delegate(".bClose, ."+a.closeClass,"click."+e,q);a.modalClose&&b(".b-modal."+e).css("cursor","pointer").bind("click",q);M||!a.follow[0]&&!a.follow[1]||d.bind("scroll."+e,function(){B&&c.dequeue().animate({left:a.follow[0]?l(!f):"auto",top:a.follow[1]?n(!f):"auto"},a.followSpeed,a.followEasing)}).bind("resize."+e,function(){w=y.innerHeight||d.height();u=y.innerWidth||d.width();if(B=E())clearTimeout(I),I=setTimeout(function(){D();c.dequeue().each(function(){f?b(this).css({left:v,top:x}):b(this).animate({left:a.follow[0]?l(!0):"auto",top:a.follow[1]?n(!0):"auto"},a.followSpeed,a.followEasing)})},50)});a.escClose&&g.bind("keydown."+e,function(a){27==a.which&&q()})}function H(b){function d(e){c.css({display:"block",opacity:1}).animate(e,a.speed,a.easing,function(){J(b)})}switch(b?a.transition:a.transitionClose||a.transition){case "slideIn":d({left:b?l(!(!a.follow[0]&&m||f)):g.scrollLeft()-(s||c.outerWidth(!0))-C});break;case "slideBack":d({left:b?l(!(!a.follow[0]&&m||f)):g.scrollLeft()+u+C});break;case "slideDown":d({top:b?n(!(!a.follow[1]&&p||f)):g.scrollTop()-(r||c.outerHeight(!0))-C});break;case "slideUp":d({top:b?n(!(!a.follow[1]&&p||f)):g.scrollTop()+w+C});break;default:c.stop().fadeTo(a.speed,b?1:0,function(){J(b)})}}function J(b){b?(L(),k(F),a.autoClose&&setTimeout(q,a.autoClose)):(c.hide(),k(a.onClose),a.loadUrl&&(a.contentContainer.empty(),c.css({height:"auto",width:"auto"})))}function l(a){return a?v+g.scrollLeft():v}function n(a){return a?x+g.scrollTop():x}function k(a){b.isFunction(a)&&a.call(c)}function D(){x=p?a.position[1]:Math.max(0,(w-c.outerHeight(!0))/2-a.amsl);v=m?a.position[0]:(u-c.outerWidth(!0))/2;B=E()}function E(){return w>c.outerHeight(!0)&&u>c.outerWidth(!0)}b.isFunction(z)&&(F=z,z=null);var a=b.extend({},b.fn.bPopup.defaults,z);a.scrollBar||b("html").css("overflow","hidden");var c=this,g=b(document),y=window,d=b(y),w=y.innerHeight||d.height(),u=y.innerWidth||d.width(),M=/OS 6(_\d)+/i.test(navigator.userAgent),C=200,t=0,e,B,p,m,f,x,v,r,s,I;c.close=function(){a=this.data("bPopup");e="__b-popup"+d.data("bPopup")+"__";q()};return c.each(function(){b(this).data("bPopup")||(k(a.onOpen),t=(d.data("bPopup")||0)+1,e="__b-popup"+t+"__",p="auto"!==a.position[1],m="auto"!==a.position[0],f="fixed"===a.positionStyle,r=c.outerHeight(!0),s=c.outerWidth(!0),a.loadUrl?K():A())})};b.fn.bPopup.defaults={amsl:50,appending:!0,appendTo:"body",autoClose:!1,closeClass:"b-close",content:"ajax",contentContainer:!1,easing:"swing",escClose:!0,follow:[!0,!0],followEasing:"swing",followSpeed:500,iframeAttr:'scrolling="no" frameborder="0"',loadCallback:!1,loadData:!1,loadUrl:!1,modal:!0,modalClose:!0,modalColor:"#000",onClose:!1,onOpen:!1,opacity:0.7,position:["auto","auto"],positionStyle:"absolute",scrollBar:!0,speed:250,transition:"fadeIn",transitionClose:!1,zIndex:9997}})(jQuery); \ No newline at end of file diff --git a/tutor/app/assets/javascripts/tracks.js b/tutor/app/assets/javascripts/tracks.js new file mode 100644 index 00000000..5fe1949c --- /dev/null +++ b/tutor/app/assets/javascripts/tracks.js @@ -0,0 +1,15 @@ +// Semicolon (;) to ensure closing of earlier scripting +// Encapsulation +// $ is assigned to jQuery +; +(function ($) { + // DOM Ready + $(function () { + // Binding a click event + // From jQuery v.1.7.0 use .on() instead of .bind() + $('#my-button1').bind('click', function (e) { + e.preventDefault(); + $('#element_to_pop_up').bPopup(); + }); + }); +})(jQuery); diff --git a/tutor/app/assets/stylesheets/tracks.css b/tutor/app/assets/stylesheets/tracks.css new file mode 100644 index 00000000..cd66111d --- /dev/null +++ b/tutor/app/assets/stylesheets/tracks.css @@ -0,0 +1,9 @@ +#element_to_pop_up { + background-color:#fff; + border-radius:10px; + color:#000; + display:none; + padding:10px; + min-width:100px; + min-height: 100px; + } \ No newline at end of file From 796b5693fcfe27c91e4acd90c0ade93fa31134d4 Mon Sep 17 00:00:00 2001 From: Ahmed ELAssuty Date: Mon, 21 Apr 2014 14:25:34 +0200 Subject: [PATCH 098/526] Issue #221 fix documentation --- tutor/app/models/course.rb | 2 +- tutor/app/views/layouts/application.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tutor/app/models/course.rb b/tutor/app/models/course.rb index 34faf7fe..75479857 100644 --- a/tutor/app/models/course.rb +++ b/tutor/app/models/course.rb @@ -33,7 +33,7 @@ def can_edit(user) end # [Simple Search - Story 1.22] - # search for users + # search for courses # Parameters: keyword # Returns: A hash with search results according to the keyword # Author: Ahmed Elassuty diff --git a/tutor/app/views/layouts/application.html.erb b/tutor/app/views/layouts/application.html.erb index 27cd9a3b..9920c619 100644 --- a/tutor/app/views/layouts/application.html.erb +++ b/tutor/app/views/layouts/application.html.erb @@ -8,7 +8,7 @@ CoolSoft - Java Tutor <%= stylesheet_link_tag "application", "bootstrap", :media => "all"%> - <%= javascript_include_tag "application","bootstrap","jquery"%> + <%= javascript_include_tag "application","bootstrap", "jquery"%> <%= csrf_meta_tags%> From cc63e8aa8fe8bdc036fa5c2ec3831766ece100fc Mon Sep 17 00:00:00 2001 From: metawaa Date: Mon, 21 Apr 2014 14:29:39 +0200 Subject: [PATCH 099/526] Adding documentation --- tutor/app/controllers/courses_controller.rb | 7 +++- tutor/app/views/courses/show.html.erb | 46 ++++++++++----------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/tutor/app/controllers/courses_controller.rb b/tutor/app/controllers/courses_controller.rb index 8459c814..00d89eac 100644 --- a/tutor/app/controllers/courses_controller.rb +++ b/tutor/app/controllers/courses_controller.rb @@ -135,7 +135,12 @@ def edit @course = Course.find_by_id(params[:id]) @discussionBoard = @course.discussion_board end - + # [View a course - story 1.21] + #Description: This action is resposible for the view of a specific course. + #Parameters: + # id: Course id + # Returns: The view of the requested course + # Author: Mohamed Metawaa def show @course = Course.find_by_id(params[:id]) if @course diff --git a/tutor/app/views/courses/show.html.erb b/tutor/app/views/courses/show.html.erb index e77d5236..a21e50f3 100644 --- a/tutor/app/views/courses/show.html.erb +++ b/tutor/app/views/courses/show.html.erb @@ -24,27 +24,27 @@
- <% @topics.each do |t| %> -
-
- - <%= link_to t.title , t , style: 'color:#003366;'%> - <%= t.tracks.count %> -
-
-
    - <% t.tracks.each do |p|%> - <% color = "label label-default" %> -
  • - <%= link_to p.title , p , class: color %> -
  • - <% end %> -
-
-
- <% end %> -
+ <% @topics.each do |t| %> +
+
+ + <%= link_to t.title , t , style: 'color:#003366;'%> + <%= t.tracks.count %> +
+
+
    + <% t.tracks.each do |tt|%> + <% color = "label label-default" %> +
  • + <%= link_to tt.title , tt , class: color %> +
  • + <% end %> +
+
+
+ <% end %> +
\ No newline at end of file From 16c3f97106cbc107ca34a8bfb5fca7b3b6cdadc9 Mon Sep 17 00:00:00 2001 From: AbdullRahman ElHusseini Date: Mon, 21 Apr 2014 14:32:36 +0200 Subject: [PATCH 100/526] Issue #208 linking with track & failure demos 2 --- tutor/app/controllers/problems_controller.rb | 7 +++++-- .../views/problems/_failure_options.html.erb | 7 +++---- tutor/app/views/problems/edit.html.erb | 4 ++-- tutor/app/views/tracks/show.html.erb | 4 ++-- tutor/config/routes.rb | 7 ++++++- tutor/db/development.sqlite3 | Bin 208896 -> 208896 bytes 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tutor/app/controllers/problems_controller.rb b/tutor/app/controllers/problems_controller.rb index 7a82be3b..41bf6630 100644 --- a/tutor/app/controllers/problems_controller.rb +++ b/tutor/app/controllers/problems_controller.rb @@ -32,6 +32,7 @@ def create p.owner_id = current_teaching_assistant.id p.owner_type = "teaching assistant" end + p.incomplete = true p.track_id = params[:id] if p.save redirect_to :action => "edit", :id => p.id @@ -52,6 +53,7 @@ def edit @problem = Problem.find_by_id(params[:id]) @test_cases = @problem.test_cases @answers = @problem.model_answers + @track = Track.find_by_id(@problem.track_id) else render ('public/404') end @@ -83,7 +85,7 @@ def update end def done - @problem = Problem.find_by_id(params[:id]) + @problem = Problem.find_by_id(params[:problem_id]) if @problem.test_cases.empty? @failure = true flash.keep[:notice] = "Test cases are empty #{@failure}" @@ -93,12 +95,13 @@ def done flash.keep[:notice] = "Answers are empty" redirect_to :back else + @problem.incomplete = false redirect_to :action => "show", :id => @problem.id end end def destroy_problem - @problem = Problem.find_by_id(params[:id]) + @problem = Problem.find_by_id(params[:problem_id]) @problem.test_cases.destroy @problem.model_answers.destroy @problem.destroy diff --git a/tutor/app/views/problems/_failure_options.html.erb b/tutor/app/views/problems/_failure_options.html.erb index 0af8b5d4..28ae175a 100644 --- a/tutor/app/views/problems/_failure_options.html.erb +++ b/tutor/app/views/problems/_failure_options.html.erb @@ -1,4 +1,3 @@ -<%= button_to "Abort and Delete Problem", action: "destroy_problem" , id: @problem.id %> -<%= button_to "Save as Incomplete", action: "done" , id: @problem.id %> - - \ No newline at end of file + +<%= button_to 'Abort and Delete Problem', problem_destroy_problem_path(:problem_id => @problem.id), method: :get, :confirm => 'Are you sure?' %> +<%= button_to 'Save as Incomplete', problem_path(:id => @problem.id), method: :get %> \ No newline at end of file diff --git a/tutor/app/views/problems/edit.html.erb b/tutor/app/views/problems/edit.html.erb index 009bfcec..552efe0b 100644 --- a/tutor/app/views/problems/edit.html.erb +++ b/tutor/app/views/problems/edit.html.erb @@ -21,9 +21,9 @@ and a paragraph to view the problem description of the instance variable @proble <% end %> <%= render partial: "test_cases/index" %> <%= render partial: "model_answers/new" %> - - +<%= button_to 'Done', problem_done_path(:problem_id => @problem.id), method: :get %> <%= render partial: "problems/failure_options" %> + <% if flash[:notice] %>
<%= flash[:notice] %>
diff --git a/tutor/app/views/tracks/show.html.erb b/tutor/app/views/tracks/show.html.erb index 1239b292..9ff4b63d 100644 --- a/tutor/app/views/tracks/show.html.erb +++ b/tutor/app/views/tracks/show.html.erb @@ -31,7 +31,7 @@ <%= link_to p.title , p , style: 'color:#003366;' , class: color %> - +
<%= p.description %> @@ -41,6 +41,6 @@ <% end %>
-<% if @can_edit %> +<% if true %> <% end %> \ No newline at end of file diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index e9d7079c..834e6dbc 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -27,7 +27,7 @@ resources :model_answers resources :problems_by_tas resources :solutions - resources :problems + resources :topics # Example resource route with options: @@ -54,6 +54,11 @@ resources :model_answers do post "model_answers/new" end + + resources :problems do + get 'done' + get 'destroy_problem' + end # Example resource route with sub-resources: # resources :products do # resources :comments, :sales diff --git a/tutor/db/development.sqlite3 b/tutor/db/development.sqlite3 index a268d354fc1fbca450d22f088990194c49f49eb9..c624d4befd16aa15c9f007dc878af6bcf0b5146d 100644 GIT binary patch delta 4273 zcmZu!TWlN072O%?VLiyDpHlqL!>;15-XW~?pL`t;Y5*b-a zQF-%|0BM1wY&vy;!cO3#?MLiZZp5HK8zVtK(iXK_py*HR#`$PkG>L*VAE})*y(BG? z=5nQ7kbCCNoSA#?xtAB;FTD7E;Y+)>;Uz&3DBK6(MsPoPxk@R9w?{uH&xWs9{2ZPF z74M6miyOauW?9?{Ukjt}imcu6++`K4x&K;ygp?7bhR8LVE)ms`iK)m$Ju0h56&tcv zS0th>H;Oy6<)oP*feFzSyV)iZZdxVD@k}xeS(gp__)R2yb(I`WEY2iDBTUmXjgKKW zzFw_aP0nvfI+fu+Z9J(VhD3GK)YS0U*9TI^s|IB>BmX!OUVC&rh2bW(&mZM)5<~eF z+AbcA^CvYjkqDJ#U9*i(Am7CNRS_NL=S7tNkQdm=Fq;Z|?RJ|8zbqm>)d0>^qjq92 zRUBD&qyIP)1}c$sP1EG`lO;8PfQxj)~*6ea($bX`$ZGT(9OC4f)#@ z-$<`#fHg^HJ(E(G5zw^8K(pDl)YE#V%WI<@n^aSYonHds*Gkaw)r9AD3EV>Ubbhf= zeTdXe`9_1G1>b@+Iy+sVcq@opai(jsZ*ZB&^ny0+t?%|Po?lewLft2gR)3&x#oyoV z9h{Y#XZ^w6Ha6FMwzp|&W;tN(L%W31Xm;@PrKmiWgsKoqGlZ)y#SxN;gnz27r=`Vj zj-Os?od|WBr#$s)Psq2}I@s@D?jN6*MuO~Q!}!8Ve<)}!kfjOMJJ*^I%R9t%LHs0= zUxvP@uDT;^6W$SocaV;5;%$y^cviQ&tdI?+E{NF?9 zFWAcAzkL#Y2V1$k^(piRY;EC1=g^zj%Hy}sp&wx@Km41VA3C133c_z?Kls5g$|;)= zgb5VRs?CaIpUWxD`Cab4Ennp4<$qOp#JT926|;d=eb#e_tis63FnR)(bVjav(a$lq zT)blpE#+BaZqbva$m$PwqvCJ@+QI)jhUT&5=950yw6&F2`O#HuZHxTbk9NZZ+an*1 zqn+?!M+668-`Lv8x1C3yVQW_;dlFT_i=v1!g-*eTV!k|$?qlmQ9-Kkn$JXvh-Ylxx z6fa0JD#@~J8tL9mLHO`xRGG*bSphZD4XWD0JAv?DfI)2{{S`^qnXK962n^zg)A?&5 z%Q+x82VC#DR$Rr=zZ+ZKjZQxBI%3s{nTVuORb_TTAXK8n0F@C>2v5U-5Aot_h@~o! z$-vUCKtz>fMr6|*&gOTop~Jf7u|!u|L$R^4Vd{FuS>gy-KOLPSeuekAyZ8&YQ2X(OW*L&H=`u~% ztXTEYsRE$WC4jpx2_kh~a=q&sbBW;W=bil09dztO!r9;%LJUUi2LP(5Q>sys3uBu^ z1VMzay>Ob{eC#f&Nye)xDJEegeM`WHNwTV%%;4|dMYX90gla^wX9UqDlR$k@IQ=^^ zlkTRF5pbo~Pgp^hbP`~sjj0CE}1gQlr+O+gf(R636Dj$ z>hYZM%}p)a0~snD92PS(WZ5RtkoCwU{DBJ>B;(DLOs3g$D;5(mgv%n{^KjF#w@j6p zntnP6k5$}I^yfIjZ<|IRRBAXJ67JFmejo)@9{h>(;Gt3P70oi28iefVU zaS8rzssZf7)Y7SeKOh!ljVUVsNhwazKusbF0~xf38kHb)h+(Xk;eVARJ;tEpGj-bv zu)73Ow-^kK`DTJCW!XF5A87QoPfyIWwi_PBnC!UVX_KbL>)Sfmd~m9%#bcb2XC;aC zG=@gz=LUncqh;DEL%W52aF(LLCu(s;k_1Gfu0vOt#u`X$A|wNePQBiLsw>z$Gk291F@J>g|G8XR$;)WP0sKcM0 zNU~s24c9aE%n76}=uJ6==Kjg)u4NkN?(U%rO}(eb%nN$Rceb^s>Fi*Ab;IeAKyX2C z>1MQTX=tRoO_`aV8|k#Rqhet@u!vnA4_{fuMX4k}+;v-Fi1{OqkVi=@OV9W_+efDx z+x&wkm6eWOt=qp8>TMcp3r^R!_jLH6UFm3Bn46rQn4=>@lhUZs+7Lg54+Z!+@nMul z#C;Lpk{+fI6ifwDP=U5M%^?tXRMJ(=(0Sf<{CF}>6-k52%j{tXGsO}9)OCC))qui0 zHg%3I9Y-S9uH%51w2+~}1#QV7qK2fXrov2K{}xtL4K!*n!!9sTc8CIbtMXUV3@9^o znxQ5$NM{AYbNwdfVj!XG8mJ}IT)Q62o5(SgE1m|tz zsgkOKMFug5rmA9SCcpOy9!)hc3`R2*ZwP2=sD{C3H}E4XKy#pw3~pyosi{F!{^kbW zm%0Mvi_9`qNG4I0X_TygimOYL?F)1bkm{K>y@_;VeqD6z%}|4&!Gmf>GKgCO;jfF1 z$6FH)0?mU4FGKwUgE-=hM!y?=OW(}=7b$Z)t`ufLD_;i%-~@8Ovld}q?sn8-d@=eC z<2Zz45Q;-64xt$I@;45I%iJYVq%H>3#@-+M-f))U6chnX;>GNR?0@9EkoRJKRsQ|L zN@t~Om+PMZrCrZy)}cs!nS((;yeG0!?#O`;dn49<$CuEB@8jRDbSz@4gnw4)xZ<)( zbBicNFIEPh($ delta 5223 zcmaJ_YfK#16`nI=u)*vOc|x5SuM<0oU3+%!+{et&WX&3EFxUoc9)>(@SQZw-!@$B~ zCoLvYrTj>hq+9hil_JMd+N!Ezr*^}pjjEvLSE@9QDpmQDS1U!St2R#BDr%D`?pbek z7nmuCS=f8-IrqEgp7Wh^=gbEcXFjNSYSWGItfD9spS$n@d|rBbmsO3UyZ^Ga1iz~K zXZWd5{R{mw{nKC0p3-mVo5F$e>}b^_e%#uBvGPyhZ<-F)llR1`2*lv^U zwmg!HbyYf)UaD>_F^g)p!A-|;O|M#Bl5UzO%jZ+qwix%DpOd7YpC>yDi`#}}GnWXz z`PU_vuFcoZFSqZSgb>#=pL4@;ZQCO0fopdzpKm)ZHGQ^i8#zh(;>!7gI!t)+qkSfb z<+{IuoAliU{I1~=i`hQ@$xDu_@|+Gk<%kaDMOKd5Dy_`Bl3uS;C+QrD6-HE{QEbnkHNP<{K+Xfk}DKGo23y2VYM zG^XZQb9Am}WP~?&Mq^>S>ELN9W{xI0A7){vYs}v$cj#(Ie7#&&BG1>ree(s+3B$s3 zM2su(VW<`)b))fEa%L(%WyB`Nwpo4Kh`EhV*Y6+dYdoCl?KftpyM}wop@G)c#zw2F zA=;EknUj-K(b?0YJ4OcD4$j3Ayu0mi{laFrRoRlw4LPy}wiZEf!^Kk&t5ILimz;$7 zfuL?*=aKkWQ(~mE;q*vHN7I4&$+4Mkda^a#oJfg!HtB}@dnU%>PF(EkVF$!qbVy`# zQ_~j}{o_n|2>uh^bw#;RxvVIcVK2O))@YBHZY}-q`p-8!TeiQvyZo;kU#Vyc+#L8r zFrllun!X`)F7sL&bd*4stnPxhq5Ef_b^*Y#^!mVa+QMBu>4z$Qsy!C$%|v^k65#&y z+vQKHZ4bx~d*P4pp#1gy@B}=R{>6shtKzu4`9XLYPRKVOgdam+`nRP&QXlD0zgqIe z4^Kd8D5WSVIJfTLy4Ok)r8`RBTz_T5wQ_x< z{9J{2x*2A)g*yi2D+BO649UJYEI~rvIf&neGp`TACV-L5heL1+z{8m@6QBc(%D@Qx z6UH*|Fzf;t&xA)|Kfr`cjlt(|QcjP<4`4D=HUYbeti%Yil1p4KYZN5%#97#0$Q~S~ z4o4F31Y1EOUqppH`RK%9i<^QHKZTqm5crK!8aSrtXZ1+nSn!?T>0tGx8$t~MdF%zS z!v#yGL8)V#-o)jm!H{blf^qQ>`m|S8p9i}@EzC4*LXb&45I8Z2WjTbMD3R}-hn<3J zo;j$^9osg&>4n;+X;NXycW}8v89)Ul7?uc+Da6TbCMXz((usIq{4kt(B1M%sYmS@|QmY7*fso@A454I?& z%=Q(_MRMRhs4XU(WpHK_zu;vCB{p|m`TBdXXSo8iD92*zvkiiN;zH8*!985aE6YGL zJe$<3_l;<=qi~!ds8F^Xz-?mC;aN^i^pD2JLZl-xJRM36kB)}=6N2fjA z)zjQhdM3wOhTG$VNtTQ^wZ@Lo{iEZ(JlWcCw6`%aTc7G_n`w{560GBp7#9m6*raSm zU+RiX>`}KZ2f>)lEblh4|H(;+4+wTN+-5X%Vj$H|ntKOr5!-*Vy|w8m>Fh`yB*t)b z_N39=H9kCY*bpMQ&zU~b)mfkIJXHN%MZcXLoSypZUa zv#DKws(&CJJsRsi(AeGF(lWDeGTIiMvdp0)VKO+|dPsEa?@k$XU!&96gJpW*Ca6|! zLKN43qEUHzUacyE5Qd8(<&(MgO<{Q5Hw0@{D@fD5MaUFH8yUbJf8> z6|OBDS$09arx>SLg$Z*h^8_|F4>^f^;DUO0QNhesK@4B7LSB+Ne?cAA3mV7@++xJ> zQVZTjFm~`hAosqivgHa?*tm#i2~@y-0864gw@Sex6luUu0eMi^VsS~8`f!1Ekq9aF z6<(sjM9)d?h4l)Ql|`ef$0*LhUK^AC|4SC%QWt9q8^Y=)a529PF@xE{5>)>AV>MP( zpa!;D)bgPlW?%s$HkA`s)fFq?UC6J~!}@9C9YApT@>O+naRtk8uy#9M>O=)0s44j3 zCu(?0v5_O$ASOO{Pz;ouq+OL4bnSLORwZ~*Bv~A*=@XT668VCz-P2MyAYus0{n!u{ za*_ZBf1qMX(U%t8=_{ za))^@u$*GhX3J=#Vr_knNrHFa)%!wyO0hSZXOWF-8=!(ae#e0Iz^0g(k@B_mE#h#$ zzT7fgLF{>#M#}OA29q9~jAMssF?`$M*@0!)SomEQ*|3&A#v{Q#$V&$tgWeMJgu0RS zYa75m3PaHk0HfHF@JQ*}`uIY_!kd8425@~W!cL@QZ37J1#^;>`?!a_xVUx(ZyuM!y zVJnzj--oR*G3HG)Y)7=b0ly<)c+&W?#@7IngX>rkHLvdvz(nrzd0U08MgpT7Z*CFD z8}I{wt)^|GtGzBH2E&fd<=2x<*`q*8{Z7fFC09$ID*Jx9Rer5vN8p}db?}O^=jrHX z?J@qHj0kBqz*J^pt5ymyok`uHeW`9puCMymW>~0_pKjNxWO}>S2{ZC<+qLIlHuJ Date: Mon, 21 Apr 2014 14:46:27 +0200 Subject: [PATCH 101/526] fixing indentation --- tutor/app/views/profile/index.html.erb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tutor/app/views/profile/index.html.erb b/tutor/app/views/profile/index.html.erb index e029cba9..0bc76099 100644 --- a/tutor/app/views/profile/index.html.erb +++ b/tutor/app/views/profile/index.html.erb @@ -7,12 +7,14 @@ <% next_problems_to_solve.each do |key , value| %> - - - - + + + + <% end %>
Your Next Problems
<%= link_to value.title, controller: "problems", action: "show", id: value.id %> - <%= key %> -
+ <%= link_to value.title, controller: "problems", action: "show", id: value.id %> + + <%= key %> +
<% end %> From ea717a68ded257ef00036f22fcf32938db4dc44d Mon Sep 17 00:00:00 2001 From: Mohab Date: Mon, 21 Apr 2014 15:35:24 +0200 Subject: [PATCH 102/526] adding popup div --- tutor/app/views/tracks/show.html.erb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tutor/app/views/tracks/show.html.erb b/tutor/app/views/tracks/show.html.erb index 25a67437..bbe5182d 100644 --- a/tutor/app/views/tracks/show.html.erb +++ b/tutor/app/views/tracks/show.html.erb @@ -31,7 +31,9 @@ <%= link_to p.title , p , style: 'color:#003366;' , class: color %> - <%= p.success_attempts %> + +
Click me!
+
<%= p.description %> @@ -39,6 +41,18 @@
<% end %>
+
+
+
    +
  • kdj ie Lorem ipsum dolor sit amet
  • +
  • consectetur adipisicing elit, sed do eiusmod
  • +
  • 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
  • +
  • cillum dolore eu fugiat nulla pariatur. Excepteur
  • +
+
+
<% if @can_edit %> <%= link_to "New" , '/problems/new', class: "label label-default" %> From e6b84046c56e345c6e24c4697a5c4980013570a3 Mon Sep 17 00:00:00 2001 From: Mohab Date: Mon, 21 Apr 2014 15:46:48 +0200 Subject: [PATCH 103/526] Fixing indentation in profile_controller_test --- tutor/test/controllers/profile_controller_test.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tutor/test/controllers/profile_controller_test.rb b/tutor/test/controllers/profile_controller_test.rb index 81441f04..242bcc3f 100644 --- a/tutor/test/controllers/profile_controller_test.rb +++ b/tutor/test/controllers/profile_controller_test.rb @@ -1,7 +1,9 @@ require 'test_helper' class ProfileControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end + + # test "the truth" do + # assert true + # end + end From 7ce800a5b25a9c9ed2f3a2f63a3a25594ddcfc28 Mon Sep 17 00:00:00 2001 From: metawaa Date: Mon, 21 Apr 2014 16:27:14 +0200 Subject: [PATCH 104/526] Fixing implementation --- tutor/app/views/courses/show.html.erb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tutor/app/views/courses/show.html.erb b/tutor/app/views/courses/show.html.erb index a21e50f3..e2d252ba 100644 --- a/tutor/app/views/courses/show.html.erb +++ b/tutor/app/views/courses/show.html.erb @@ -3,24 +3,24 @@

Code: - <%=@course.code%> -

+ <%= @course.code%> +

Year: <%= @course.year%> -

+

Semester: <%= @course.semester%> -

+

Description: <%= @course.description%> -

+

- <%= link_to "View Discussion Board", {:controller => 'discussion_boards', :action => 'show', :id => @course.id }, class: "btn btn-success", method: :get, style: "text-decoration:none" %> + <%= link_to "View Discussion Board", { :controller => 'discussion_boards', :action => 'show', :id => @course.id }, class: "btn btn-success", method: :get, style: "text-decoration:none" %>
@@ -36,10 +36,10 @@
    <% t.tracks.each do |tt|%> - <% color = "label label-default" %> + <% color = "label label-default" %>
  • - <%= link_to tt.title , tt , class: color %> + <%= link_to tt.title , tt , class: color %>
  • <% end %>
From 94854466d1e6fe16e21cb9d332949d56f4daa5ed Mon Sep 17 00:00:00 2001 From: Khaled Date: Mon, 21 Apr 2014 16:31:04 +0200 Subject: [PATCH 105/526] Issue #193 Added method for getting variables --- tutor/app/models/debugger.rb | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tutor/app/models/debugger.rb b/tutor/app/models/debugger.rb index 4c048a77..0501feba 100644 --- a/tutor/app/models/debugger.rb +++ b/tutor/app/models/debugger.rb @@ -1,3 +1,4 @@ +require "open3" class Debugger < ActiveRecord::Base #Validations @@ -8,4 +9,27 @@ class Debugger < ActiveRecord::Base #Methods -end + def get_variables + method_arguments = [] + local_variables = [] + instance_variables = [] + flag = 0 + input "locals" + output_buffer = bufferUntilComplete + output_buffer.each_line do |line| + if line == "Method arguments:" + flag = 1 + next + else + flag = 2 + next + end + variable_value = get_value line + if flag == 1 + method_arguments << variable_value + else + local_variables << variable_value + end + end + +end \ No newline at end of file From 482a2ce4f4b476af497b006b9e5dc216f198183c Mon Sep 17 00:00:00 2001 From: metawaa Date: Mon, 21 Apr 2014 16:31:12 +0200 Subject: [PATCH 106/526] Fixing implementation 2 --- tutor/app/views/courses/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutor/app/views/courses/show.html.erb b/tutor/app/views/courses/show.html.erb index e2d252ba..baf5afb5 100644 --- a/tutor/app/views/courses/show.html.erb +++ b/tutor/app/views/courses/show.html.erb @@ -2,11 +2,11 @@

- Code: + Code: <%= @course.code%>

- Year: + Year: <%= @course.year%>

From 15264b34ef0aac6f82bdecda3b8c01529dd507b0 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Mon, 21 Apr 2014 16:31:36 +0200 Subject: [PATCH 107/526] Added update method and show method and edit method in Posts controller --- tutor/app/controllers/posts_controller.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index 42cc7ef6..234d28ea 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -13,6 +13,15 @@ def new @new_post = Post.new end + def show + @post = Post.find(params[:id]) + @replies = @post.replies.order("created_at desc") + end + + def edit + @post = Post.find(params[:id]) + end + # [Add Post - Story 1.13] # Description: This action takes the passed parameters from # the add post form, creates a new Post record @@ -49,6 +58,19 @@ def create end end + def update + @post = Post.find(params[:id]) + if @post.update_attributes(post_params) + flash[:notice] = "Post successfully updated" + redirect_to(:action => 'show' ,:id => @post.id) + else + if @new_post.errors.any? + flash[:notice] = @new_post.errors.full_messages.first + end + render :action => 'edit' + end + end + # [Add Post - story 1.13] # private method. Controls the post form parameters that can be accessed. # Parameters: From 777205c30fc4c91525442ee02124efaace4acdd8 Mon Sep 17 00:00:00 2001 From: Khaled Date: Mon, 21 Apr 2014 16:32:41 +0200 Subject: [PATCH 108/526] Issue #193 Followed conventions --- tutor/app/models/debugger.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/models/debugger.rb b/tutor/app/models/debugger.rb index 0501feba..2f52c438 100644 --- a/tutor/app/models/debugger.rb +++ b/tutor/app/models/debugger.rb @@ -15,7 +15,7 @@ def get_variables instance_variables = [] flag = 0 input "locals" - output_buffer = bufferUntilComplete + output_buffer = buffer_until_complete output_buffer.each_line do |line| if line == "Method arguments:" flag = 1 From 7eba59d1005c22831de0cc602c953deb9847936c Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Mon, 21 Apr 2014 16:35:01 +0200 Subject: [PATCH 109/526] changed the view of the discussion board to have title as a link to the post --- tutor/app/views/discussion_boards/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutor/app/views/discussion_boards/show.html.erb b/tutor/app/views/discussion_boards/show.html.erb index d3a5f9e0..5a63b80e 100644 --- a/tutor/app/views/discussion_boards/show.html.erb +++ b/tutor/app/views/discussion_boards/show.html.erb @@ -5,8 +5,8 @@ <% unless @posts.blank? %> <% @posts.each do |post| %>

-

<%= post.owner.name %>

- <%= post.content %>
+ <%= link_to post.title, :controller => 'posts', :action => 'show', :id => post.id, + :method => :get, class: "btn btn-success" %> <%= post.views_count %>

From 046e75cf68fa651354ecd1d91c8057edbcd83bae Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Mon, 21 Apr 2014 16:36:11 +0200 Subject: [PATCH 110/526] added edit html page in the views of the Post and added a show view for the post --- tutor/app/views/posts/create.html.erb | 0 tutor/app/views/posts/edit.html.erb | 27 ++++++++++++++++++++++++++ tutor/app/views/posts/show.html.erb | 28 +++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 tutor/app/views/posts/create.html.erb create mode 100644 tutor/app/views/posts/edit.html.erb create mode 100644 tutor/app/views/posts/show.html.erb diff --git a/tutor/app/views/posts/create.html.erb b/tutor/app/views/posts/create.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/tutor/app/views/posts/edit.html.erb b/tutor/app/views/posts/edit.html.erb new file mode 100644 index 00000000..5f646fbe --- /dev/null +++ b/tutor/app/views/posts/edit.html.erb @@ -0,0 +1,27 @@ + + +
+

Edit Post

+
+ <% if flash[:notice] -%> +
<%= flash[:notice] %>
+ <% end %> +


+ <%= form_for :post, url: {action: "update", :id => @post.id} do |f| %> +

+ <%= f.label "Title" %>
+ <%= f.text_field :title, autofocus: true, class:"form-control", style: "width:300px", placeholder: "Title"%> +

+

+ <%= f.label :content %>
+ <%= f.text_area :content, class:"form-control", style: "margin-left:auto; + margin-right:auto;height:200px;width:500px;resize:none", placeholder: "Enter your post"%> + <%= f.hidden_field :discussion_board_id, value: params[:discussion_board_id] %> +

+

+ <%= f.submit "Update Post", class: "btn btn-success"%> +

+ <% end %> +
\ No newline at end of file diff --git a/tutor/app/views/posts/show.html.erb b/tutor/app/views/posts/show.html.erb new file mode 100644 index 00000000..0f46c1c5 --- /dev/null +++ b/tutor/app/views/posts/show.html.erb @@ -0,0 +1,28 @@ +
+ <% if current_lecturer %> + <% @userID = current_lecturer.id %> + <% end %> + <% if current_student %> + <% @userID = current_student.id %> + <% end %> + <%if current_teaching_assistant %> + <% @userID = current_teaching_assistant.id %> + <%end%> +
+

<%=@post.title%>

+ <% unless @replies.blank? %> + <% @replies.each do |reply| %> +
+ <%= reply.content %>
+
+
+ <% end %> + <% else %> + No Replies in this post yet . + <% end %> +
+ <% if @post.owner_id == @userID %> + <%= button_to "Edit Post", {:action => 'edit', :controller => 'posts'}, { + class: 'btn btn-primary',:id => @post.id} %> +<% end %> +
\ No newline at end of file From e503eaab49e3deb8a856cd7332c3d6328d1cc65b Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Mon, 21 Apr 2014 16:38:43 +0200 Subject: [PATCH 111/526] modified the view of the discussion board --- tutor/app/views/discussion_boards/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutor/app/views/discussion_boards/show.html.erb b/tutor/app/views/discussion_boards/show.html.erb index d3a5f9e0..5a63b80e 100644 --- a/tutor/app/views/discussion_boards/show.html.erb +++ b/tutor/app/views/discussion_boards/show.html.erb @@ -5,8 +5,8 @@ <% unless @posts.blank? %> <% @posts.each do |post| %>
-

<%= post.owner.name %>

- <%= post.content %>
+ <%= link_to post.title, :controller => 'posts', :action => 'show', :id => post.id, + :method => :get, class: "btn btn-success" %> <%= post.views_count %>

From 14f5785378146532e989f669eec6dfb51306f713 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Mon, 21 Apr 2014 16:42:12 +0200 Subject: [PATCH 112/526] added create file in the view of the post --- tutor/app/views/posts/create.html.erb | 0 tutor/db/development.sqlite3 | Bin 208896 -> 208896 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tutor/app/views/posts/create.html.erb diff --git a/tutor/app/views/posts/create.html.erb b/tutor/app/views/posts/create.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/tutor/db/development.sqlite3 b/tutor/db/development.sqlite3 index 9dfcccb83f25a2e3d024825d9da799f72d80bf42..c75953487d4bed62d714c616ca08bb03d6ae7d5d 100644 GIT binary patch delta 263 zcmZp8z|-)6XM!}N&qNt#MxTud`TmT|%@_Q)U+`x%DPUvd*Ja?>-OhD@QJKHKF@Twe z!IGh|kb{#`*3q#fu_)CjwM4-!FinUa{NkPFn3n_rY@oLHiem;w|B8dw74fr6p2l`#VYL!u^wA_pg@tfQl2UZO&AUSe`~u|iUQl9Rua0thQA=AI=Hoz)lYG!F^4zwUalR=(?0cb%8E*o%IU~Xk%sb^?n SVPJ@E0g_DH1;%9;m=XXK9YMJO From ac4b287f3ea4d1855048cd865db36c9b51d6e2d0 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Mon, 21 Apr 2014 16:52:23 +0200 Subject: [PATCH 113/526] modified post controller to add show and added show view --- tutor/app/controllers/posts_controller.rb | 12 ++++++++++++ tutor/app/views/posts/show.html.erb | 0 tutor/db/development.sqlite3 | Bin 208896 -> 208896 bytes 3 files changed, 12 insertions(+) create mode 100644 tutor/app/views/posts/show.html.erb diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index 42cc7ef6..89250b92 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -13,6 +13,18 @@ def new @new_post = Post.new end + # [Add Post - Story 1.13] + # Description: Displays the post that the user chose + # Parameters: + # @post: The current post the user is in. + # @posts = The list of replies of @post + # Returns: The view of the post + # Author: Ahmed Atef + def show + @post = Post.find(params[:id]) + @replies = @post.replies.order("created_at desc") + end + # [Add Post - Story 1.13] # Description: This action takes the passed parameters from # the add post form, creates a new Post record diff --git a/tutor/app/views/posts/show.html.erb b/tutor/app/views/posts/show.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/tutor/db/development.sqlite3 b/tutor/db/development.sqlite3 index c75953487d4bed62d714c616ca08bb03d6ae7d5d..a92923190baf31b9c3e10340f56b5e2332ac8862 100644 GIT binary patch delta 276 zcmZp8z|-)6XM!}N-$WT_M!$^-`TmS7%@_Q)U+`x%Dd1q@3u55c5ux60@)YK|oE+f5Muoj>d#rfHZMKKE5NvTDN3K>BA zQY#aAxs3HHf#NxdNebzSl_`mNIjPAdrA4VlMh1o^x&|h?MurN8CRQevR>nqpCYI(F ZCdSxgObty;jZNEi&oge<+tC?bAZu}kC#E5 z0SFu&1M-VYOeQndin5wo7+6?S$9CtC5R|i=k1O5p0rY zi9%+vLRo52r9wtxQHnxIzCw0tYJoy#o Date: Mon, 21 Apr 2014 16:53:58 +0200 Subject: [PATCH 114/526] Issue #221 ajax feature --- tutor/app/controllers/utilities_controller.rb | 8 +---- .../views/layouts/_signed_in_header.html.erb | 7 +++- .../views/utilities/_simple_search.html.erb | 32 +++++++++++++++++ .../views/utilities/simple_search.html.erb | 35 ++----------------- .../app/views/utilities/simple_search.js.erb | 2 ++ 5 files changed, 44 insertions(+), 40 deletions(-) create mode 100644 tutor/app/views/utilities/_simple_search.html.erb create mode 100644 tutor/app/views/utilities/simple_search.js.erb diff --git a/tutor/app/controllers/utilities_controller.rb b/tutor/app/controllers/utilities_controller.rb index 07ac6fdc..6b8fab96 100644 --- a/tutor/app/controllers/utilities_controller.rb +++ b/tutor/app/controllers/utilities_controller.rb @@ -7,17 +7,11 @@ class UtilitiesController < ApplicationController # Author: Ahmed Elassuty def simple_search @lecturers = Lecturer.search(params[:search]) - puts @lecturers.present? @students = Student.search(params[:search]) - puts "______________________________________" - puts @students.inspect @teaching_assisstants = TeachingAssistant.search(params[:search]) - puts @teaching_assisstants.present? - puts ">>>>>>>>>>>>>>>>>>>>>>>>>>" @courses = Course.search(params[:search]) - puts @courses.inspect - puts "_______________________________" respond_to do |format| + format.js #render 'simple_search.js.erb' format.html end end diff --git a/tutor/app/views/layouts/_signed_in_header.html.erb b/tutor/app/views/layouts/_signed_in_header.html.erb index a7403c11..0700ef83 100644 --- a/tutor/app/views/layouts/_signed_in_header.html.erb +++ b/tutor/app/views/layouts/_signed_in_header.html.erb @@ -4,7 +4,12 @@ # Author: Ahmed Elassuty --> <% if true %> - + <% end %> \ No newline at end of file diff --git a/tutor/db/development.sqlite3 b/tutor/db/development.sqlite3 index cdf0f15783ba35b3bc67b2141177f8cabc9605b4..c624d4befd16aa15c9f007dc878af6bcf0b5146d 100644 GIT binary patch delta 4010 zcmZu!TWl298J>T};bOcywlSDGvAqzm!G-ahxt%l41+OvSyVn@om?Xq&@2+jU>oxW+ zwrN_}ytEIkQdqU8v{D06)2gikscF4Us|ebt4^(QJst=9S66GZ?6#}BFeJE||zut?$ zGow8#?SB9H&v*X&T==x?!lz~5tf>?i1wqhpHQ)kV4=?W5L~-%r*fzNTv$IQbuEktcGErl3NCAOv#gp0_lBEKp_6F)73Crbx6si?<5 zj?PU5guf|+U6e-inYxn?>d7Iib8Y z?rf)8mmW;c4VnIlWTaOMj}Q4z&<^Fee?|$gY13?5jj z7<0*i!>l_pJ$x=Q(iLGbffJ?t!!Ff^j; zE-`5-IfS^8h(vn^ySgIw#NTENCc_Keqa%^!k;ya4c!C~2G&z56B$=@1 z$>J0pn(Hpb!zFoDknhQVl`|e6{Ij|8j!-FlAP66T1-HaX>9q~pcvS%2$=nP;eF?A| z6+Q!`)X;gpV;DXLA@lh#WS{g#&y|u?LrP4aD*Iu{>)w=<@sC0UKuP*9rEf@q)KmPk zlkjKQz~6fbz5yH4Ki%|u$x3bFRju~--4RV<~TH~`LNa%RaI@a-VK-@ z1%!{i348O>n!-$r>4qZ$)dIrbMQJOSV47lCR5hK&0i|<@$MY+p#B)OMobdk5doJU> z0$m<)OyaLygQgZ;bRI(#Q#TCi%vquA^n9*Ci+ zl&H4N&!Kd&m@ti6hBKM)3|qH!qK=j17#gk&EvBk22F2Y5rMhKeF#Z-9j`6pyLsi=6 z>slFu@(kR9q&LeK(~v2YQd_5v`(sr#Y+~3N|Ne(im(L_y(KJK1*E&A`$%1U+5> z{e4-Gb9=Kv3V z0x#qpZYY{fC|Q3QWI`3yFl@^B?N6XBYe0;21G|SwG-nPFOR)(SeQjJU6Y3A*p_|t% zI3FL6hGRbM_|)`*4?kza^UJ=e;C#pz$UzSBm`w~Dg85|ctH>UYhgc-b3Dr;IMZ#~5 zm9KmR<-Y*&D}{it6&-`hE$?i_WHu#~|Hv!W=5MbmXh3Sa1lOsU5Z zPGqrmf6m9YLJgG~>ut3rokQ>%FW@z7enS@bP0huYZKE82afg3(7+fCs!272zg;itMQNf@EPW17 z;Tae?gt1khc(;&Z6sIlQa_Gie7m?P5L^2efO+3~xgJ(vj+rz!FsoCyc=GWLv-;%#a ziB7il^wBekXh)Zy9aH0qLI>NE<7ehZ6MA1)Eaih5p%#rO;}ZDHL2-AnV`6^dT(*uf zlE5%sLx>BBeyc5VB#`KwJ#!?g97|4zl5u;vKR%r7B7=#po>~9IOq;%Rq&ZASjt(2+ z1MSfh!C1Coit-&nzK>r*#@i}Bcrnj{W=pr_HqRE3)*qXIK_VN2`v9Esl zyjUI0MIlwNnp=)Gu;z~(LY^eCtelPX_fEvxdm^KUwR3$#=0IdIIn)vANyOTE2m8V} zNc8p0&&|Z9=JfHCGs*<(KD2s4Eb)~}-i+YQ$S=#KH!6HT_6`m}sZiaReG~BemwYey z)TwYZ8uyLF=c6GXap?#erlW>~>^i?;VCsrxn9Q28eOIiJ^Jl0yonk$4sj*Dau)9#3x7`$JQQFiQWiH(l zUo|vLYlB~XTw15LrMq-!im9$)_^#d(zbi)ysm@I7z%KkvESOp3dDtkx=FNV;i)Br; zAI^}@v#^BZkkyaG4dtbm1n(vJmvUTgKo`F5<(KY>jd=qa7)hwZrD|j|TVtk;20V-g z^z*&<#VS*BcoEwNV^nwR_?QtoGZ^EY_r#sq_nNh4gR_N3T%rMk+SVE2bN9uadD9!% z8f=xibX2P71~qlE`asm`^MeZx7+43~%uzrFM1EbCp5aTfRCo)*xydBNr4VAv$|3w6 zS^8q05Ee%q09{%oO6QQ(a>*=*#*F2Y7{Jq+_)cjfz%!Y}UDAKWO|=`VpR0vbHUE5% zRL#?Sq+zJzf8Qfrh5F3b8zfNzAAe(?bOm;DwMqH|?8^MFNy54KS-x+-^aytIeFvlm Ru!q+u(x0Fqb61h7;Qs@BrF{SZ delta 3935 zcmZ`+YitzP6`nI=LvZY!g*ezEwJ{V7xGI5iXqCsRy`_~3R86WD1yYlEg{m|`Rew;aX{!Ecq%JI$B6mLnYh=uTbXY90UFVa5H zLHzEC6HpSb>}o78+Ww?+0H(u%VCbBGCbATqk8Hga>Ut~Voogm~=1#u%3=(g_WyVB>wXa#yYpDSxqXz@yr%v27R@WqHO1 z*HTD)^-=AC6iHmO9LsQco-umXb((-5_p;1bakUZloa!wZ4RHze^DwL(d zL5Mguck)@uBI1e)JZr7vPMv&O&^m>zx#3?)-xOmqG{e-Hv1zL*#H6-i8KSxx4or;I zM>>N;-l2~E#YrFYHCao8?c-WkJN0XHkS`Ck4=wqvkrvA8Pax0%Ltl2cu7z&O?7v_WW+Gu!spW)v}^nIjd%x8vYMuL68 z=9AN=uaC891Hq}OX>YryXOskbds;@14zLc!yO)|~mb@!dzCkTk1v{nP$sUm;kC@&K zd$K_=Tep#;oRCwElR`+LAbR-NRAjJ!{#b9*;QYu!tKPlX*3{K@f{uxa6!NnDIO;R7IAE}A58u+4q$4Al*>5e4b0TX^JyOotK<)XYB z-bnne8>)(c-`ZYdK~d~ftVdM#!H3YB_`DDB^2N87T`h{$#!kl1mcCx}ZCC76!ZQfl z0s7*9EqO`lj`fRAhu|+TAa1`1--p5Y^(X$Iu-K3&KLfYnMe+U__z9ejzq92>$~R(X z;_nuJ`NLtDg0qRxFw_B@O9(&wN`~QhJ1i8%_Qw3;HvxDJMua~IcVJX}bqs$65_iYo z8GvBo)AO(sU@YjY1W-pwLZ?72=l{cUv-RD#z%%TM})wDE5blW1s#p2!#?DN-e zfa`E33Y~BVquX3*_>jpg$2L*h_u*1!W%Y`tD6I`OY#tHa<!*KqOP&1QQ#42-1QgPX3sqC`rt}B3p>6CiCtQq@2 zE0bN4*nSUu;_}DvLV9N==9_S$=k3gNGy`+)P?bKOY<*iwrDvX2k!Yy$cxLCrBcb4Q zAQ%~q7AYC2$@PTdW$GF;Er;gHT3LgoCk2+;RA*EK?!j~E)L57rZrk}}V@Rg0JB*3D z_rRMj3sd8cMfH5T(VChzGi~*{v=?ijdf?=?QmG;veRLuk3a-a47mVF*(0PN&G?Or5 z=ghBML`sqRvtjq@2jG4iT?hncq8sL7-=NpG==Za5)6r?)M5||x z_IZ8UoVP975^d`WG@ZZDHFQ!V{r;eKe0C@j(gV{+Ct@|QOR7ThuqUt(re2Wur3a&< zktF5$a)m*p5Krd!%adgm9Cb5T}5mehy%B_&*q@@LOyqrfUNto)>46ltU}>fgY^%!TmWV0gSc z;0%POoN<3JV)t||GzTus+P)Jrkxpa4S~Qw_{r&arQ<24q-bre;&&8gCO6jR21If$d zsfrbgZ(fuuLK)T>s&fJ5#voD%$qiz0)F1oiLw@~ta=_*ohNItCVE>Ut*u1i-F z)tGLQO?s3(?BhI3A>uSz8!5@9I9;5AC&mndd+uG|`EgvSZS75YmzrLQXtu+#7W4WJ zPrrtZiDAO~u54$m8NO;1>Itq9>R1jJ*EU+C+FN!(;d5-p30r$l{;@ii+6B`XGtqTk zBs7CO3tJ`Fw$0;_3)$cxuvmT>;nOK(?E`s>yX2VUdR3is9a9e?``jhM59K}C7G`*Y zp!qIPrx`IBCF0cw@`1Eqp=6+%@B*WfqczGTS8q$LNOzN{eJGck1!7L>2xCZc&dkQ4 zqZ18}^tvSy7+rQf(_+-gAA=MR7wZTnczwOq;bQmO#mbS)JBx{LaF(tYknIf8Ba54= z@)fbHDw%f{Q!_X!+NRi&6_`Q98>;fPGlCu)RxCGMNU$2k0hmsN_b6Kd zW)e$#mH)_3gtu0Fy$WI#;`9AVg^2H0`e0W4eZO)I<`UnlRb&O`#Y=~js}K=-o$^PB kCjMKe;30NF96GE#f< Date: Mon, 21 Apr 2014 20:14:26 +0200 Subject: [PATCH 133/526] Revert "Issue #208 More on Linking with track, Handling failure demos, delete problem, Save problem as incomplete" This reverts commit 53cc3575c416131eefe915d25a1a987ff5a7cedd. --- tutor/app/controllers/problems_controller.rb | 9 ++++----- .../views/problems/_failure_options.html.erb | 4 ++-- .../views/problems/_success_options.html.erb | 1 + tutor/app/views/problems/edit.html.erb | 3 ++- tutor/app/views/problems/new.html.erb | 1 + tutor/app/views/tracks/show.html.erb | 4 ++-- tutor/db/development.sqlite3 | Bin 208896 -> 208896 bytes tutor/db/seeds.rb | 8 ++++---- 8 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 tutor/app/views/problems/_success_options.html.erb diff --git a/tutor/app/controllers/problems_controller.rb b/tutor/app/controllers/problems_controller.rb index 41bf6630..078da8c6 100644 --- a/tutor/app/controllers/problems_controller.rb +++ b/tutor/app/controllers/problems_controller.rb @@ -33,7 +33,6 @@ def create p.owner_type = "teaching assistant" end p.incomplete = true - p.track_id = params[:id] if p.save redirect_to :action => "edit", :id => p.id else @@ -53,7 +52,6 @@ def edit @problem = Problem.find_by_id(params[:id]) @test_cases = @problem.test_cases @answers = @problem.model_answers - @track = Track.find_by_id(@problem.track_id) else render ('public/404') end @@ -96,7 +94,7 @@ def done redirect_to :back else @problem.incomplete = false - redirect_to :action => "show", :id => @problem.id + redirect_to :controller => "tracks", :action => "show", :id => @problem.track_id end end @@ -104,9 +102,10 @@ def destroy_problem @problem = Problem.find_by_id(params[:problem_id]) @problem.test_cases.destroy @problem.model_answers.destroy + @track = @problem.track_id @problem.destroy flash.keep[:notice] = "Problem has been deleted" - redirect_to :action => "new" + redirect_to :controller => "tracks", :action => "show", :id => @problem.track_id end # [Add Problem - 4.4] # Passes the input of the form as paramaters for create action to use it @@ -117,6 +116,6 @@ def destroy_problem # Author: Abdullrahman Elhusseny private def problem_params - params.require(:Problem).permit(:title , :description) + params.require(:Problem).permit(:title , :description, :track_id) end end \ No newline at end of file diff --git a/tutor/app/views/problems/_failure_options.html.erb b/tutor/app/views/problems/_failure_options.html.erb index 28ae175a..27410fa3 100644 --- a/tutor/app/views/problems/_failure_options.html.erb +++ b/tutor/app/views/problems/_failure_options.html.erb @@ -1,3 +1,3 @@ -<%= button_to 'Abort and Delete Problem', problem_destroy_problem_path(:problem_id => @problem.id), method: :get, :confirm => 'Are you sure?' %> -<%= button_to 'Save as Incomplete', problem_path(:id => @problem.id), method: :get %> \ No newline at end of file +<%= button_to 'Abort and Delete Problem', problem_destroy_problem_path(:problem_id => @problem.id), method: :get, :confirm => 'Are you sure you want to delete this problem?' %> +<%= button_to 'Save as Incomplete', track_path(:id => @problem.track_id), method: :get %> \ No newline at end of file diff --git a/tutor/app/views/problems/_success_options.html.erb b/tutor/app/views/problems/_success_options.html.erb new file mode 100644 index 00000000..fd835cf1 --- /dev/null +++ b/tutor/app/views/problems/_success_options.html.erb @@ -0,0 +1 @@ +<%= button_to 'Done', problem_done_path(:problem_id => @problem.id), method: :get %> \ No newline at end of file diff --git a/tutor/app/views/problems/edit.html.erb b/tutor/app/views/problems/edit.html.erb index 552efe0b..e8bba23e 100644 --- a/tutor/app/views/problems/edit.html.erb +++ b/tutor/app/views/problems/edit.html.erb @@ -19,9 +19,10 @@ and a paragraph to view the problem description of the instance variable @proble <%= p.hidden_field :title, value: @problem.title %> <% end %> + <%= render partial: "test_cases/index" %> <%= render partial: "model_answers/new" %> -<%= button_to 'Done', problem_done_path(:problem_id => @problem.id), method: :get %> +<%= render partial: "problems/success_options" %> <%= render partial: "problems/failure_options" %> diff --git a/tutor/app/views/problems/new.html.erb b/tutor/app/views/problems/new.html.erb index 3b0ca32b..2faf1e66 100644 --- a/tutor/app/views/problems/new.html.erb +++ b/tutor/app/views/problems/new.html.erb @@ -11,6 +11,7 @@ <%= p.label :description %>
<%= p.text_area :description , :cols => "50", :rows => "10" %>

+ <%= p.hidden_field :track_id, value: params[:id] %>

<%= p.submit %>

diff --git a/tutor/app/views/tracks/show.html.erb b/tutor/app/views/tracks/show.html.erb index 9ff4b63d..f58e4a36 100644 --- a/tutor/app/views/tracks/show.html.erb +++ b/tutor/app/views/tracks/show.html.erb @@ -37,10 +37,10 @@ <%= p.description %>
- + <% end %>
<% if true %> - + <% end %> \ No newline at end of file diff --git a/tutor/db/development.sqlite3 b/tutor/db/development.sqlite3 index c624d4befd16aa15c9f007dc878af6bcf0b5146d..cdf0f15783ba35b3bc67b2141177f8cabc9605b4 100644 GIT binary patch delta 3935 zcmZ`+YitzP6`nI=LvZY!g*ezEwJ{V7xGI5iXqCsRy`_~3R86WD1yYlEg{m|`Rew;aX{!Ecq%JI$B6mLnYh=uTbXY90UFVa5H zLHzEC6HpSb>}o78+Ww?+0H(u%VCbBGCbATqk8Hga>Ut~Voogm~=1#u%3=(g_WyVB>wXa#yYpDSxqXz@yr%v27R@WqHO1 z*HTD)^-=AC6iHmO9LsQco-umXb((-5_p;1bakUZloa!wZ4RHze^DwL(d zL5Mguck)@uBI1e)JZr7vPMv&O&^m>zx#3?)-xOmqG{e-Hv1zL*#H6-i8KSxx4or;I zM>>N;-l2~E#YrFYHCao8?c-WkJN0XHkS`Ck4=wqvkrvA8Pax0%Ltl2cu7z&O?7v_WW+Gu!spW)v}^nIjd%x8vYMuL68 z=9AN=uaC891Hq}OX>YryXOskbds;@14zLc!yO)|~mb@!dzCkTk1v{nP$sUm;kC@&K zd$K_=Tep#;oRCwElR`+LAbR-NRAjJ!{#b9*;QYu!tKPlX*3{K@f{uxa6!NnDIO;R7IAE}A58u+4q$4Al*>5e4b0TX^JyOotK<)XYB z-bnne8>)(c-`ZYdK~d~ftVdM#!H3YB_`DDB^2N87T`h{$#!kl1mcCx}ZCC76!ZQfl z0s7*9EqO`lj`fRAhu|+TAa1`1--p5Y^(X$Iu-K3&KLfYnMe+U__z9ejzq92>$~R(X z;_nuJ`NLtDg0qRxFw_B@O9(&wN`~QhJ1i8%_Qw3;HvxDJMua~IcVJX}bqs$65_iYo z8GvBo)AO(sU@YjY1W-pwLZ?72=l{cUv-RD#z%%TM})wDE5blW1s#p2!#?DN-e zfa`E33Y~BVquX3*_>jpg$2L*h_u*1!W%Y`tD6I`OY#tHa<!*KqOP&1QQ#42-1QgPX3sqC`rt}B3p>6CiCtQq@2 zE0bN4*nSUu;_}DvLV9N==9_S$=k3gNGy`+)P?bKOY<*iwrDvX2k!Yy$cxLCrBcb4Q zAQ%~q7AYC2$@PTdW$GF;Er;gHT3LgoCk2+;RA*EK?!j~E)L57rZrk}}V@Rg0JB*3D z_rRMj3sd8cMfH5T(VChzGi~*{v=?ijdf?=?QmG;veRLuk3a-a47mVF*(0PN&G?Or5 z=ghBML`sqRvtjq@2jG4iT?hncq8sL7-=NpG==Za5)6r?)M5||x z_IZ8UoVP975^d`WG@ZZDHFQ!V{r;eKe0C@j(gV{+Ct@|QOR7ThuqUt(re2Wur3a&< zktF5$a)m*p5Krd!%adgm9Cb5T}5mehy%B_&*q@@LOyqrfUNto)>46ltU}>fgY^%!TmWV0gSc z;0%POoN<3JV)t||GzTus+P)Jrkxpa4S~Qw_{r&arQ<24q-bre;&&8gCO6jR21If$d zsfrbgZ(fuuLK)T>s&fJ5#voD%$qiz0)F1oiLw@~ta=_*ohNItCVE>Ut*u1i-F z)tGLQO?s3(?BhI3A>uSz8!5@9I9;5AC&mndd+uG|`EgvSZS75YmzrLQXtu+#7W4WJ zPrrtZiDAO~u54$m8NO;1>Itq9>R1jJ*EU+C+FN!(;d5-p30r$l{;@ii+6B`XGtqTk zBs7CO3tJ`Fw$0;_3)$cxuvmT>;nOK(?E`s>yX2VUdR3is9a9e?``jhM59K}C7G`*Y zp!qIPrx`IBCF0cw@`1Eqp=6+%@B*WfqczGTS8q$LNOzN{eJGck1!7L>2xCZc&dkQ4 zqZ18}^tvSy7+rQf(_+-gAA=MR7wZTnczwOq;bQmO#mbS)JBx{LaF(tYknIf8Ba54= z@)fbHDw%f{Q!_X!+NRi&6_`Q98>;fPGlCu)RxCGMNU$2k0hmsN_b6Kd zW)e$#mH)_3gtu0Fy$WI#;`9AVg^2H0`e0W4eZO)I<`UnlRb&O`#Y=~js}K=-o$^PB kCjMKe;30NF96GE#f<T};bOcywlSDGvAqzm!G-ahxt%l41+OvSyVn@om?Xq&@2+jU>oxW+ zwrN_}ytEIkQdqU8v{D06)2gikscF4Us|ebt4^(QJst=9S66GZ?6#}BFeJE||zut?$ zGow8#?SB9H&v*X&T==x?!lz~5tf>?i1wqhpHQ)kV4=?W5L~-%r*fzNTv$IQbuEktcGErl3NCAOv#gp0_lBEKp_6F)73Crbx6si?<5 zj?PU5guf|+U6e-inYxn?>d7Iib8Y z?rf)8mmW;c4VnIlWTaOMj}Q4z&<^Fee?|$gY13?5jj z7<0*i!>l_pJ$x=Q(iLGbffJ?t!!Ff^j; zE-`5-IfS^8h(vn^ySgIw#NTENCc_Keqa%^!k;ya4c!C~2G&z56B$=@1 z$>J0pn(Hpb!zFoDknhQVl`|e6{Ij|8j!-FlAP66T1-HaX>9q~pcvS%2$=nP;eF?A| z6+Q!`)X;gpV;DXLA@lh#WS{g#&y|u?LrP4aD*Iu{>)w=<@sC0UKuP*9rEf@q)KmPk zlkjKQz~6fbz5yH4Ki%|u$x3bFRju~--4RV<~TH~`LNa%RaI@a-VK-@ z1%!{i348O>n!-$r>4qZ$)dIrbMQJOSV47lCR5hK&0i|<@$MY+p#B)OMobdk5doJU> z0$m<)OyaLygQgZ;bRI(#Q#TCi%vquA^n9*Ci+ zl&H4N&!Kd&m@ti6hBKM)3|qH!qK=j17#gk&EvBk22F2Y5rMhKeF#Z-9j`6pyLsi=6 z>slFu@(kR9q&LeK(~v2YQd_5v`(sr#Y+~3N|Ne(im(L_y(KJK1*E&A`$%1U+5> z{e4-Gb9=Kv3V z0x#qpZYY{fC|Q3QWI`3yFl@^B?N6XBYe0;21G|SwG-nPFOR)(SeQjJU6Y3A*p_|t% zI3FL6hGRbM_|)`*4?kza^UJ=e;C#pz$UzSBm`w~Dg85|ctH>UYhgc-b3Dr;IMZ#~5 zm9KmR<-Y*&D}{it6&-`hE$?i_WHu#~|Hv!W=5MbmXh3Sa1lOsU5Z zPGqrmf6m9YLJgG~>ut3rokQ>%FW@z7enS@bP0huYZKE82afg3(7+fCs!272zg;itMQNf@EPW17 z;Tae?gt1khc(;&Z6sIlQa_Gie7m?P5L^2efO+3~xgJ(vj+rz!FsoCyc=GWLv-;%#a ziB7il^wBekXh)Zy9aH0qLI>NE<7ehZ6MA1)Eaih5p%#rO;}ZDHL2-AnV`6^dT(*uf zlE5%sLx>BBeyc5VB#`KwJ#!?g97|4zl5u;vKR%r7B7=#po>~9IOq;%Rq&ZASjt(2+ z1MSfh!C1Coit-&nzK>r*#@i}Bcrnj{W=pr_HqRE3)*qXIK_VN2`v9Esl zyjUI0MIlwNnp=)Gu;z~(LY^eCtelPX_fEvxdm^KUwR3$#=0IdIIn)vANyOTE2m8V} zNc8p0&&|Z9=JfHCGs*<(KD2s4Eb)~}-i+YQ$S=#KH!6HT_6`m}sZiaReG~BemwYey z)TwYZ8uyLF=c6GXap?#erlW>~>^i?;VCsrxn9Q28eOIiJ^Jl0yonk$4sj*Dau)9#3x7`$JQQFiQWiH(l zUo|vLYlB~XTw15LrMq-!im9$)_^#d(zbi)ysm@I7z%KkvESOp3dDtkx=FNV;i)Br; zAI^}@v#^BZkkyaG4dtbm1n(vJmvUTgKo`F5<(KY>jd=qa7)hwZrD|j|TVtk;20V-g z^z*&<#VS*BcoEwNV^nwR_?QtoGZ^EY_r#sq_nNh4gR_N3T%rMk+SVE2bN9uadD9!% z8f=xibX2P71~qlE`asm`^MeZx7+43~%uzrFM1EbCp5aTfRCo)*xydBNr4VAv$|3w6 zS^8q05Ee%q09{%oO6QQ(a>*=*#*F2Y7{Jq+_)cjfz%!Y}UDAKWO|=`VpR0vbHUE5% zRL#?Sq+zJzf8Qfrh5F3b8zfNzAAe(?bOm;DwMqH|?8^MFNy54KS-x+-^aytIeFvlm Ru!q+u(x0Fqb61h7;Qs@BrF{SZ diff --git a/tutor/db/seeds.rb b/tutor/db/seeds.rb index aa0556ef..652305ad 100644 --- a/tutor/db/seeds.rb +++ b/tutor/db/seeds.rb @@ -89,10 +89,10 @@ Problem.create(title:"Problem 5", description:"This is very easy Problem") puts("# -----------------------Tracks---------------------------") - Track.create(title: "Track 1", difficulty: 1) - Track.create(title: "Track 2", difficulty: 2) - Track.create(title: "Track 3", difficulty: 3) - Track.create(title: "Track 4", difficulty: 4) + Track.create(title: "Track 1", difficulty: 1, topic_id: 1) + Track.create(title: "Track 2", difficulty: 2, topic_id: 1) + Track.create(title: "Track 3", difficulty: 3, topic_id: 1) + Track.create(title: "Track 4", difficulty: 4, topic_id: 1) puts("# -----------------------Solutions---------------------------") Solution.create(code:"println(My first solution)", length:5, status:0) From 8ba8a1c34175f2b6dcd438023c2c58b77f6501c2 Mon Sep 17 00:00:00 2001 From: Khaled Date: Mon, 21 Apr 2014 20:18:59 +0200 Subject: [PATCH 134/526] Issue #193 Fixed bugs --- tutor/app/models/debugger.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tutor/app/models/debugger.rb b/tutor/app/models/debugger.rb index 81763f47..fb48ce17 100644 --- a/tutor/app/models/debugger.rb +++ b/tutor/app/models/debugger.rb @@ -9,10 +9,6 @@ class Debugger < ActiveRecord::Base #Methods - def input input - $input.puts input - end - def get_variables method_arguments = [] local_variables = [] From 83772840e9411fc48f53280d27e99ece854bc702 Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Mon, 21 Apr 2014 20:20:18 +0200 Subject: [PATCH 135/526] Issue #188 adding some javascript without any ajax --- ...nts.js.coffee => solutions_constraints.js} | 0 .../solutions_constraints_controller.rb | 13 +-- .../solutions_constraints/_form.html.erb | 100 ++++++++++++++++-- .../views/solutions_constraints/create.js.erb | 1 + .../solutions_constraints/index.html.erb | 4 +- .../views/solutions_constraints/new.html.erb | 3 + tutor/config/routes.rb | 9 +- tutor/db/development.sqlite3 | Bin 196608 -> 196608 bytes tutor/db/schema.rb | 2 + tutor/db/seeds.rb | 6 +- 10 files changed, 116 insertions(+), 22 deletions(-) rename tutor/app/assets/javascripts/{solutions_constraints.js.coffee => solutions_constraints.js} (100%) create mode 100644 tutor/app/views/solutions_constraints/create.js.erb create mode 100644 tutor/app/views/solutions_constraints/new.html.erb diff --git a/tutor/app/assets/javascripts/solutions_constraints.js.coffee b/tutor/app/assets/javascripts/solutions_constraints.js similarity index 100% rename from tutor/app/assets/javascripts/solutions_constraints.js.coffee rename to tutor/app/assets/javascripts/solutions_constraints.js diff --git a/tutor/app/controllers/solutions_constraints_controller.rb b/tutor/app/controllers/solutions_constraints_controller.rb index 53ab7261..d15ec3d7 100644 --- a/tutor/app/controllers/solutions_constraints_controller.rb +++ b/tutor/app/controllers/solutions_constraints_controller.rb @@ -6,17 +6,12 @@ def index end def create - + redirect_to action: "index" end - def show_params - @data = MethodParameter.all - render "show_data" - end - - def show_variables - @data = VariableConstraint.all - render "show_data" + def new + @constrain = MethodConstraint.new() + @params = MethodParameter.new() end def show diff --git a/tutor/app/views/solutions_constraints/_form.html.erb b/tutor/app/views/solutions_constraints/_form.html.erb index ee9d0fe9..2270cfa3 100644 --- a/tutor/app/views/solutions_constraints/_form.html.erb +++ b/tutor/app/views/solutions_constraints/_form.html.erb @@ -1,4 +1,85 @@ -<%= form_for :constrain do |f| %> + + +<%= form_for :@constrain do |f| %> @@ -10,14 +91,14 @@ - <%= form_for :patient do |u| %> + <%= form_for :@params do |u| %> - + - + - + <% end %> @@ -34,11 +115,14 @@
Method Constrains
Method Parameter <%= u.text_field :parameter, placeholder: "Variable Type" %><%= u.text_field :parameaaater, placeholder: "Variable Type", id:"params_type" %> <%= u.text_field :parameter, placeholder: "Variable Name" %><%= u.text_field :asd, placeholder: "Variable Name", id:"params_name" %> <%= image_submit_tag "add_buttom.png", id:"params", style: "width:15%;height:15%;margin_top:10px;"%><%= image_tag "add_buttom.png", id:"params", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_params(this);"%>
- <% render action: "show_params"%> +

Paramter

+ No paramter +
- <% render action: "show_variables"%> +

- <%= f.submit "Save Changes", class: "btn btn-success"%> + <%= f.submit "Save Changes", class: "btn btn-default"%> + <% end %> \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/create.js.erb b/tutor/app/views/solutions_constraints/create.js.erb new file mode 100644 index 00000000..df2ca465 --- /dev/null +++ b/tutor/app/views/solutions_constraints/create.js.erb @@ -0,0 +1 @@ +$('body').append('<%= @comment.text %>'); \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/index.html.erb b/tutor/app/views/solutions_constraints/index.html.erb index 617589f8..f8e2cd77 100644 --- a/tutor/app/views/solutions_constraints/index.html.erb +++ b/tutor/app/views/solutions_constraints/index.html.erb @@ -7,4 +7,6 @@ <% end %> - \ No newline at end of file + + + <%= link_to "Create new Constraint", solutions_constraints_path %> \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/new.html.erb b/tutor/app/views/solutions_constraints/new.html.erb new file mode 100644 index 00000000..b4dd62db --- /dev/null +++ b/tutor/app/views/solutions_constraints/new.html.erb @@ -0,0 +1,3 @@ +

New mooo

+ +<%= render 'form' %> \ No newline at end of file diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index 480589ae..f4005e4d 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -29,7 +29,7 @@ resources :solutions resources :problems resources :topics - resources :solutions_constraints + # Example resource route with options: # resources :products do @@ -55,6 +55,13 @@ resources :model_answers do post "model_answers/new" end + resources :solutions_constraints do + collection do + post "new" + end + end + + # Example resource route with sub-resources: # resources :products do # resources :comments, :sales diff --git a/tutor/db/development.sqlite3 b/tutor/db/development.sqlite3 index d19c0b1d72718ca09796e9cf12d0309b4ca00b82..16f9168c6518c0aa49ad1fcc1826ba2aa4fd9b2e 100644 GIT binary patch delta 4675 zcmbVQZERat8NSDMlBP}K?xTbuN+Q%%ZK__MbI*4-v^ZYtv}qG3aheZMz8W`QPMpMc zl0}2KQYH9<*tk+ILWnX1;tyL_M@lB7vHn0H_yN--v_H_X-w4KpplDJX&UHrawS6KG zk@LsTbKmoRJn#FS>q4QSP-uAblW=XbVHi&yEgpYlZX$63vI`WNRB~bw3nFqJlJgd7 ztwh>$6XuP~!YOOw6oRL6OPvWiNUkT7Oy*+qD+3#o@tM@%bYEgaOs-x{<)-^PRx=~! z#Ly)ep=dFhj7DO&o&ujWo>GUG{-V*7x9pc+XkPG6!U!Uy^`V5Iav$bm@puPJr}?#> zd_1{4czwBRIG)N5MAKcDr!!dO2J%DKX3)g)4cI@hK0kls#(Kmow%2{(?7@i^g&b?5 zW+ovR3u4336Eka_BmLczaAWw&)tfh2)*R`bnIGwyyS6;k6Hj)p%c0nGv@>hvv)#G$ zCH`XnTy%2Dtd7F9iMU{gBKGT}?QI9HVT3T$kfHf0Vx!Tg>0C5BJQM96q4~MBx%qf( zHkXWKQ(|r;zZglUiA*QD7p|w##lelvz7caMhE_MGV)pph`Tw2+Xzpjn%>n(ta!?#^ z37D{`hvX~UZsVjpUJv~>4*19YnH&=3t$(voX*Ui-O`dWInV|A%BwQ+gz z67OBQYGU(NEBKsoQi(mR{_VNVQ=Si42qL-8hkXQTd`Nb!!r6@&pXj=R%&Dox$(P_l z%v>4TSi9KG2lI(ozGG-0-?6$ron2fS=}z#n+YLw1ypQ{2`uc_%Gs1bS)C5WMwBvH{6W6S zXPZDwG|6*4;erVJ`){1|Qq2ex6j$3;QYs-Y29K%KxHHj+MiZHA?hr0jhw81kh?Eec>(-d)g-$S=27v9rQ=xephW#ML{4%sQBjBe4=GkouX|BDI~RMtft<0 zW^M-bZhgXjEgA|TYs770Wlv7Hav{cOvU8o!loRR%1IfBJ>5 zvDG(JYT8e+k-LxWzx);Z5-2FqvmvsGv^ziYEfjGm8L6QGk^SS3ET7v##jRBdlngRl z{M%c8w<+aVpAu;aj_nU0x12s`48f$pnjlpvnY2&uwffvRgsKDu1)<2!l(Pw=T0vQm zGK<@9?X~!_#~|mLDdE~y>v4N;@7s-@C!9)3v;H8OHOw~JO>c*9HvX#VyWuYbX)GACufE!{`}J1P5U>+9pV)n&$J@t(aj+YC7DR&e zktgb!BN1@B(V0F2wrZCqRwfp*&b_C>XPm@2uvX8WtZPOH+-`QhdKP@IA(flSOpUFi za`}}-=Y@0N8@u0X1HTPzK~Q@nWQ2bj9twxHpD6sZX|pd_Zy@)cAB|osJ(X}xr*f&4 zY%88!%vGmCX&(|yHHG^R(ib?~rd4j!Tm1rBoatMwg!F;KjiPd+UNxoU`g=JqA&tgv zpdCb7Jdvq;klPPc^;e;lkluiEcMN>qSs(L@Oduw8BglQqMV!~iK%1vYfe6vB+kIqb z9DL{-S*rD=(9e8?)J@DengM4$>s*a$q#5I?T}z1bl?pmit3Veq7cSzwQBFV987L&; za%Tyg2z&YDP^}KV^%CMX?WWtboBn*NqA6=ypGt^xXA=lt#1J#xno|*%kevbuy<2+% zgpA;db0iV?Vr}5PKn)1ly~p3%{Yh^i6L3Z&;D@^>l7ZXjrVrF3q}qns!MKk+59$n1 zUmuMIbe;-z{eqftr8H4Ob_#*_U-n{N}c-^boX^Y>kK0Zi>=3Hu3J)VaXnjI9E8(eL04}C znj$D)sJih`r%*x1MEA3VOIMnL&ix8HV*2fXD8@u=?UlO@A=k)K87J!Qi=FmzIufd} jw2=}^y~{a;3c9*a>DM+^X~)j}3OZ7+*IMfssVe;&FxWn2 delta 4570 zcmbVPYfM|$9lyus5yImpO&ii`8K}#mlq%+&d)~BDF-}5&1Ptcgl}Ess7>p^HIi9NF zD4#d2yAoHLrlnOkbzj<~MuKXuM%uJ#`?7qiCT;2ZZR)hO(=+1bqcx)tLM*(R$#vF#@wtN&p@pCVxy@iY5Uhw@xVrcu8{7;QfwiV zVME=E8%x&pkx18-**57Nb;a8Mqx+ow*_ z|0@K!nHIBn43-E|r1Qr`?CvBf<^>CBVSP2ai2Z{k_Oclvdeb703%exNTfFcmoKDZfnG5pGrftv)Ff-a z5E>25T7#=}Vv=;d%gEo+)ZTsuUR41*3o4E1Xm+l|@Zn)_k1 z0ul>KG(p}+a^HUXfQe(u>)PA#sO*xhtB{(33 zI+f+#*l6Mqnr;DLh9tx~2jskMQU#~*btp1E(Fq~XZX?#@vSWt3} zKl_OKdde`a1J_DVs@3ke!_9*hBS=Cf?ChN}uNV3M>Aet2a_;UoJVi?|WKs>J!{eD# z!7LoAt}~u4_%IY*UC!vGVo8N2aLNf6300LEA@-x6*B3jOUSq~w^2-2D$5i_v5VQ~l7AOi*a={qe=35T$`rZRiV# zJ^$c;Vk;d|Li;xlf*#w5G3Ab?v?NDJU>kq*f|rd{q_k{C8Ns&mQKyFu8PsnTYS|#f z%Khn=p2lXBBYj8&#|&fpuYbdy08+u_q2h28F9<~T>{eHN7~;7P3En+;aAyF&LrP(vE(G*k|`zJu)g%WqxvFJ6X!c zglG+`C<(=Wf3L+8J)){zpGU6BczbW}JB>vp6jPkvhYpV)!7!!V`Eer`^W3oNy<2>P<$@3(+NZa1v0CkZ;pL1s#e8IUfT~Y%=s*6GUm5Vsax^J|r%(GXp;MOcd2T zyh4RBsdgOaXc9cjO0O(Nb3X1=F3OX8_MQA0|X1s8E{Zvx@*SZ!k!a_k~ISx|Mq>Phgn;T#S7o~`z8 z_) z@59%M;?>wC>J6vyRjp@4%B@GfW-nW%MB8VQFtrsrouzcBZbkhqK-8?GPPUBBp+1mO zJ;jCP+$*C~HAc14F=7yJJuZeIfVQP1 Date: Mon, 21 Apr 2014 20:22:55 +0200 Subject: [PATCH 136/526] Issue #216 Fixed documentation --- tutor/app/controllers/application_controller.rb | 4 ++-- tutor/app/models/lecturer.rb | 2 +- tutor/app/models/student.rb | 2 +- tutor/app/models/teaching_assistant.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tutor/app/controllers/application_controller.rb b/tutor/app/controllers/application_controller.rb index e7b5eb1e..d303835a 100644 --- a/tutor/app/controllers/application_controller.rb +++ b/tutor/app/controllers/application_controller.rb @@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :update_sanitized_params, if: :devise_controller? - # [User Authentication Advanced - Story 5.9, 5.11, 5.12, 5.16] + # [User Authentication Advanced - Story 5.9, 5.10, 5.11, 5.14, 5.15] # Permits some fields to be passed through sign up forms to update the lecturer, # student, and teaching_assistant models # Parameters: None @@ -33,7 +33,7 @@ def update_sanitized_params end end - # [User Authentication Advanced - Story 5.9, 5.11, 5.12, 5.16] + # [User Authentication Advanced - Story 5.9, 5.10, 5.11, 5.14, 5.15] # Checks if a user is signed-in in order to be used in authentication over different pages # where they are redirected to homepage if they aren't authenticated # Parameters: None diff --git a/tutor/app/models/lecturer.rb b/tutor/app/models/lecturer.rb index dcd4a28c..a6212275 100644 --- a/tutor/app/models/lecturer.rb +++ b/tutor/app/models/lecturer.rb @@ -37,7 +37,7 @@ class Lecturer < ActiveRecord::Base #Methods - # [User Authentication Advanced - Story 5.9, 5.11, 5.12, 5.16] + # [User Authentication Advanced - Story 5.9, 5.10, 5.11, 5.14, 5.15] # Checks if the email is already registered in tables: Student and TeachingAssistant # before registering the email for table: Lecturer # Parameters: None diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index ce42ede8..77db215e 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -32,7 +32,7 @@ class Student < ActiveRecord::Base #Methods - # [User Authentication Advanced - Story 5.9, 5.11, 5.12, 5.16] + # [User Authentication Advanced - Story 5.9, 5.10, 5.11, 5.14, 5.15] # Checks if the email is already registered in tables: Lecturer and TeachingAssistant # before registering the email for table: Student # Parameters: None diff --git a/tutor/app/models/teaching_assistant.rb b/tutor/app/models/teaching_assistant.rb index 20bb9967..87aec822 100644 --- a/tutor/app/models/teaching_assistant.rb +++ b/tutor/app/models/teaching_assistant.rb @@ -38,7 +38,7 @@ class TeachingAssistant < ActiveRecord::Base #Methods - # [User Authentication Advanced - Story 5.9, 5.11, 5.12, 5.16] + # [User Authentication Advanced - Story 5.9, 5.10, 5.11, 5.14, 5.15] # Checks if the email is already registered in tables: Lecturer and Student # before registering the email for table: TeachingAssistant # Parameters: None From 1449c5b2993653439f0dd5a39b928d9f061e919a Mon Sep 17 00:00:00 2001 From: serag Date: Mon, 21 Apr 2014 21:00:37 +0200 Subject: [PATCH 137/526] Issue #206 Modified Controllers and added primative views --- Coolsoft-14 | 1 - 1 file changed, 1 deletion(-) delete mode 160000 Coolsoft-14 diff --git a/Coolsoft-14 b/Coolsoft-14 deleted file mode 160000 index 37221f72..00000000 --- a/Coolsoft-14 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 37221f725d7016bbe114f1c23f3e0d313ca01a4c From 8e5f175ec106de5ae95aac36d8038845bb7598d3 Mon Sep 17 00:00:00 2001 From: serag Date: Mon, 21 Apr 2014 21:15:52 +0200 Subject: [PATCH 138/526] Issue #206 Modified Controllers and added primative views --- tutor/app/controllers/lecturers_controller.rb | 4 ++-- tutor/app/controllers/students_controller.rb | 4 ++-- tutor/app/controllers/teaching_assistants_controller.rb | 4 ++-- tutor/app/views/lecturers/show.html.erb | 2 +- tutor/app/views/students/show.html.erb | 2 +- tutor/app/views/teaching_assistants/show.html.erb | 2 +- tutor/config/routes.rb | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tutor/app/controllers/lecturers_controller.rb b/tutor/app/controllers/lecturers_controller.rb index 096e7bdd..a64d7975 100644 --- a/tutor/app/controllers/lecturers_controller.rb +++ b/tutor/app/controllers/lecturers_controller.rb @@ -1,7 +1,7 @@ class LecturersController < ApplicationController - def index - end def show @lecturer = Lecturer.find(params[:id]) end + def index + end end \ No newline at end of file diff --git a/tutor/app/controllers/students_controller.rb b/tutor/app/controllers/students_controller.rb index bd7f3e35..84bf342d 100644 --- a/tutor/app/controllers/students_controller.rb +++ b/tutor/app/controllers/students_controller.rb @@ -1,7 +1,7 @@ class StudentsController < ApplicationController - def index - end def show @student = Student.find(params[:id]) end + def index + end end \ No newline at end of file diff --git a/tutor/app/controllers/teaching_assistants_controller.rb b/tutor/app/controllers/teaching_assistants_controller.rb index f07c2afe..10e2e7c9 100644 --- a/tutor/app/controllers/teaching_assistants_controller.rb +++ b/tutor/app/controllers/teaching_assistants_controller.rb @@ -1,7 +1,7 @@ class TeachingAssistantsController < ApplicationController - def index - end def show @teaching_assistant = TeachingAssistant.find(params[:id]) end + def index + end end \ No newline at end of file diff --git a/tutor/app/views/lecturers/show.html.erb b/tutor/app/views/lecturers/show.html.erb index b5386660..256accc2 100644 --- a/tutor/app/views/lecturers/show.html.erb +++ b/tutor/app/views/lecturers/show.html.erb @@ -1,7 +1,7 @@ - CoolSoft - Java Tutor + CoolSoft - Java Tutor | <%= @lecturer.id%>'s Profile

I am <%= @lecturer.email%>

diff --git a/tutor/app/views/students/show.html.erb b/tutor/app/views/students/show.html.erb index 298eccd4..5d06eaf6 100644 --- a/tutor/app/views/students/show.html.erb +++ b/tutor/app/views/students/show.html.erb @@ -1,7 +1,7 @@ - CoolSoft - Java Tutor + CoolSoft - Java tutor | <%= @student.id%>'s Profile

I am <%= @student.email%>

diff --git a/tutor/app/views/teaching_assistants/show.html.erb b/tutor/app/views/teaching_assistants/show.html.erb index c0cb5ab1..e87bb1db 100644 --- a/tutor/app/views/teaching_assistants/show.html.erb +++ b/tutor/app/views/teaching_assistants/show.html.erb @@ -1,7 +1,7 @@ - CoolSoft - Java Tutor + CoolSoft - Java Tutor | <%= @teaching_assistant.id%>'s Profile

I am <%= @teaching_assistant.email%>

diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index dd86ad5c..e6f43c82 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -28,9 +28,9 @@ resources :solutions resources :problems resources :topics - resources :students - resources :teaching_assistants resources :lecturers + resources :teaching_assistants + resources :students # Example resource route with options: # resources :products do From db630ac5877d5bef8643f90461d1cde3dabf06da Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Mon, 21 Apr 2014 21:23:35 +0200 Subject: [PATCH 139/526] giving the current user the post created --- tutor/app/controllers/posts_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index b2ac6773..f12c0bc5 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -42,12 +42,15 @@ def create if lecturer_signed_in? @new_post.owner_id = current_lecturer.id @new_post.owner_type = "lecturer" + current_lecturer.posts << @new_post elsif teaching_assistant_signed_in? @new_post.owner_id = current_teaching_assistant.id @new_post.owner_type = "teaching assistant" + current_teaching_assistant << @new_post elsif student_signed_in? @new_post.owner_id = current_student.id @new_post.owner_type = "student" + current_student.posts << @new_post end if @new_post.save flash[:notice] = "Post successfully created" From d83bc286069928279264ed60e3010087efafd11e Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Mon, 21 Apr 2014 21:24:49 +0200 Subject: [PATCH 140/526] Fixed indentation in show view of posts --- tutor/app/views/posts/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/views/posts/show.html.erb b/tutor/app/views/posts/show.html.erb index 00d70d9d..858f2b82 100644 --- a/tutor/app/views/posts/show.html.erb +++ b/tutor/app/views/posts/show.html.erb @@ -6,7 +6,7 @@ <% unless @replies.blank? %> <% @replies.each do |reply| %>
- <%= reply.content %>
+ <%= reply.content %>

<% end %> From 5efd89576ed966b7f36781f2789348e02aa2feb3 Mon Sep 17 00:00:00 2001 From: metawaa Date: Mon, 21 Apr 2014 22:07:56 +0200 Subject: [PATCH 141/526] Adding the edit form --- tutor/app/controllers/courses_controller.rb | 21 +++++++++++-- tutor/app/views/courses/edit.html.erb | 34 ++++++++++++++++++++- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/tutor/app/controllers/courses_controller.rb b/tutor/app/controllers/courses_controller.rb index 5bd5e1f9..1f795a1f 100644 --- a/tutor/app/controllers/courses_controller.rb +++ b/tutor/app/controllers/courses_controller.rb @@ -142,9 +142,24 @@ def show def manage end + # [Edit a course - story 1.17] + #Description: This action is resposible for editing a specific course. + #Parameters: + # id: Course id + # Returns: + # null + # Author: Mohamed Metawaa + def update + @course = Course.find_by_id(params[:id]) + if @course.update(course_params) + redirect_to @course + else + render 'edit' + end + end + end + private def course_params params.require(:course).permit(:name,:code,:year,:semester,:description) - end - -end \ No newline at end of file + end \ No newline at end of file diff --git a/tutor/app/views/courses/edit.html.erb b/tutor/app/views/courses/edit.html.erb index 2a259c5f..9a3cb8bd 100644 --- a/tutor/app/views/courses/edit.html.erb +++ b/tutor/app/views/courses/edit.html.erb @@ -30,8 +30,40 @@ <%= button_to str, {:controller => :discussion_boards, :action => 'toggle', :id => @discussionBoard.id}, class: "btn btn-success", style: "float: left; margin-left: 15px" %>
-
+
+
+ <%= form_for :course, url: course_path(@course), method: :patch do |c| %> +

+

<%= c.label :name %>
+ <%= c.text_field :name %> +

+ +

+ <%= c.label :code %>
+ <%= c.text_area :code %> +

+ +

+ <%= c.label :year %>
+ <%= c.text_area :year %> +

+ +

+ <%= c.label :semester %>
+ <%= c.text_area :semester %> +

+

+ <%= c.label :description %>
+ <%= c.text_area :description %> +

+ +

+ <%= c.submit %> +

+ <% end %> + <%= link_to 'Back', courses_path %> +
<%= button_to "Delete Course", {:action => "destroy"}, class: "btn btn-danger" , style: "margin-top: 100px; float: right", method: :delete %> From a1354395920158ff9d913c429e72c8e7b30e469d Mon Sep 17 00:00:00 2001 From: Mohab Date: Mon, 21 Apr 2014 22:12:19 +0200 Subject: [PATCH 142/526] Adding recommend dialog --- tutor/app/assets/javascripts/tracks.js | 53 +++++++++++++++++----- tutor/app/assets/stylesheets/tracks.css | 2 +- tutor/app/controllers/tracks_controller.rb | 17 +++++++ tutor/config/routes.rb | 1 + 4 files changed, 60 insertions(+), 13 deletions(-) diff --git a/tutor/app/assets/javascripts/tracks.js b/tutor/app/assets/javascripts/tracks.js index 5fe1949c..d37a2209 100644 --- a/tutor/app/assets/javascripts/tracks.js +++ b/tutor/app/assets/javascripts/tracks.js @@ -1,15 +1,44 @@ // Semicolon (;) to ensure closing of earlier scripting // Encapsulation // $ is assigned to jQuery -; -(function ($) { - // DOM Ready - $(function () { - // Binding a click event - // From jQuery v.1.7.0 use .on() instead of .bind() - $('#my-button1').bind('click', function (e) { - e.preventDefault(); - $('#element_to_pop_up').bPopup(); - }); - }); -})(jQuery); + +function showdialog(id){ + + $.ajax({ + type: "GET", + url: '/tracks/recommend_problem/' + id, + datatype: 'json', + success: fill + }); +} + +function fill(data){ + elem = $('#container'); + elem.html(""); + if(Object.keys(data).length == 0){ + elem.html("
Empty
"); + $('.classmates_list').bPopup(); + return; + } + elem.html("
    "); + $.each(data, function (i , datum){ + datum = data[i]; + temp = "
  • " + datum + " " + i + "
  • " + elem.append(temp); + }); + elem.append("
"); + $('.classmates_list').bPopup(); +} +// ; +// (function ($) { +// // DOM Ready +// $(function () { +// // Binding a click event +// // From jQuery v.1.7.0 use .on() instead of .bind() +// $('.recommend').bind('click', function (e) { +// e.preventDefault(); + +// $('.classmates_list').bPopup(); +// }); +// }); +// })(jQuery); diff --git a/tutor/app/assets/stylesheets/tracks.css b/tutor/app/assets/stylesheets/tracks.css index cd66111d..446ede9a 100644 --- a/tutor/app/assets/stylesheets/tracks.css +++ b/tutor/app/assets/stylesheets/tracks.css @@ -1,4 +1,4 @@ -#element_to_pop_up { +.classmates_list { background-color:#fff; border-radius:10px; color:#000; diff --git a/tutor/app/controllers/tracks_controller.rb b/tutor/app/controllers/tracks_controller.rb index 51287bdc..8e525e52 100644 --- a/tutor/app/controllers/tracks_controller.rb +++ b/tutor/app/controllers/tracks_controller.rb @@ -68,6 +68,23 @@ def create end end + def recommend_problem + problem = Problem.find_by_id(params[:id]) + track = problem.track + topic = problem.track.topic + course = problem.track.topic.course + students_enrolled = course.students + students_receiving_recommendation = Hash.new + + students_enrolled.each do |student| + student_level = TrackProgression.get_progress(student.id,topic.id) + if (student_level == track.difficulty) + students_receiving_recommendation[student.id] = student.name + end + end + render json: students_receiving_recommendation + end + # [Create Track - Story 4.1] # permits the passed parameters # Parameters: diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index e9d7079c..59a145d8 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -12,6 +12,7 @@ # get 'products/index' post 'courses/new' => 'courses#new' get 'courses/sign_up' + get 'tracks/recommend_problem/:id' => 'tracks#recommend_problem' # You can have the root of your site routed with "root" From 4d0afc609c57985fcfddce20cf9f75df83614fe7 Mon Sep 17 00:00:00 2001 From: Khaled Date: Mon, 21 Apr 2014 22:14:00 +0200 Subject: [PATCH 143/526] Issue #193 Added method for getting field variables and Added documentation --- tutor/app/models/debugger.rb | 60 +++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/tutor/app/models/debugger.rb b/tutor/app/models/debugger.rb index fb48ce17..7acbcf4d 100644 --- a/tutor/app/models/debugger.rb +++ b/tutor/app/models/debugger.rb @@ -9,10 +9,16 @@ class Debugger < ActiveRecord::Base #Methods + # [Debugger: View Variables - Story 3.7] + # Returns a list of all variables in the class with + # their values + # Parameters: None + # Returns: An Array + # Author: Khaled Helmy def get_variables method_arguments = [] local_variables = [] - instance_variables = get_instance_variables + class_variables = get_class_variables flag = 0 input "locals" output_buffer = buffer_until_complete @@ -32,13 +38,52 @@ def get_variables local_variables = local_variables + variable_value end end - return method_arguments + local_variables + instance_variables + return method_arguments + local_variables + class_variables end - def get_instance_variables - input "dump this" + # [Debugger: View Variables - Story 3.7] + # Return the list of instance and static variables from within + # static methods + # Parameters: None + # Returns: An Array + # Author: Khaled Helmy + def get_class_variables + result = [] + input "print this.getClass().getName()" + flag = 0 + output_buffer = buffer_until_complete + output_buffer.each_line do |line| + if flag == 1 + class_name = output_buffer.split(" = ").last + input "fields " + class_name + fields_list = buffer_until_complete + fields_list.each_line do |line| + if line.match("fields list") + next + else + field_name = line.split(" ").last + input "print this." + field_name + field_result = buffer_until_complete + field_result = field_result.split(".").last + result << field_result + end + end + else + if line.match("Exception") + break + else + flag = 1 + end + end + return result end + # [Debugger: View Variables - Story 3.7] + # Takes a variable and evaluates its value + # Parameters: + # variable: A String containing a variable assignment + # Returns: An Array + # Author: Khaled Helmy def get_value variable result = [] if variable.match("instance") @@ -56,6 +101,13 @@ def get_value variable return result end + # [Debugger: View Variables - Story 3.7] + # Takes a line containing an object assignment and extracts + # the object name + # Parameters: + # variable: A String containing an object assignment + # Returns: A String + # Author: Khaled Helmy def get_name variable name = variable.split(" = ").first return name From e9c992fb465c3e56c0089d3722632d373acf6e76 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Mon, 21 Apr 2014 22:14:43 +0200 Subject: [PATCH 144/526] installed missing gems and changed in the edit post view --- tutor/Gemfile.lock | 2 ++ tutor/app/views/posts/edit.html.erb | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tutor/Gemfile.lock b/tutor/Gemfile.lock index fa0d2aac..43582f98 100644 --- a/tutor/Gemfile.lock +++ b/tutor/Gemfile.lock @@ -29,6 +29,7 @@ GEM atomic (1.1.16) bcrypt (3.1.7) builder (3.1.4) + chartkick (1.2.4) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -131,6 +132,7 @@ PLATFORMS ruby DEPENDENCIES + chartkick coffee-rails (~> 4.0.0) composite_primary_keys (~> 6.0.1) devise diff --git a/tutor/app/views/posts/edit.html.erb b/tutor/app/views/posts/edit.html.erb index 5f646fbe..2b66ea55 100644 --- a/tutor/app/views/posts/edit.html.erb +++ b/tutor/app/views/posts/edit.html.erb @@ -18,7 +18,6 @@ <%= f.label :content %>
<%= f.text_area :content, class:"form-control", style: "margin-left:auto; margin-right:auto;height:200px;width:500px;resize:none", placeholder: "Enter your post"%> - <%= f.hidden_field :discussion_board_id, value: params[:discussion_board_id] %>

<%= f.submit "Update Post", class: "btn btn-success"%> From 4a4499b5b4fce8a50ac36d79f5149c08e92d6d87 Mon Sep 17 00:00:00 2001 From: metawaa Date: Mon, 21 Apr 2014 22:23:14 +0200 Subject: [PATCH 145/526] fixing implementation 3 --- tutor/app/views/courses/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/views/courses/show.html.erb b/tutor/app/views/courses/show.html.erb index baf5afb5..a50f2758 100644 --- a/tutor/app/views/courses/show.html.erb +++ b/tutor/app/views/courses/show.html.erb @@ -36,7 +36,7 @@

    <% t.tracks.each do |tt|%> - <% color = "label label-default" %> + <% color = "label label-default" %>
  • <%= link_to tt.title , tt , class: color %> From 4ea378d1952c57ec81c650c3ab2495ed87e683ed Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Tue, 22 Apr 2014 01:26:01 +0200 Subject: [PATCH 146/526] fixed logic for the insertion --- tutor/app/controllers/teaching_assistants_controller.rb | 8 +++++--- tutor/app/views/teaching_assistants/index.html.erb | 6 +++--- tutor/app/views/teaching_assistants/new.html.erb | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tutor/app/controllers/teaching_assistants_controller.rb b/tutor/app/controllers/teaching_assistants_controller.rb index 72b51bcb..f1fdfa59 100644 --- a/tutor/app/controllers/teaching_assistants_controller.rb +++ b/tutor/app/controllers/teaching_assistants_controller.rb @@ -5,14 +5,16 @@ def new end def create - @teaching_assistant = teaching_assistants.where(email: params[:email]) - @course = courses.find_by_id(params[:course_id]) + @teaching_assistant = TeachingAssistant.find_by_id(params[:teaching_assistant][:id]) + @course = Course.find_by_id(params[:course_id]) + @course.TAs << @teaching_assistant + redirect_to :action => 'index' end def index @course = Course.find(params[:course_id]) - @teaching_assistants = @course.TAs.order('name') + @course_teaching_assistants = @course.TAs.order('name') end diff --git a/tutor/app/views/teaching_assistants/index.html.erb b/tutor/app/views/teaching_assistants/index.html.erb index 3b5396f4..e12efa22 100644 --- a/tutor/app/views/teaching_assistants/index.html.erb +++ b/tutor/app/views/teaching_assistants/index.html.erb @@ -8,12 +8,12 @@ - - + + - <% @teaching_assistants.each do |teacing_assistant| %> + <% @course_teaching_assistants.each do |teaching_assistant| %> diff --git a/tutor/app/views/teaching_assistants/new.html.erb b/tutor/app/views/teaching_assistants/new.html.erb index 644b0d70..d93e6201 100644 --- a/tutor/app/views/teaching_assistants/new.html.erb +++ b/tutor/app/views/teaching_assistants/new.html.erb @@ -2,7 +2,7 @@ <%= form_for :teaching_assistant, url: {action: "create"} do |f| %>

    - <%= select("teaching_assistant", "email", TeachingAssistant.find(:all).collect {|p| [ p.name ] }, {:prompt => 'Select'}) %> + <%= select("teaching_assistant", "id", TeachingAssistant.find(:all).collect {|p| [p.name ,p.id ] }, {:prompt => 'Select'}) %>

    From f38e820a362dae1d65184c5f51b0a3a7050debec Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Tue, 22 Apr 2014 01:44:29 +0200 Subject: [PATCH 147/526] fixed saving fields when leaving one of the fields empty and added values to the form fields to be given at rendering --- tutor/app/controllers/posts_controller.rb | 5 +++-- tutor/app/views/posts/new.html.erb | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index f12c0bc5..138158dc 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -52,16 +52,17 @@ def create @new_post.owner_type = "student" current_student.posts << @new_post end + @discussion_board = DiscussionBoard.find(discussion_board_params[:discussion_board_id]) if @new_post.save flash[:notice] = "Post successfully created" - @discussion_board = DiscussionBoard.find(discussion_board_params[:discussion_board_id]) @discussion_board.posts << @new_post redirect_to :controller => 'posts', :action => 'show', :id => @new_post.id else if @new_post.errors.any? flash[:notice] = @new_post.errors.full_messages.first end - render :action => 'new' + #redirect_to :controller => 'posts', :action => 'new',:discussion_board_id => @discussion_board.id + render :action => 'new' end end diff --git a/tutor/app/views/posts/new.html.erb b/tutor/app/views/posts/new.html.erb index af096d8a..b984fd1e 100644 --- a/tutor/app/views/posts/new.html.erb +++ b/tutor/app/views/posts/new.html.erb @@ -12,13 +12,13 @@ <%= form_for :post, url: {action: "create"} do |f| %>

    <%= f.label "Title" %>
    - <%= f.text_field :title, autofocus: true, class:"form-control", style: "width:300px", placeholder: "Title"%> + <%= f.text_field :title, autofocus: true, class:"form-control", style: "width:300px", placeholder: "Title",:value => @new_post.title%>

    <%= f.label :content %>
    <%= f.text_area :content, class:"form-control", style: "margin-left:auto; - margin-right:auto;height:200px;width:500px;resize:none", placeholder: "Enter your post"%> - <%= f.hidden_field :discussion_board_id, value: params[:discussion_board_id] %> + margin-right:auto;height:200px;width:500px;resize:none", placeholder: "Enter your post",:value => @new_post.content%> + <%= f.hidden_field :discussion_board_id, value: params[:discussion_board_id], :value => @discussion_board.id%>

    <%= f.submit "Save", class: "btn btn-success"%> From a14ef1e004af6aae86d267a8e61f20c32e52ed0f Mon Sep 17 00:00:00 2001 From: Mohab Date: Tue, 22 Apr 2014 02:22:10 +0200 Subject: [PATCH 148/526] Inserting recommendation in database --- tutor/app/assets/javascripts/tracks.js | 33 +++++++++++++++++----- tutor/app/assets/stylesheets/tracks.css | 14 +++++++-- tutor/app/controllers/tracks_controller.rb | 16 ++++++++++- tutor/app/views/tracks/show.html.erb | 18 ++++-------- tutor/config/routes.rb | 4 +-- 5 files changed, 59 insertions(+), 26 deletions(-) diff --git a/tutor/app/assets/javascripts/tracks.js b/tutor/app/assets/javascripts/tracks.js index d37a2209..3dce4149 100644 --- a/tutor/app/assets/javascripts/tracks.js +++ b/tutor/app/assets/javascripts/tracks.js @@ -2,17 +2,17 @@ // Encapsulation // $ is assigned to jQuery -function showdialog(id){ - +function showdialog(problem_id, recommender_id){ $.ajax({ type: "GET", - url: '/tracks/recommend_problem/' + id, + url: '/tracks/show_classmates/' + problem_id, datatype: 'json', - success: fill + success: function(json){ + fill(json, problem_id, recommender_id)} }); } -function fill(data){ +function fill(data, problem_id, recommender_id){ elem = $('#container'); elem.html(""); if(Object.keys(data).length == 0){ @@ -20,15 +20,34 @@ function fill(data){ $('.classmates_list').bPopup(); return; } - elem.html("

      "); + elem.html("

      Recommend this problem to

      ") + elem.append("
        "); $.each(data, function (i , datum){ datum = data[i]; - temp = "
      • " + datum + " " + i + "
      • " + temp = "
      • " + datum + + "" + + "
      • " elem.append(temp); }); elem.append("
      "); $('.classmates_list').bPopup(); } + +function recommend(problem_id, recommender_id, student_id){ + + $.ajax({ + type: "POST", + url: '/tracks/insert_recommendation/', + data: { p_id : problem_id, + r_id : recommender_id, + s_id : student_id + } + }); + +} // ; // (function ($) { // // DOM Ready diff --git a/tutor/app/assets/stylesheets/tracks.css b/tutor/app/assets/stylesheets/tracks.css index 446ede9a..768b794d 100644 --- a/tutor/app/assets/stylesheets/tracks.css +++ b/tutor/app/assets/stylesheets/tracks.css @@ -4,6 +4,14 @@ color:#000; display:none; padding:10px; - min-width:100px; - min-height: 100px; - } \ No newline at end of file + min-width:400px; + min-height: 600px; + } +#container li{ + padding: 10px; + list-style: none; +} + +.recommend { + float: right; +} \ No newline at end of file diff --git a/tutor/app/controllers/tracks_controller.rb b/tutor/app/controllers/tracks_controller.rb index 8e525e52..c7ec1279 100644 --- a/tutor/app/controllers/tracks_controller.rb +++ b/tutor/app/controllers/tracks_controller.rb @@ -68,7 +68,7 @@ def create end end - def recommend_problem + def show_classmates problem = Problem.find_by_id(params[:id]) track = problem.track topic = problem.track.topic @@ -85,6 +85,20 @@ def recommend_problem render json: students_receiving_recommendation end + def insert_recommendation + problem_id = params[:p_id] + student_id = params[:s_id] + recommender_id = params[:r_id] + + recommendation = Recommendation.new + recommendation.problem_id = problem_id + recommendation.student_id = student_id + recommendation.recommender_id = recommender_id + recommendation.save + + render :nothing => true + end + # [Create Track - Story 4.1] # permits the passed parameters # Parameters: diff --git a/tutor/app/views/tracks/show.html.erb b/tutor/app/views/tracks/show.html.erb index bbe5182d..9b980bf4 100644 --- a/tutor/app/views/tracks/show.html.erb +++ b/tutor/app/views/tracks/show.html.erb @@ -32,7 +32,7 @@ <%= link_to p.title , p , style: 'color:#003366;' , class: color %> -
      Click me!
      +
      Recommend to classmates
      @@ -40,18 +40,10 @@
      <% end %> - -
      -
      -
        -
      • kdj ie Lorem ipsum dolor sit amet
      • -
      • consectetur adipisicing elit, sed do eiusmod
      • -
      • 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
      • -
      • cillum dolore eu fugiat nulla pariatur. Excepteur
      • -
      -
      +
      +
      +
      +
      <% if @can_edit %> diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index 59a145d8..22eef24b 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -12,8 +12,8 @@ # get 'products/index' post 'courses/new' => 'courses#new' get 'courses/sign_up' - get 'tracks/recommend_problem/:id' => 'tracks#recommend_problem' - + get 'tracks/show_classmates/:id' => 'tracks#show_classmates' + post 'tracks/insert_recommendation' => 'tracks#insert_recommendation' # You can have the root of your site routed with "root" root 'site#index' From 28afbd9ac3a29eb0f1149953670a61dcd59ee27c Mon Sep 17 00:00:00 2001 From: Mohab Date: Tue, 22 Apr 2014 02:40:24 +0200 Subject: [PATCH 149/526] Preventing duplicate recommendations --- tutor/app/assets/javascripts/tracks.js | 3 ++- tutor/app/controllers/tracks_controller.rb | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tutor/app/assets/javascripts/tracks.js b/tutor/app/assets/javascripts/tracks.js index 3dce4149..fedf2dad 100644 --- a/tutor/app/assets/javascripts/tracks.js +++ b/tutor/app/assets/javascripts/tracks.js @@ -16,7 +16,7 @@ function fill(data, problem_id, recommender_id){ elem = $('#container'); elem.html(""); if(Object.keys(data).length == 0){ - elem.html("
      Empty
      "); + elem.html("
      No classmates to recommend this problem to
      "); $('.classmates_list').bPopup(); return; } @@ -46,6 +46,7 @@ function recommend(problem_id, recommender_id, student_id){ s_id : student_id } }); + showdialog(problem_id, recommender_id); } // ; diff --git a/tutor/app/controllers/tracks_controller.rb b/tutor/app/controllers/tracks_controller.rb index c7ec1279..6ab291dc 100644 --- a/tutor/app/controllers/tracks_controller.rb +++ b/tutor/app/controllers/tracks_controller.rb @@ -79,7 +79,12 @@ def show_classmates students_enrolled.each do |student| student_level = TrackProgression.get_progress(student.id,topic.id) if (student_level == track.difficulty) - students_receiving_recommendation[student.id] = student.name + if (!Recommendation.where( + :problem_id => problem.id, + :recommender_id => current_student.id, + :student_id => student.id).present?) + students_receiving_recommendation[student.id] = student.name + end end end render json: students_receiving_recommendation From 4e3d903c260a60fe3b375611e213613c30cabefc Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Tue, 22 Apr 2014 04:44:55 +0200 Subject: [PATCH 150/526] added flash , catching exceptions when trying to add TA twice --- .../teaching_assistants_controller.rb | 19 ++++++++++++++----- tutor/app/models/teaching_assistant.rb | 2 ++ .../views/teaching_assistants/new.html.erb | 8 +++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/tutor/app/controllers/teaching_assistants_controller.rb b/tutor/app/controllers/teaching_assistants_controller.rb index f1fdfa59..1408558f 100644 --- a/tutor/app/controllers/teaching_assistants_controller.rb +++ b/tutor/app/controllers/teaching_assistants_controller.rb @@ -1,14 +1,23 @@ class TeachingAssistantsController < ApplicationController def new - + @course = Course.find_by_id(params[:course_id]) end def create - @teaching_assistant = TeachingAssistant.find_by_id(params[:teaching_assistant][:id]) - @course = Course.find_by_id(params[:course_id]) - @course.TAs << @teaching_assistant - redirect_to :action => 'index' + begin + @teaching_assistant = TeachingAssistant.find_by_id(params[:teaching_assistant][:id]) + @course = Course.find_by_id(params[:course_id]) + @course.TAs << @teaching_assistant + current_lecturer.worked_with << @teaching_assistant + flash[:notice]='TA added!' + redirect_to :action => 'index' + rescue + flash[:notice]='TA is already added to the course' + redirect_to :action => 'new' + end + + end diff --git a/tutor/app/models/teaching_assistant.rb b/tutor/app/models/teaching_assistant.rb index 541e789e..7b8fb18c 100644 --- a/tutor/app/models/teaching_assistant.rb +++ b/tutor/app/models/teaching_assistant.rb @@ -5,6 +5,8 @@ class TeachingAssistant < ActiveRecord::Base :recoverable, :rememberable, :trackable, :validatable #Validations + validates :id, uniqueness: true + #Relations has_many :posts, as: :owner, dependent: :destroy diff --git a/tutor/app/views/teaching_assistants/new.html.erb b/tutor/app/views/teaching_assistants/new.html.erb index d93e6201..7995dcc7 100644 --- a/tutor/app/views/teaching_assistants/new.html.erb +++ b/tutor/app/views/teaching_assistants/new.html.erb @@ -1,10 +1,16 @@

      Add a Teaching Assistant

      - +
      +<% if flash[:notice] -%> +
      <%= flash[:notice] %>
      +<% end %> +
      <%= form_for :teaching_assistant, url: {action: "create"} do |f| %>

      <%= select("teaching_assistant", "id", TeachingAssistant.find(:all).collect {|p| [p.name ,p.id ] }, {:prompt => 'Select'}) %>

      + +

      <%= f.submit "Add TA", class: "btn btn-success"%>

      From a2619b8f9e0d53258635fbaaed8649bb9f19cd7c Mon Sep 17 00:00:00 2001 From: mohamedsaeed93 Date: Tue, 22 Apr 2014 06:35:56 +0200 Subject: [PATCH 151/526] Issue #194, submitting using Ajax --- tutor/.gitignore | 2 +- .../assets/javascripts/solutions.js.coffee | 33 +++++++++++++++++- tutor/app/controllers/solutions_controller.rb | 34 ++++++++----------- tutor/app/models/solution.rb | 8 +++-- tutor/app/views/solutions/_new.html.erb | 7 +++- tutor/app/views/solutions/alert.js.erb | 8 ----- 6 files changed, 60 insertions(+), 32 deletions(-) delete mode 100644 tutor/app/views/solutions/alert.js.erb diff --git a/tutor/.gitignore b/tutor/.gitignore index 7e2d3651..4786acfb 100644 --- a/tutor/.gitignore +++ b/tutor/.gitignore @@ -38,6 +38,6 @@ Gemfile.lock, .ruby-version, .ruby-gemset # Ignoring generated model diagram models.svg -# Ignoring Java files and class files +# Ignoring .java files and .class files *.java *.class diff --git a/tutor/app/assets/javascripts/solutions.js.coffee b/tutor/app/assets/javascripts/solutions.js.coffee index ca51b435..69cabf82 100644 --- a/tutor/app/assets/javascripts/solutions.js.coffee +++ b/tutor/app/assets/javascripts/solutions.js.coffee @@ -69,4 +69,35 @@ root.previous = () -> # Returns: none # Author: Rami Khalil (Temporary) root.stop = () -> - toggleDebug() \ No newline at end of file + toggleDebug() + +@validate_code = (problem_id) -> + code = $('#solution_code').val() + mins = parseInt($('#mins').text()) + secs = parseInt($('#secs').text()) + time = mins*60 + secs + #start_spin() + $.ajax + type: "POST" + url: '/solutions' + data: {problem_id: problem_id, code: code, time: time} + datatype: 'json' + success: (data) -> + #stop_spin() + success = $('#validate_success') + errors = $('#validate_error') + success.html("") + for i in data["success"] + success.append("#{i}
      ") + errors.html("") + for i in data["failure"] + errors.append("#{i}
      ") + if code.length isnt 0 + alert 'Solution has been submitted successfully' + else + alert 'Blank submissions are not allowed' + return + error: (data) -> + #stop_spin() + return + return \ No newline at end of file diff --git a/tutor/app/controllers/solutions_controller.rb b/tutor/app/controllers/solutions_controller.rb index 7726b3d8..2c7b3235 100644 --- a/tutor/app/controllers/solutions_controller.rb +++ b/tutor/app/controllers/solutions_controller.rb @@ -8,21 +8,17 @@ class SolutionsController < ApplicationController # Returns: none # Author: MOHAMEDSAEED def create - @solution = Solution.new(solution_params) - @solution.student_id = current_student.id - @solution.status = 0 - @solution.length = @solution.code.length - testcases = @solution.problem.test_cases - file = "st[" + current_student.id.to_s + "]pr[" + @solution.problem_id.to_s + "]so[" - #+ Solution_id - response_message = Solution.validate(@solution.code , testcases , file) - @solution.status = response_message[:status] - errors = response_message[:failure] - success = response_message[:success] - respond_to do |format| - format.html { redirect_to :back } - format.js { render 'alert.js.erb' } - end + solution = Solution.new({problem_id: params[:problem_id], code: params[:code], + time: params[:time]}) + solution.student_id = current_student.id + solution.length = solution.code.length + testcases = solution.problem.test_cases + #response_message = Solution.validate(solution.code , testcases , file) + response_message = {:success => ["Success"], :failure => ["Failure"]} + #solution.status = response_message[:status] + solution.save + render json: response_message + #end end # [Code Editor: Write Code - Story 3.3] @@ -32,9 +28,9 @@ def create # problem_id: Hidden field for problem id # Returns: none # Author: MOHAMEDSAEED - private - def solution_params - params.require(:solution).permit(:code , :problem_id) - end + # private + # def solution_params + # params.require(:solution).permit(:code , :problem_id) + # end end \ No newline at end of file diff --git a/tutor/app/models/solution.rb b/tutor/app/models/solution.rb index b30a8aa1..6214992a 100644 --- a/tutor/app/models/solution.rb +++ b/tutor/app/models/solution.rb @@ -38,10 +38,14 @@ def self.validate(code, testcases, file) response[:failure] << "Logic error: for input: " + input +" , expected output: " + expected_output +" but your output was: " + output - response[:status] = 5 + unless response[:status] == 4 + response[:status] = 5 + end else response[:success] << "Your Solution is correct , Passed" - response[:status] = 1 + unless(response[:status] == 4 | 5) + response[:status] = 1 + end end else runtime_error = Executer.get_runtime_error() diff --git a/tutor/app/views/solutions/_new.html.erb b/tutor/app/views/solutions/_new.html.erb index 3c737a24..96c2565a 100644 --- a/tutor/app/views/solutions/_new.html.erb +++ b/tutor/app/views/solutions/_new.html.erb @@ -34,7 +34,8 @@ Wrong Answer Runtime Error Compilation Error - <%= f.submit "Submit", confirm: 'Are you sure you want to submit your solution?' %> + <%= button_tag 'Submit', type: 'Button', + id: 'submitButton', onClick: "validate_code(#{params[:id]})" %>
    TitleDescriptionNameEmail
    <%= teaching_assistant.name %>
    @@ -43,5 +44,9 @@ Output:

    Output response +

    +
    +
    +

    <% end %> \ No newline at end of file diff --git a/tutor/app/views/solutions/alert.js.erb b/tutor/app/views/solutions/alert.js.erb deleted file mode 100644 index 31d535dc..00000000 --- a/tutor/app/views/solutions/alert.js.erb +++ /dev/null @@ -1,8 +0,0 @@ -<% if @solution.save %> - alert('Your Solution has been submitted successfully'); -<% end %> -<% if !@solution.save %> - alert('Blank submissions are not allowed'); -<% end %> - - From 683d7a99076e31d0e821f2c8dc6bf678edec1e78 Mon Sep 17 00:00:00 2001 From: Khaled Date: Tue, 22 Apr 2014 07:19:21 +0200 Subject: [PATCH 152/526] Issue #193 Fixed documentation --- tutor/app/models/debugger.rb | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tutor/app/models/debugger.rb b/tutor/app/models/debugger.rb index 7acbcf4d..0435b37f 100644 --- a/tutor/app/models/debugger.rb +++ b/tutor/app/models/debugger.rb @@ -10,10 +10,12 @@ class Debugger < ActiveRecord::Base #Methods # [Debugger: View Variables - Story 3.7] - # Returns a list of all variables in the class with - # their values + # Fetches the variables found in the class and returns + # a list of all variables in the class with their + # associated values # Parameters: None - # Returns: An Array + # Returns: + # An array. It contains the list of variables and their values # Author: Khaled Helmy def get_variables method_arguments = [] @@ -42,10 +44,12 @@ def get_variables end # [Debugger: View Variables - Story 3.7] - # Return the list of instance and static variables from within - # static methods + # Return the list of instance and static variables of the + # class from within static methods # Parameters: None - # Returns: An Array + # Returns: + # An array. It contains the list of instance and static + # variables and their associated values # Author: Khaled Helmy def get_class_variables result = [] @@ -79,10 +83,11 @@ def get_class_variables end # [Debugger: View Variables - Story 3.7] - # Takes a variable and evaluates its value + # Takes an object and evaluates its value # Parameters: - # variable: A String containing a variable assignment - # Returns: An Array + # variable: a string containing an instance object + # Returns: + # An array. It contains the values inside an object # Author: Khaled Helmy def get_value variable result = [] @@ -105,8 +110,9 @@ def get_value variable # Takes a line containing an object assignment and extracts # the object name # Parameters: - # variable: A String containing an object assignment - # Returns: A String + # variable: A string containing an object assignment + # Returns: + # A string. It contains the object name # Author: Khaled Helmy def get_name variable name = variable.split(" = ").first From 8fd5e9bc9e6343f54e502d3306c5c1cfadf6224c Mon Sep 17 00:00:00 2001 From: Mohab Date: Tue, 22 Apr 2014 08:58:19 +0200 Subject: [PATCH 153/526] Issue #203 Editing duplicate recommendation --- tutor/app/assets/javascripts/tracks.js | 13 +++++++++---- tutor/app/controllers/tracks_controller.rb | 7 +++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tutor/app/assets/javascripts/tracks.js b/tutor/app/assets/javascripts/tracks.js index fedf2dad..ac2d5643 100644 --- a/tutor/app/assets/javascripts/tracks.js +++ b/tutor/app/assets/javascripts/tracks.js @@ -24,11 +24,16 @@ function fill(data, problem_id, recommender_id){ elem.append("
      "); $.each(data, function (i , datum){ datum = data[i]; - temp = "
    • " + datum + + temp = "
    • " + datum['student_name'] + "" + + "onclick='recommend(" + problem_id + "," + recommender_id + "," + i + ")'"; + if (datum['recommended_before'] == 'true' ){ + temp += "disabled"; + temp += ">recommended before" + }else { + temp += ">recommend"; + } + temp += "" + "
    • " elem.append(temp); }); diff --git a/tutor/app/controllers/tracks_controller.rb b/tutor/app/controllers/tracks_controller.rb index 6ab291dc..c355fe04 100644 --- a/tutor/app/controllers/tracks_controller.rb +++ b/tutor/app/controllers/tracks_controller.rb @@ -79,11 +79,14 @@ def show_classmates students_enrolled.each do |student| student_level = TrackProgression.get_progress(student.id,topic.id) if (student_level == track.difficulty) - if (!Recommendation.where( + students_receiving_recommendation[student.id] = Hash.new + students_receiving_recommendation[student.id]['student_name'] = student.name + students_receiving_recommendation[student.id]['recommended_before'] = 'false' + if (Recommendation.where( :problem_id => problem.id, :recommender_id => current_student.id, :student_id => student.id).present?) - students_receiving_recommendation[student.id] = student.name + students_receiving_recommendation[student.id]['recommended_before'] = 'true' end end end From 65c1b9b0c8d5122b569d78f8fc6037073161e1bf Mon Sep 17 00:00:00 2001 From: metawaa Date: Tue, 22 Apr 2014 09:20:03 +0200 Subject: [PATCH 154/526] fixing implementation 4 --- tutor/app/views/courses/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutor/app/views/courses/show.html.erb b/tutor/app/views/courses/show.html.erb index a50f2758..62b688ff 100644 --- a/tutor/app/views/courses/show.html.erb +++ b/tutor/app/views/courses/show.html.erb @@ -30,7 +30,7 @@ data-toggle="collapse" data-parent="#accordion" href="#<%= t.id.to_s %>"> - <%= link_to t.title , t , style: 'color:#003366;'%> + <%= link_to t.title, t, style: 'color:#003366;'%>
      <%= t.tracks.count %>
@@ -39,7 +39,7 @@ <% color = "label label-default" %>
  • - <%= link_to tt.title , tt , class: color %> + <%= link_to tt.title, tt, class: color %>
  • <% end %> From ad916c6905c13245b5499acca78ae0ea9c2668a7 Mon Sep 17 00:00:00 2001 From: metawaa Date: Tue, 22 Apr 2014 09:42:16 +0200 Subject: [PATCH 155/526] fixing scenario --- tutor/app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/controllers/courses_controller.rb b/tutor/app/controllers/courses_controller.rb index 1f795a1f..bd2b7b7e 100644 --- a/tutor/app/controllers/courses_controller.rb +++ b/tutor/app/controllers/courses_controller.rb @@ -152,7 +152,7 @@ def manage def update @course = Course.find_by_id(params[:id]) if @course.update(course_params) - redirect_to @course + render 'show' else render 'edit' end From 39ecac18d3d7a90c0931c397dc93139d5c1d20c8 Mon Sep 17 00:00:00 2001 From: metawaa Date: Tue, 22 Apr 2014 09:56:23 +0200 Subject: [PATCH 156/526] fixing implementation --- tutor/app/views/courses/edit.html.erb | 36 +++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tutor/app/views/courses/edit.html.erb b/tutor/app/views/courses/edit.html.erb index 9a3cb8bd..bfdf5a7b 100644 --- a/tutor/app/views/courses/edit.html.erb +++ b/tutor/app/views/courses/edit.html.erb @@ -35,29 +35,29 @@ <%= form_for :course, url: course_path(@course), method: :patch do |c| %>



    <%= c.label :name %>
    - <%= c.text_field :name %> -

    - -

    - <%= c.label :code %>
    - <%= c.text_area :code %> -

    + <%= c.text_field :name %> +

    - <%= c.label :year %>
    - <%= c.text_area :year %> -

    + <%= c.label :code %>
    + <%= c.text_area :code %> +

    -

    - <%= c.label :semester %>
    - <%= c.text_area :semester %> -

    +

    + <%= c.label :year %>
    + <%= c.text_area :year %> +

    -

    - <%= c.label :description %>
    - <%= c.text_area :description %> +

    + <%= c.label :semester %>
    + <%= c.text_area :semester %>

    - + +

    + <%= c.label :description %>
    + <%= c.text_area :description %> +

    +

    <%= c.submit %>

    From 29432e5c130fef49140aeed7dbad514fa6aa8470 Mon Sep 17 00:00:00 2001 From: metawaa Date: Tue, 22 Apr 2014 10:15:52 +0200 Subject: [PATCH 157/526] fixing routes --- tutor/app/views/courses/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/views/courses/index.html.erb b/tutor/app/views/courses/index.html.erb index e30f1f36..1e90367d 100644 --- a/tutor/app/views/courses/index.html.erb +++ b/tutor/app/views/courses/index.html.erb @@ -19,7 +19,7 @@ <% @courses.each do |c| %> - <%= link_to c.name, :controller => 'courses', :action => 'show', :id => c.id, + <%= link_to c.name, {:controller => 'courses', :action => 'show', :id => c.id }, :method => :get, class: "btn btn-success" %> <%= c.code %> From de18ce119e459b3df37739788a33603ebe3c0c23 Mon Sep 17 00:00:00 2001 From: mohamedsaeed93 Date: Tue, 22 Apr 2014 11:48:19 +0200 Subject: [PATCH 158/526] Issue #194, Adding documentation --- .../assets/javascripts/solutions.js.coffee | 9 +++++++- tutor/app/controllers/solutions_controller.rb | 15 +----------- tutor/app/models/solution.rb | 23 ++++++++----------- tutor/app/views/solutions/_new.html.erb | 11 +++------ 4 files changed, 21 insertions(+), 37 deletions(-) diff --git a/tutor/app/assets/javascripts/solutions.js.coffee b/tutor/app/assets/javascripts/solutions.js.coffee index 69cabf82..29cc87c1 100644 --- a/tutor/app/assets/javascripts/solutions.js.coffee +++ b/tutor/app/assets/javascripts/solutions.js.coffee @@ -7,7 +7,6 @@ root = exports ? this # none # Returns: none # Author: Rami Khalil (Temporary) - root.toggleDebug = () -> $('#debugButton').prop 'hidden', !$('#debugButton').prop 'hidden' $('#compileButton').prop 'hidden', !$('#compileButton').prop 'hidden' @@ -71,6 +70,14 @@ root.previous = () -> root.stop = () -> toggleDebug() +# [Compiler: Validate - Story 3.5] +# submits a solution in the form without refreshing +# using ajax showing an alert box for success and failure scenarios +# Parameters: +# problem_id: the id of the problem being solved +# Returns: a json object containing two arrays one for the errors +# of the current code and the other containing success messages +# Author: MOHAMEDSAEED @validate_code = (problem_id) -> code = $('#solution_code').val() mins = parseInt($('#mins').text()) diff --git a/tutor/app/controllers/solutions_controller.rb b/tutor/app/controllers/solutions_controller.rb index 2c7b3235..8cd4a435 100644 --- a/tutor/app/controllers/solutions_controller.rb +++ b/tutor/app/controllers/solutions_controller.rb @@ -2,7 +2,6 @@ class SolutionsController < ApplicationController # [Code Editor: Write Code - Story 3.3] # submits a solution for a problem that the student chose - # and show an alert box for success and failure scenarios # Parameters: # solution_params: submitted from the form_for # Returns: none @@ -13,24 +12,12 @@ def create solution.student_id = current_student.id solution.length = solution.code.length testcases = solution.problem.test_cases + solution.status = 0 #response_message = Solution.validate(solution.code , testcases , file) response_message = {:success => ["Success"], :failure => ["Failure"]} #solution.status = response_message[:status] solution.save render json: response_message - #end end - - # [Code Editor: Write Code - Story 3.3] - # Fills the ID of the problem , code from the form_for - # Parameters: - # code: The written code for the problem - # problem_id: Hidden field for problem id - # Returns: none - # Author: MOHAMEDSAEED - # private - # def solution_params - # params.require(:solution).permit(:code , :problem_id) - # end end \ No newline at end of file diff --git a/tutor/app/models/solution.rb b/tutor/app/models/solution.rb index 6214992a..5a08ac11 100644 --- a/tutor/app/models/solution.rb +++ b/tutor/app/models/solution.rb @@ -7,22 +7,17 @@ class Solution < ActiveRecord::Base belongs_to :student belongs_to :problem - - - - #Scoops - #Methods # [Compiler: Validate - Story 3.5] - # checks the validity of a submitted solution - # and show the #compilation, runtime and logic errors if exist + # Checks the validity of a submitted solution + # and show the runtime and logic errors if exist # Parameters: # code: the code written in the editor from the form_for # testcases: the testcases for the given problem # file: the name of the file which is compiled successfully - # without errors + # without errors # Returns: a hash response containing status for the solution, - # solution errors or success message. + # solution errors or success message. # Author: MOHAMEDSAEED def self.validate(code, testcases, file) response = {status: 0, success: [], failure: []} @@ -31,7 +26,7 @@ def self.validate(code, testcases, file) testcases.each do |testcase| input = testcase.input expected_output = testcase.output - runtime_check = Executer.execute(file , input) + runtime_check = Executer.execute(file, input) if(runtime_check) output = Executer.get_output() if output != expected_output? @@ -42,7 +37,7 @@ def self.validate(code, testcases, file) response[:status] = 5 end else - response[:success] << "Your Solution is correct , Passed" + response[:success] << "Your Solution is correct, Passed" unless(response[:status] == 4 | 5) response[:status] = 1 end @@ -64,13 +59,13 @@ def self.validate(code, testcases, file) # [Compiler: Validate - Story 3.5] # Parameters: # s_id : the id of the current Student - # p_id : the id of the current Problem + # p_id : the id of the current Problem # Returns: the number of trials the student made for this problem # Author: MOHAMEDSAEED def self.get_num_of_trials(s_id , p_id) num_of_trials = Solution.distinct.count(:all, - :conditions => [" student_id = ? AND problem_id = ? AND status != ? " , - s_id , p_id , 3]) + :conditions => ["student_id = ? AND problem_id = ? AND status != ?", + s_id, p_id, 3]) end #Constants diff --git a/tutor/app/views/solutions/_new.html.erb b/tutor/app/views/solutions/_new.html.erb index 96c2565a..33aff5c0 100644 --- a/tutor/app/views/solutions/_new.html.erb +++ b/tutor/app/views/solutions/_new.html.erb @@ -1,17 +1,12 @@ - -

    <%= flash[:success] %>

    -

    <%= flash[:alert] %>

    - Time spent: 0:00 <%= form_for :solution, :url => { :controller => "solutions", :action => "create" }, - :html => {:method => :post} , remote: true do |f| %> - <%= @code = f.text_area :code, placeholder: "Write your code here and then click submit", + :html => {:method => :post}, remote: true do |f| %> + <%= f.text_area :code, placeholder: "Write your code here and then click submit", class: "editor" %> - <%= f.hidden_field :problem_id, value: params[:id] %>
    @@ -46,7 +41,7 @@ Output response
    -
    +

    <% end %> \ No newline at end of file From a6cf63c46b5efd859178e51c516b6785cf7e782e Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Tue, 22 Apr 2014 11:52:43 +0200 Subject: [PATCH 159/526] Issue #188 adding some ajax to send arrays to controller --- .../javascripts/solutions_constraints.js | 173 +++++++++++++++++- .../solutions_constraints_controller.rb | 28 ++- .../_edit_method.html.erb | 47 +++++ .../_edit_variable.html.erb | 19 ++ .../solutions_constraints/_form.html.erb | 114 ++---------- .../views/solutions_constraints/create.js.erb | 1 - .../views/solutions_constraints/edit.html.erb | 2 +- .../views/solutions_constraints/new.html.erb | 2 +- 8 files changed, 274 insertions(+), 112 deletions(-) create mode 100644 tutor/app/views/solutions_constraints/_edit_method.html.erb create mode 100644 tutor/app/views/solutions_constraints/_edit_variable.html.erb delete mode 100644 tutor/app/views/solutions_constraints/create.js.erb diff --git a/tutor/app/assets/javascripts/solutions_constraints.js b/tutor/app/assets/javascripts/solutions_constraints.js index 24f83d18..838fddd8 100644 --- a/tutor/app/assets/javascripts/solutions_constraints.js +++ b/tutor/app/assets/javascripts/solutions_constraints.js @@ -1,3 +1,170 @@ -# 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/ +// # 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/ + +var type = new Array(); +var param_name = new Array(); + +function add_params(field) +{ + var tmp_type = document.getElementById("params_type").value; + var tmp_name = document.getElementById("params_name").value; + + if (tmp_name != "" && tmp_type != "") { + document.getElementById("params_type").style.border= ""; + document.getElementById("params_name").style.border= ""; + type[type.length] = tmp_type; + document.getElementById("params_type").value = ""; + param_name[param_name.length] = tmp_name; + document.getElementById("params_name").value = ""; + + document.getElementById("parameter").innerHTML = "

    Paramters Constraints

    "; + for (var i = 0; i < type.length; i++) { + $('#parameter').append(""); + $('#parameter').append(""); + $('#parameter').append(""); + $('#parameter').append(""); + $('#parameter').append(""); + $('#parameter').append(""); + $('#parameter').append(""); + $('#parameter').append(""); + } + $('#parameter').append("
    \"delete
    "); + }else { + if (tmp_name == "" && tmp_type == ""){ + document.getElementById("params_type").style.border= "red 1px solid"; + document.getElementById("params_name").style.border= "red 1px solid"; + }else if(tmp_name == ""){ + document.getElementById("params_type").style.border= ""; + document.getElementById("params_name").style.border= "red 1px solid"; + }else{ + document.getElementById("params_type").style.border= "red 1px solid"; + document.getElementById("params_name").style.border= ""; + } + } +} +function remove_params(field) +{ + var index = field.id.split("_")[1]; + type.splice(index,1); + param_name.splice(index,1); + document.getElementById("parameter").innerHTML = "

    Paramters Constraints

    "; + if(type.length == 0) + { + $('#parameter').append("No paramter"); + } + for (var i = 0; i < type.length; i++) { + $('#parameter').append(""); + $('#parameter').append(""); + $('#parameter').append(""); + $('#parameter').append(""); + $('#parameter').append(""); + $('#parameter').append(""); + $('#parameter').append(""); + $('#parameter').append(""); + } + $('#parameter').append("
    \"delete
    "); +} + +var var_type = new Array(); +var var_name = new Array(); + +function add_variable(field) +{ + var tmp_type = document.getElementById("variable_type").value; + var tmp_name = document.getElementById("variable_name").value; + + if (tmp_name != "" && tmp_type != "") { + document.getElementById("variable_type").style.border= ""; + document.getElementById("variable_name").style.border= ""; + var_type[var_type.length] = tmp_type; + document.getElementById("variable_type").value = ""; + var_name[var_name.length] = tmp_name; + document.getElementById("variable_name").value = ""; + + document.getElementById("variable").innerHTML = "

    Variables Constraints

    "; + for (var i = 0; i < var_type.length; i++) { + $('#variable').append(""); + $('#variable').append(""); + $('#variable').append(""); + $('#variable').append(""); + $('#variable').append(""); + $('#variable').append(""); + $('#variable').append(""); + $('#variable').append(""); + } + $('#variable').append("
    \"delete
    "); + }else { + if (tmp_name == "" && tmp_type == ""){ + document.getElementById("variable_type").style.border= "red 1px solid"; + document.getElementById("variable_name").style.border= "red 1px solid"; + }else if(tmp_name == ""){ + document.getElementById("variable_type").style.border= ""; + document.getElementById("variable_name").style.border= "red 1px solid"; + }else{ + document.getElementById("variable_type").style.border= "red 1px solid"; + document.getElementById("variable_name").style.border= ""; + } + } +} +function remove_variable(field) +{ + var index = field.id.split("_")[1]; + var_type.splice(index,1); + var_name.splice(index,1); + document.getElementById("variable").innerHTML = "

    Variables Constraints

    "; + if(var_type.length == 0) + { + $('#variable').append("No Variables"); + } + for (var i = 0; i < var_type.length; i++) { + $('#variable').append(""); + $('#variable').append(""); + $('#variable').append(""); + $('#variable').append(""); + $('#variable').append(""); + $('#variable').append(""); + $('#variable').append(""); + $('#variable').append(""); + } + $('#variable').append("
    \"delete
    "); +} + +function submitParams() +{ hash = {} + for (var i = 0; i < type.length; i++) { + hash += {params_name[i]:type[i]} + }; + method = $('#_constrain_method_return').val() + name = $('#_constrain_method_name').val() + $.ajax({ + type: "POST", + url: "/solutions_constraints", + data:{ p_type: JSON.stringify(type), + p_hash: JSON.stringify(hash), + p_name: JSON.stringify(param_name), + v_type: JSON.stringify(var_type), + v_name: JSON.stringify(var_name), + method_return: JSON.stringify(method), + method_name: JSON.stringify(name), + }, + datatype: "JSON", + success: function(){}, + error: function(){alert("failed");}, + }); +} + + +// function sendparams(){ +// alert("doog"); +// $.ajax({ +// data: { depart: type.toString(), return_date: param_name}, +// type: 'post', +// url: "/payment/create", +// }); +// } +// $('#account_settings').on('ajax:error', function(event, xhr, status) { +// // insert the failure message inside the "#account_settings" element +// $(this).append(xhr.responseText) +// $ajax:beforeSend() +// }); \ No newline at end of file diff --git a/tutor/app/controllers/solutions_constraints_controller.rb b/tutor/app/controllers/solutions_constraints_controller.rb index d15ec3d7..f3800fc9 100644 --- a/tutor/app/controllers/solutions_constraints_controller.rb +++ b/tutor/app/controllers/solutions_constraints_controller.rb @@ -6,12 +6,29 @@ def index end def create - redirect_to action: "index" + param_type = params[:p_type] + param_name = params[:p_name] + var_type = params[:v_type] + var_name = params[:v_type] + method_return = params[:method_return] + method_name = params[:method_name] + + myhash = {} + param_name.each_with_index do |k,i| + myhash[k] = param_type[i] + end + + myhash.each do |key, value| + puts(key + value) + end + + end def new - @constrain = MethodConstraint.new() - @params = MethodParameter.new() + @constrain = MethodConstraint.new + @params = MethodParameter.new + @variables = VariableConstraint.new end def show @@ -52,9 +69,4 @@ def destroy flash[:success_deletion] = "Constraints deleted." end - private - def constraint_params - params.require(:parameter).permit(:parameters, :variables) - end - end diff --git a/tutor/app/views/solutions_constraints/_edit_method.html.erb b/tutor/app/views/solutions_constraints/_edit_method.html.erb new file mode 100644 index 00000000..0351b8cb --- /dev/null +++ b/tutor/app/views/solutions_constraints/_edit_method.html.erb @@ -0,0 +1,47 @@ + + +<%= form_for :@constrain do |f| %> + + + + + + + +
    + + + + <%= fields_for :@params do |u| %> + + + + + + + + <% end %> + +
    Method Constrains<%= f.text_field :method_return, placeholder: "Return Type"%><%= f.text_field :method_name, placeholder: "Method Name" %>
    Method Parameter<%= u.text_field :params_type, placeholder: "Variable Type", id:"params_type" %><%= u.text_field :parameter, placeholder: "Variable Name", id:"params_name" %><%= image_tag "add_buttom.png", id:"params", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_params(this);"%>
    +
    +

    Paramter

    + No paramters +
    +
    + <%= f.submit "Save Changes", class: "btn btn-default", onclick:"submitParams();"%> + +<% end %> \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/_edit_variable.html.erb b/tutor/app/views/solutions_constraints/_edit_variable.html.erb new file mode 100644 index 00000000..47464e84 --- /dev/null +++ b/tutor/app/views/solutions_constraints/_edit_variable.html.erb @@ -0,0 +1,19 @@ +<%= form_for :@constrain do |f| %> + + + + + + + + + + +
    Variable Constraints<%= u.text_field :variable_name, placeholder: "Variable Type" %><%= u.text_field :variable_name, placeholder: "Variable Name" %><%= image_tag "add_buttom.png", id:"params", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_params(this);"%>
    +
    +

    Variables

    + No Variables +
    +
    + <%= f.submit "Save Changes", class: "btn btn-default"%> +<% end %> \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/_form.html.erb b/tutor/app/views/solutions_constraints/_form.html.erb index 2270cfa3..ea049415 100644 --- a/tutor/app/views/solutions_constraints/_form.html.erb +++ b/tutor/app/views/solutions_constraints/_form.html.erb @@ -1,128 +1,46 @@ - - -<%= form_for :@constrain do |f| %> +<%= form_for :@constrain, url:{action:"create"} do |f| %> - + - +
    - <%= form_for :@params do |u| %> + <%= fields_for :@params do |u| %> - + - + - + <% end %> - <%= form_for :patient do |u| %> + <%= fields_for :@variables do |u| %> - + - + - + <% end %>
    Method Constrains <%= f.text_field :parameter, placeholder: "Return Type"%><%= f.text_field :method_return, placeholder: "Return Type"%> <%= f.text_field :parameter, placeholder: "Method Name" %><%= f.text_field :method_name, placeholder: "Method Name" %>
    Method Parameter <%= u.text_field :parameaaater, placeholder: "Variable Type", id:"params_type" %><%= u.text_field :params_type, placeholder: "Variable Type", id:"params_type" %> <%= u.text_field :asd, placeholder: "Variable Name", id:"params_name" %><%= u.text_field :parameter, placeholder: "Variable Name", id:"params_name" %> <%= image_tag "add_buttom.png", id:"params", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_params(this);"%><%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_params(this);"%>
    Variable Constraints <%= u.text_field :variable_name, placeholder: "Variable Type" %><%= u.text_field :variable_type, placeholder: "Variable Type", id:"variable_type" %> <%= u.text_field :variable_name, placeholder: "Variable Name" %><%= u.text_field :variable_name, placeholder: "Variable Name", id:"variable_name" %> <%= image_submit_tag "add_buttom.png", id:"variables", style: "width:15%;height:15%;margin_top:10px;"%><%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_variable(this);"%>
    -

    Paramter

    - No paramter - +

    Paramters Constraints

    + No paramters
    - +

    Variables Constraints

    + No variables

    - <%= f.submit "Save Changes", class: "btn btn-default"%> - + <%= button_tag "Save Changes", type: "button", class: "btn btn-large btn-success", onclick:"submitParams();"%> <% end %> \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/create.js.erb b/tutor/app/views/solutions_constraints/create.js.erb deleted file mode 100644 index df2ca465..00000000 --- a/tutor/app/views/solutions_constraints/create.js.erb +++ /dev/null @@ -1 +0,0 @@ -$('body').append('<%= @comment.text %>'); \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/edit.html.erb b/tutor/app/views/solutions_constraints/edit.html.erb index cc1a9a5e..eb8f486a 100644 --- a/tutor/app/views/solutions_constraints/edit.html.erb +++ b/tutor/app/views/solutions_constraints/edit.html.erb @@ -1,3 +1,3 @@ <%= link_to "<< Back to list", :controller => 'solutions_constraints', :action => 'index' %>

    Edit Constraints

    -<%= render "form" %> \ No newline at end of file +<%= render "edit_method" %> \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/new.html.erb b/tutor/app/views/solutions_constraints/new.html.erb index b4dd62db..a0932b48 100644 --- a/tutor/app/views/solutions_constraints/new.html.erb +++ b/tutor/app/views/solutions_constraints/new.html.erb @@ -1,3 +1,3 @@ -

    New mooo

    +

    New Method/Variable Constraints

    <%= render 'form' %> \ No newline at end of file From 8341d99959a2556c6ebd4099b090d7bd8f851beb Mon Sep 17 00:00:00 2001 From: Mohab Date: Tue, 22 Apr 2014 12:33:48 +0200 Subject: [PATCH 160/526] Issue #200 Editing student model --- tutor/app/models/student.rb | 13 +++++++++++++ tutor/config/routes.rb | 1 + 2 files changed, 14 insertions(+) diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index 72116f09..a563300e 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -75,5 +75,18 @@ def getProblemsStatus end return res end + + def getClassMatesRecommendations + recommended_problems = Recommendation.where(:student_id => self.id) + recommended_problems_hash = Hash.new + recommended_problems.each do |problem| + recommended_problems_hash[problem.id] = Hash.new + recommender_name = Student.where(:id => problem.recommender_id).recommender_name + problem_title = Problem.where(:id => problem.id).title + recommended_problems_hash[problem.id]['recommender_name '] = recommender_name + recommended_problems_hash[problem.id]['ptoblem_title'] = problem.title + end + return recommended_problems_hash + end end diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index e9d7079c..9d8935e4 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -29,6 +29,7 @@ resources :solutions resources :problems resources :topics + resources :profile # Example resource route with options: # resources :products do From 6e0f5af90d230220953ff059b8d76372eb6f3826 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Tue, 22 Apr 2014 12:54:07 +0200 Subject: [PATCH 161/526] changing in the posts controller and in the views of the edit and show --- tutor/Gemfile.lock | 2 -- tutor/app/controllers/posts_controller.rb | 4 ++-- tutor/app/views/posts/edit.html.erb | 4 ++-- tutor/app/views/posts/show.html.erb | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tutor/Gemfile.lock b/tutor/Gemfile.lock index 43582f98..fa0d2aac 100644 --- a/tutor/Gemfile.lock +++ b/tutor/Gemfile.lock @@ -29,7 +29,6 @@ GEM atomic (1.1.16) bcrypt (3.1.7) builder (3.1.4) - chartkick (1.2.4) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -132,7 +131,6 @@ PLATFORMS ruby DEPENDENCIES - chartkick coffee-rails (~> 4.0.0) composite_primary_keys (~> 6.0.1) devise diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index 234d28ea..7aed2717 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -64,8 +64,8 @@ def update flash[:notice] = "Post successfully updated" redirect_to(:action => 'show' ,:id => @post.id) else - if @new_post.errors.any? - flash[:notice] = @new_post.errors.full_messages.first + if @post.errors.any? + flash[:notice] = @post.errors.full_messages.first end render :action => 'edit' end diff --git a/tutor/app/views/posts/edit.html.erb b/tutor/app/views/posts/edit.html.erb index 2b66ea55..c2d3227a 100644 --- a/tutor/app/views/posts/edit.html.erb +++ b/tutor/app/views/posts/edit.html.erb @@ -12,12 +12,12 @@ <%= form_for :post, url: {action: "update", :id => @post.id} do |f| %>

    <%= f.label "Title" %>
    - <%= f.text_field :title, autofocus: true, class:"form-control", style: "width:300px", placeholder: "Title"%> + <%= f.text_field :title, autofocus: true, class:"form-control", style: "width:300px", placeholder: "Title",:value => @post.title%>

    <%= f.label :content %>
    <%= f.text_area :content, class:"form-control", style: "margin-left:auto; - margin-right:auto;height:200px;width:500px;resize:none", placeholder: "Enter your post"%> + margin-right:auto;height:200px;width:500px;resize:none", placeholder: "Enter your post",:value => @post.content%>

    <%= f.submit "Update Post", class: "btn btn-success"%> diff --git a/tutor/app/views/posts/show.html.erb b/tutor/app/views/posts/show.html.erb index 0f46c1c5..085d8497 100644 --- a/tutor/app/views/posts/show.html.erb +++ b/tutor/app/views/posts/show.html.erb @@ -22,7 +22,7 @@ <% end %>

    <% if @post.owner_id == @userID %> - <%= button_to "Edit Post", {:action => 'edit', :controller => 'posts'}, { + <%= link_to "Edit Post", {:action => 'edit', :controller => 'posts'}, { class: 'btn btn-primary',:id => @post.id} %> <% end %>
    \ No newline at end of file From f29620efda5ff825e85320403c201e6e548b4864 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Tue, 22 Apr 2014 12:59:19 +0200 Subject: [PATCH 162/526] fixed giving posts to users where i do not need to give the post the id --- tutor/app/controllers/posts_controller.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index 138158dc..62b00363 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -1,4 +1,4 @@ -class PostsController < ApplicationController + class PostsController < ApplicationController # [Add Post - Story 1.13] # Description: This action takes the passed discussion board id and assigns @@ -40,16 +40,10 @@ def create @new_post = Post.new(post_params) @new_post.views_count = 0 if lecturer_signed_in? - @new_post.owner_id = current_lecturer.id - @new_post.owner_type = "lecturer" current_lecturer.posts << @new_post elsif teaching_assistant_signed_in? - @new_post.owner_id = current_teaching_assistant.id - @new_post.owner_type = "teaching assistant" - current_teaching_assistant << @new_post + current_teaching_assistant.posts << @new_post elsif student_signed_in? - @new_post.owner_id = current_student.id - @new_post.owner_type = "student" current_student.posts << @new_post end @discussion_board = DiscussionBoard.find(discussion_board_params[:discussion_board_id]) From 155338641ac49ddb6da1bb18ef9f52a6be693959 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Tue, 22 Apr 2014 13:01:36 +0200 Subject: [PATCH 163/526] removed commented line --- tutor/app/controllers/posts_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index 62b00363..c1d14de8 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -55,7 +55,6 @@ def create if @new_post.errors.any? flash[:notice] = @new_post.errors.full_messages.first end - #redirect_to :controller => 'posts', :action => 'new',:discussion_board_id => @discussion_board.id render :action => 'new' end end From 875aae3ebfcc39eeb401650b51300f02391a9243 Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Tue, 22 Apr 2014 13:03:07 +0200 Subject: [PATCH 164/526] Issue #188 commiting to go database --- .../javascripts/solutions_constraints.js | 41 ++++++++---------- .../solutions_constraints_controller.rb | 17 +------- tutor/db/development.sqlite3 | Bin 196608 -> 200704 bytes tutor/db/schema.rb | 18 ++++++-- 4 files changed, 32 insertions(+), 44 deletions(-) diff --git a/tutor/app/assets/javascripts/solutions_constraints.js b/tutor/app/assets/javascripts/solutions_constraints.js index 838fddd8..9f5db2d6 100644 --- a/tutor/app/assets/javascripts/solutions_constraints.js +++ b/tutor/app/assets/javascripts/solutions_constraints.js @@ -43,6 +43,7 @@ function add_params(field) } } } + function remove_params(field) { var index = field.id.split("_")[1]; @@ -107,6 +108,7 @@ function add_variable(field) } } } + function remove_variable(field) { var index = field.id.split("_")[1]; @@ -131,40 +133,31 @@ function remove_variable(field) } function submitParams() -{ hash = {} +{ var hash_p = [] + var hash_v = [] + for (var i = 0; i < type.length; i++) { + hash_p.push({ + type: type[i] , + name: param_name[i] + }); + }; for (var i = 0; i < type.length; i++) { - hash += {params_name[i]:type[i]} + hash_v.push({ + type: var_type[i] , + name: var_name[i] + }); }; method = $('#_constrain_method_return').val() name = $('#_constrain_method_name').val() $.ajax({ type: "POST", url: "/solutions_constraints", - data:{ p_type: JSON.stringify(type), - p_hash: JSON.stringify(hash), - p_name: JSON.stringify(param_name), - v_type: JSON.stringify(var_type), - v_name: JSON.stringify(var_name), + data:{ parameter_constraint: JSON.stringify(hash_p), + variable_constraint: JSON.stringify(hash_v), method_return: JSON.stringify(method), method_name: JSON.stringify(name), }, - datatype: "JSON", success: function(){}, error: function(){alert("failed");}, }); -} - - -// function sendparams(){ -// alert("doog"); -// $.ajax({ -// data: { depart: type.toString(), return_date: param_name}, -// type: 'post', -// url: "/payment/create", -// }); -// } -// $('#account_settings').on('ajax:error', function(event, xhr, status) { -// // insert the failure message inside the "#account_settings" element -// $(this).append(xhr.responseText) -// $ajax:beforeSend() -// }); \ No newline at end of file +} \ No newline at end of file diff --git a/tutor/app/controllers/solutions_constraints_controller.rb b/tutor/app/controllers/solutions_constraints_controller.rb index f3800fc9..319bda4d 100644 --- a/tutor/app/controllers/solutions_constraints_controller.rb +++ b/tutor/app/controllers/solutions_constraints_controller.rb @@ -6,22 +6,7 @@ def index end def create - param_type = params[:p_type] - param_name = params[:p_name] - var_type = params[:v_type] - var_name = params[:v_type] - method_return = params[:method_return] - method_name = params[:method_name] - - myhash = {} - param_name.each_with_index do |k,i| - myhash[k] = param_type[i] - end - - myhash.each do |key, value| - puts(key + value) - end - + @method_cons = params[:paramter_constraint] end diff --git a/tutor/db/development.sqlite3 b/tutor/db/development.sqlite3 index 16f9168c6518c0aa49ad1fcc1826ba2aa4fd9b2e..5a2a8685fe775231f963209454ea5e30f6e0be6e 100644 GIT binary patch delta 5239 zcmbVQYitzP6`s2bUe@;R*f?NH;$jD@1%u7pJ9A%d6Yu(k9}9kijasl_*RaOkHTD`m z6v;*<%AYi87^x#wYA8yB`lFa)S9aAZA#J5d=|hRsR%)dR+CNoWsfDUS^dW`bomtS# z?5r$xWn1!o=broBbG~!#V`Zgupz4($=&?JNn2 zzcry%Jx~_)g;v-5%HpA&Wi`HoNP(K7Ap{liLF*q>wfg)up*QqEwXl0b*tLc#cKQzj zr(MnZjrvpN%cvSEjR-bk-ar%;L6)_uSG0PRk3=$K4d>ERwP>ssDz!)ZW2Y9DE~h&B z6G!7}Y=%zK#bXVZdKX6~c)GJ;3Y{EA3zxbsjl~v|OCv|(BWKgYC$Ch1JyONfB}SwA zQd6a!16Dc3suu?ffldw!$qU_=PPI+9_jaL%!B~{1;ZPzmJ2-uu&Mys(4<6}A!sAn2 z<5T@hsrlB+ZSxm9P9?K(tO$Q3$&che$-kBFu9rm~RUNV|7hxj8;3AAv!$$96rg|*g#wB+>w+vw!o9^BdELc*xacj zsoC-L)I@t??sBrPtAD63hRzT7cK4pRm|R$F&_~Z4+Aq=-+nR6E14ROWPuvinccWm#|%j8d0%=yzFyGWHvJw zPoy%og3w}pxFs>kV@H%?>P4oJt*SnC*!VUg$oXO14aN z#yfhhRD-=zl~ANC=@*u3?Hp9j81bwH3xOUSjvwPo9ckQfbfCEhw#Ud+iuI24^mNSk zPc~1rcCqQ^c5+djrz5FzGv|j;n=&0=Xvr1?kl&NU&w9zq&*VCr+908b60bm*$oi8v z_c#;DnL^xZMvaQnfK-htP;b7jITFb=%H4_2*(($y{l<08&POCmf$pGK_K<6E{mJ!A z*x_Fzn&@lJ#9Q{F=%}i{z52X8=tOiM;^t!s(L`GPB_djt;#Z1Bd(*QSx9^-SRP$!F zA!77tNlF6KOQ+6m({fwPiN+CD^_AO0&Xr`p^!9XomE8wElQ1MVmUqNIoVA-g@(xC*%|yQaOESLFTLJ?=2ah^TJ%rWlxs z=<$1vTiRRh#k`85e{`?OX|HhPO@|BiNLTMW`Dhg86-bW0rV^?f_g{AS*HD2nh74jw zUHijN9A(eU?ZGoVP!;0W|MquiZ!3&*g}KvZ@=;*6Yjr$84mt(RArc*g>F+*Joc0i@ z?pm~#EBq5}?cs)#KGAT2E~=;sqxv5|tvX<<8%9NR-1M#VQceHdlg~QHco~~y5JU(w zJ?*v^&CKoGvRAmqRQ(4}9LFa{nAkA9Vvm$;Px?N1(;;PwIcDxk&ILy!7#cqe0b)-U zC75#e0CTkh87(sIg+U!7eiwtM2Khs+xe!7c9o=q@Cb+<8RjAG7*BT8eQkn7lFrf9e zyik%oPTUn@|6A`X``zY0%7M?n-n;!%|K{ULAn!Qv zn&f-U|LV41Z2wi!UjzRM9xi^h3P^$z?q~B+(Hi5kii5XpS%2}yY$j})<8)AI72^_SmkSQXCo+l#{*?iIj zlzk3{2vQ*vuNh3F&u82|175(M%4RUTYkLkh5#!bwaKJ7hCZ@`(Dr-F^vM~zoJ9-Xf zFdIWBy_~oe%(zjU2A{XjK$$pjxqH4jgM}Dh${TaZz?e5B6Uo-wa<<-&wZi%mvbGg*0$ox7My&rc@e=Mz)nLNV+9AGY+jMF-oe z2cylgw(1w{u)Y%HMN^5{*|GD+==0z?V`nX>Fy0>W?bh%6>Vq|h1C>=(;OZ_T+~@mw z$y`cY-lr!MnM8c^$9=vvu(^BCcjZvh)<(E!FXAP^sR1(%7ViD{^D_U*U~#CX7N4L#v_5P+jStOK*zDimRo|kx)E2I;~DQrsJKuh#Nl6qksVumPzkZ;d^!6fWUWJ7%Q=k%wswIO>@GXY zgLq2eFjBO&2L(T^r{!mlPdOJ*97`hNwvy9Cp-3Q6`tA;CdC;)9N=L+1WeZgy@vy?s zvQz#!7YbHM#Q)4iK@u9_?hB0NLCqdpBEDxH3P~G{A}wzt%DE7a4@v|)b5V!{O%$XOQk-vX;dMqwhBG7j-?s) zt{l~WlIJ_;-0z%8wg5cjQPdkq59iz_G=Z!)#__ z!WuAZunUoQbFOQb%xIcDl8b_p_6|y+UQv7q9d!oN2i*+JC;gb3vY&J3g8{ z-_txdHDrwp9Kns8Os0BMjp=JU(R0SmP3EbTyKt~N#DNk_h?YYhAz=>V>6VseJTc*% z=$LKkz1)BDa@%0b=uBT~qV4GUDJrvlvjZnCkde!0aZlg;#fxXp&No_qdUht>HOxom zU(7$4_gA(zJ*wFk*sjg7Lp6yI7Gso3=HgS&X0Eml^|YVC3xmgwkBx~LYpCnO#i5Sz z6PE`%T6){()j;}us&&SmooUZb9B~fyjHk{_TZJ3*V-iP-;)r|a)GPY~>?k1=YwWT0 zDdLh-pX1}HnZXOG_8~qyes%m}OFEP7ZJZgE<3qEPjS~}0O?0+jIypfO_b;?|4_O0g zGPiIp?GB&b_gNBwt&J4Axm|I%J&L@T2L4Pm!jX?CiPG$!wq@?8A`IUO6~=tbd`SMZ1g|P^4+N7jkt$4pd5}936)Z zglIVQw$0(pLfRQ=J4UQ?=O)j*iZ7+DD+3Ex54Su0vz_VL=7GN1=DGRvGn3Op?VVkN zN4qnALm=~Q1AbO27k^{c2h>IcC|;|!JhJlS`g7qzDqAs4A&F&!JOy)`msqHfQc7JR z!QK{~P0aes;7I_5dz7piD?`STmQy^LQ-u=1|HLaC@4k|@Cr_1Xq z)Cj_M9I2t^3kha|d-lC>c$+JwS3n+dm*0CaM8}t-W;+lbo=UO&{)h3Py`+K@t*(h= zM9J?wP+@bW?1G&5yOq>O+;a~Od=`6R5vhc9+;<-w4BJC$G~4y<9fGk-A3nv0NsM)3 zCX#T>T<>8r9N)H;hCjrIs!+N7r(cEI9-eWfX-%*v{u%E6?e8QwR;1)iZ;y!$I&J;P z4$&!UPN0sMxIg*`hwUK;TJc~du%OHTSPj$X+@bpPC|f$z{qrX^djowVg_2aWT_~?m z?iZhYAw;H#F-Q$d#)&)iv^^7CD>WN)Xbbn}PeRuxDX`;crimXP4psRxbUh?xhbwrh z)dIGmR^Bh-NCb=J2pC_QGX`6L43~Ki5~yB^Xko;>fz}mtVPl2KaB1FK@FL!nI@%^B z#Bm(#{V{=@hCp2$L732{j$nsNc{<|VGEu!ZZla1{i5%{K7jA%97=+E3w`3yG5?qKg z3PZi%z5)&qhZ6sYuRtFg=C{l!`Z#f~s;uHs>~U;QS#8Nb;f>%!wDx#AibPkAm6b%- z9#tR*-~tE+po+2RY|HcaX0a{ITn8>ant-VQpP1CbK}My@4x+# z-D^#?=&Q(UegPf!8ec-~ZfEJg-R_c4Rw|<{Xzh1(Xr!cEJQJ%X1ifDEiI>suT^uX( za6LL%&UePDIY+O@z3cVp2i~o{=$mWr>_gv;u42?+1~V!#qg+!0PKc z6GSN8pzxi2#QVubCIFnSmoEzp`u>L)cJaI^9%rqD~l6&x6^L^FD! znevGDl>!F>BV3mNNBW3&=V^zcl(1C9QLEEvXGjDNhM})tA&>ZNmGj#w_f%V90TH## z@`$&TLn5?yOoi^4g1zUF)kReLekm$3qF20aosk#HA|FKHU$<-f2Nl=8wm()~Q-i+I z;l0rn`R&?k-I1HfJJpE3zxHfzw~f%cUO4ma&Y+d#gAVg@QNPo*L{@)B-RSTkin zGz}MKok%>}XmL2;>;t+i5bo8K6iBh=k#yO(C=4O*I+W k^e;kyz{OB|+c*NB9Kb7Q5^V-3Mu5O)3|az|!0Xcg0P0_9761SM diff --git a/tutor/db/schema.rb b/tutor/db/schema.rb index d98ab000..9fb5eef9 100644 --- a/tutor/db/schema.rb +++ b/tutor/db/schema.rb @@ -11,7 +11,15 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140419085448) do +ActiveRecord::Schema.define(version: 20140422100002) do + + create_table "acknowledgements", force: true do |t| + t.string "message" + t.integer "course_id" + t.integer "student_id" + t.datetime "created_at" + t.datetime "updated_at" + end create_table "admins", force: true do |t| t.string "name" @@ -25,8 +33,9 @@ create_table "attempts", force: true do |t| t.integer "student_id" t.integer "problem_id" - t.boolean "failure", default: false - t.boolean "success", default: false + t.boolean "failure", default: false + t.boolean "success", default: false + t.boolean "uncompleted", default: false t.datetime "created_at" t.datetime "updated_at" end @@ -134,6 +143,7 @@ t.string "method_name" t.string "method_return" t.integer "model_answer_id" + t.integer "method_constraint_id" t.integer "owner_id" t.string "owner_type" t.datetime "created_at" @@ -324,7 +334,7 @@ create_table "variable_constraints", force: true do |t| t.string "variable_name" - t.string "type" + t.string "variable_type" t.integer "model_answer_id" t.integer "owner_id" t.string "owner_type" From 4e370102a3742f20b8cc90e5dd0cb8d74e68ca4c Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Tue, 22 Apr 2014 13:25:17 +0200 Subject: [PATCH 165/526] added post route for update --- tutor/app/views/posts/edit.html.erb | 2 +- tutor/config/routes.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tutor/app/views/posts/edit.html.erb b/tutor/app/views/posts/edit.html.erb index c2d3227a..947070d5 100644 --- a/tutor/app/views/posts/edit.html.erb +++ b/tutor/app/views/posts/edit.html.erb @@ -20,7 +20,7 @@ margin-right:auto;height:200px;width:500px;resize:none", placeholder: "Enter your post",:value => @post.content%>

    - <%= f.submit "Update Post", class: "btn btn-success"%> + <%= f.submit "Update Post", class: "btn btn-success" %>

    <% end %>
    \ No newline at end of file diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index 9d44a4c7..866b78f8 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -13,6 +13,7 @@ post 'courses/new' => 'courses#new' get 'courses/sign_up' post 'posts/new' => 'posts#new' + post '/posts/:id' => 'posts#update' # You can have the root of your site routed with "root" root 'site#index' From d4ebec049bca164f79e071149dd7827f76d5facd Mon Sep 17 00:00:00 2001 From: Mussab ElDash Date: Tue, 22 Apr 2014 13:44:32 +0200 Subject: [PATCH 166/526] Update solutions.js.coffee --- tutor/app/assets/javascripts/solutions.js.coffee | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tutor/app/assets/javascripts/solutions.js.coffee b/tutor/app/assets/javascripts/solutions.js.coffee index 09ab84de..92f994d5 100644 --- a/tutor/app/assets/javascripts/solutions.js.coffee +++ b/tutor/app/assets/javascripts/solutions.js.coffee @@ -34,10 +34,20 @@ IndexNumber = 0 return return +# [Debugger: Debug - Story 3.6] +# Starts the Spinner +# Parameters: noe +# Returns: none +# Author: Mussab ElDash @start_spin = -> $('#spinner').attr "class" , "spinner" return +# [Debugger: Debug - Story 3.6] +# Stops the Spinner +# Parameters: noe +# Returns: none +# Author: Mussab ElDash @stop_spin = -> $('#spinner').attr "class" , "" return From 2f387a205862cea96d1efe7f93c57dc2a73ba538 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Tue, 22 Apr 2014 13:47:34 +0200 Subject: [PATCH 167/526] Adding documentation and indentation for my methods and views --- tutor/app/controllers/posts_controller.rb | 18 ++++++++++++ tutor/app/views/posts/edit.html.erb | 2 +- tutor/app/views/posts/show.html.erb | 36 +++++++++++------------ 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index 7aed2717..3c52e2af 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -18,6 +18,14 @@ def show @replies = @post.replies.order("created_at desc") end + # [Edit Post - Story 1.18] + # Description: This action takes the passed post id + # to be passed to the Edit form. + # Parameters: + # params[:id]: The post id + # Returns: + # none + # Author: Ahmed Atef def edit @post = Post.find(params[:id]) end @@ -58,6 +66,16 @@ def create end end + # [Edit Post - Story 1.18] + # Description: This action takes the passed parameters from + # the edit post form, updates the passed post parameters.If the + # update fails the user is redirected to the form + # Parameters: + # topic_params[]: A list that has all fields entered by the user to in the + # Edit_post_form + # Returns: + # flash[:notice]: A message indicating the success or failure of the creation + # Author: Ahmed Atef def update @post = Post.find(params[:id]) if @post.update_attributes(post_params) diff --git a/tutor/app/views/posts/edit.html.erb b/tutor/app/views/posts/edit.html.erb index 947070d5..435a258e 100644 --- a/tutor/app/views/posts/edit.html.erb +++ b/tutor/app/views/posts/edit.html.erb @@ -1,4 +1,4 @@ - diff --git a/tutor/app/views/posts/show.html.erb b/tutor/app/views/posts/show.html.erb index 085d8497..7172e590 100644 --- a/tutor/app/views/posts/show.html.erb +++ b/tutor/app/views/posts/show.html.erb @@ -1,28 +1,28 @@
    <% if current_lecturer %> <% @userID = current_lecturer.id %> - <% end %> + <% end %> <% if current_student %> <% @userID = current_student.id %> <% end %> <%if current_teaching_assistant %> <% @userID = current_teaching_assistant.id %> <%end%> -
    -

    <%=@post.title%>

    - <% unless @replies.blank? %> - <% @replies.each do |reply| %> -
    - <%= reply.content %>
    -
    -
    - <% end %> - <% else %> - No Replies in this post yet . - <% end %> -
    - <% if @post.owner_id == @userID %> - <%= link_to "Edit Post", {:action => 'edit', :controller => 'posts'}, { - class: 'btn btn-primary',:id => @post.id} %> -<% end %> +
    +

    <%=@post.title%>

    + <% unless @replies.blank? %> + <% @replies.each do |reply| %> +
    + <%= reply.content %>
    +
    +
    + <% end %> + <% else %> + No Replies in this post yet . + <% end %> +
    + <% if @post.owner_id == @userID %> + <%= link_to "Edit Post", {:action => 'edit', :controller => 'posts'}, { + class: 'btn btn-primary',:id => @post.id} %> + <% end %>
    \ No newline at end of file From 3d71a3570e8035a11629084cc5c6d2e94d074eaa Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Tue, 22 Apr 2014 13:52:20 +0200 Subject: [PATCH 168/526] Slight changes to the view --- .../javascripts/teaching_assistants.js.coffee | 67 ++++++++++++++++++- .../teaching_assistants_controller.rb | 4 +- tutor/app/models/teaching_assistant.rb | 2 +- tutor/app/views/courses/edit.html.erb | 4 ++ .../views/teaching_assistants/new.html.erb | 13 ++-- 5 files changed, 80 insertions(+), 10 deletions(-) diff --git a/tutor/app/assets/javascripts/teaching_assistants.js.coffee b/tutor/app/assets/javascripts/teaching_assistants.js.coffee index 24f83d18..fedf2dad 100644 --- a/tutor/app/assets/javascripts/teaching_assistants.js.coffee +++ b/tutor/app/assets/javascripts/teaching_assistants.js.coffee @@ -1,3 +1,64 @@ -# 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/ +// Semicolon (;) to ensure closing of earlier scripting +// Encapsulation +// $ is assigned to jQuery + +function showdialog(problem_id, recommender_id){ + $.ajax({ + type: "GET", + url: '/tracks/show_classmates/' + problem_id, + datatype: 'json', + success: function(json){ + fill(json, problem_id, recommender_id)} + }); +} + +function fill(data, problem_id, recommender_id){ + elem = $('#container'); + elem.html(""); + if(Object.keys(data).length == 0){ + elem.html("
    No classmates to recommend this problem to
    "); + $('.classmates_list').bPopup(); + return; + } + elem.html("

    Recommend this problem to

    ") + elem.append("
      "); + $.each(data, function (i , datum){ + datum = data[i]; + temp = "
    • " + datum + + "" + + "
    • " + elem.append(temp); + }); + elem.append("
    "); + $('.classmates_list').bPopup(); +} + +function recommend(problem_id, recommender_id, student_id){ + + $.ajax({ + type: "POST", + url: '/tracks/insert_recommendation/', + data: { p_id : problem_id, + r_id : recommender_id, + s_id : student_id + } + }); + showdialog(problem_id, recommender_id); + +} +// ; +// (function ($) { +// // DOM Ready +// $(function () { +// // Binding a click event +// // From jQuery v.1.7.0 use .on() instead of .bind() +// $('.recommend').bind('click', function (e) { +// e.preventDefault(); + +// $('.classmates_list').bPopup(); +// }); +// }); +// })(jQuery); diff --git a/tutor/app/controllers/teaching_assistants_controller.rb b/tutor/app/controllers/teaching_assistants_controller.rb index 1408558f..4a8eab61 100644 --- a/tutor/app/controllers/teaching_assistants_controller.rb +++ b/tutor/app/controllers/teaching_assistants_controller.rb @@ -1,7 +1,6 @@ class TeachingAssistantsController < ApplicationController def new - @course = Course.find_by_id(params[:course_id]) end def create @@ -13,7 +12,8 @@ def create flash[:notice]='TA added!' redirect_to :action => 'index' rescue - flash[:notice]='TA is already added to the course' + flash[:notice]='Error! TA is probably already added to the course. + That or something went terribly wrong on our side. Either way lamo2a5za.' redirect_to :action => 'new' end diff --git a/tutor/app/models/teaching_assistant.rb b/tutor/app/models/teaching_assistant.rb index 7b8fb18c..403b324a 100644 --- a/tutor/app/models/teaching_assistant.rb +++ b/tutor/app/models/teaching_assistant.rb @@ -5,7 +5,7 @@ class TeachingAssistant < ActiveRecord::Base :recoverable, :rememberable, :trackable, :validatable #Validations - validates :id, uniqueness: true + #Relations diff --git a/tutor/app/views/courses/edit.html.erb b/tutor/app/views/courses/edit.html.erb index d2f8c6a3..d0ff2964 100644 --- a/tutor/app/views/courses/edit.html.erb +++ b/tutor/app/views/courses/edit.html.erb @@ -20,6 +20,10 @@ :course_id => @course.id}, class: "btn btn-success" , style: "float: left; margin-left: 15px", :method => :get%> + +
    <%= button_to "Acknowledge a student", {:controller => 'teaching_assistants', :action => 'new', + :course_id => @course.id}, class: "btn btn-success" , style: "float: left; margin-left: 15px", :method => :get%> +
    <% if @discussionBoard.activated == true %> diff --git a/tutor/app/views/teaching_assistants/new.html.erb b/tutor/app/views/teaching_assistants/new.html.erb index 7995dcc7..a3d91687 100644 --- a/tutor/app/views/teaching_assistants/new.html.erb +++ b/tutor/app/views/teaching_assistants/new.html.erb @@ -1,16 +1,21 @@

    Add a Teaching Assistant


    <% if flash[:notice] -%> -
    <%= flash[:notice] %>
    +
    <%= flash[:notice] %>
    <% end %>
    <%= form_for :teaching_assistant, url: {action: "create"} do |f| %> -

    +

    <%= select("teaching_assistant", "id", TeachingAssistant.find(:all).collect {|p| [p.name ,p.id ] }, {:prompt => 'Select'}) %>

    - - +

    + <%= select("teaching_assistant", "id", current_lecturer.worked_with.find(:all).collect {|p| [p.name ,p.id ] }, {:prompt => 'Select'}) %> +

    +

    + + Only show people I've worked with
    +

    <%= f.submit "Add TA", class: "btn btn-success"%>

    From aae2b2dcf98d06a0b2e3d33cd3e77b45f707b6b2 Mon Sep 17 00:00:00 2001 From: metawaa Date: Tue, 22 Apr 2014 14:32:01 +0200 Subject: [PATCH 169/526] Fixing the end bug --- tutor/app/controllers/courses_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutor/app/controllers/courses_controller.rb b/tutor/app/controllers/courses_controller.rb index bd2b7b7e..0cdc57fb 100644 --- a/tutor/app/controllers/courses_controller.rb +++ b/tutor/app/controllers/courses_controller.rb @@ -154,12 +154,12 @@ def update if @course.update(course_params) render 'show' else - render 'edit' - end - end + render 'edit' + end end private def course_params params.require(:course).permit(:name,:code,:year,:semester,:description) - end \ No newline at end of file + end +end From 7296d1ef5961bbc78670ab9df24dceecc0f55372 Mon Sep 17 00:00:00 2001 From: metawaa Date: Tue, 22 Apr 2014 14:34:27 +0200 Subject: [PATCH 170/526] Fixing the end bug --- tutor/app/controllers/courses_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tutor/app/controllers/courses_controller.rb b/tutor/app/controllers/courses_controller.rb index 0cdc57fb..e3dd3c11 100644 --- a/tutor/app/controllers/courses_controller.rb +++ b/tutor/app/controllers/courses_controller.rb @@ -153,9 +153,9 @@ def update @course = Course.find_by_id(params[:id]) if @course.update(course_params) render 'show' - else - render 'edit' - end + else + render 'edit' + end end private From cd4c115c411aac1a7be86d7d1324b48b3b7f6a93 Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Tue, 22 Apr 2014 14:39:14 +0200 Subject: [PATCH 171/526] Issue #188 part of the saving to db works --- .../javascripts/solutions_constraints.js | 25 +++++++++++++---- .../solutions_constraints_controller.rb | 28 +++++++++++++------ 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/tutor/app/assets/javascripts/solutions_constraints.js b/tutor/app/assets/javascripts/solutions_constraints.js index 0a04af9f..b8b072c7 100644 --- a/tutor/app/assets/javascripts/solutions_constraints.js +++ b/tutor/app/assets/javascripts/solutions_constraints.js @@ -152,18 +152,31 @@ function submitParams() $.ajax({ type: "POST", url: "/solutions_constraints", - data:{ parameter_constraint: JSON.stringify(hash_p), - variable_constraint: JSON.stringify(hash_v), - method_return: JSON.stringify(method), - method_name: JSON.stringify(name) + data:{ parameter_constraint: hash_p, + variable_constraint: hash_v, + method_return: method, + method_name: name }, success: function(data){ - alert("Data have been Added successfully"); - window.location = window.location + if (data) { + alert("Data have been Added successfully"); + window.location = window.location + }else{ + alert("Data messigin/incorrect !"); + validate(method,name); + } }, datatype: "JSON", error: function(){ alert("failed"); } }); +} + +function validate(method, name) +{ + if ( (method == "" || name == "") && type.length > 0) + { + + }; } \ No newline at end of file diff --git a/tutor/app/controllers/solutions_constraints_controller.rb b/tutor/app/controllers/solutions_constraints_controller.rb index b3d7051d..ae97f2f5 100644 --- a/tutor/app/controllers/solutions_constraints_controller.rb +++ b/tutor/app/controllers/solutions_constraints_controller.rb @@ -6,18 +6,28 @@ def index end def create - @method_cons = params[:parameter_constraint] + method_cons = params[:parameter_constraint] @var_cons = params[:variable_constraint] - - @method = params[:method_name] - @method_returned = params[:method_return] - @constarint = MethodConstraint.new - @Constraint.method_name = @method - @Constraint.method_return = @method_returned - @Constraint.save + method = params[:method_name] + method_returned = params[:method_return] - redirect_to action:"index" + unless method == "" + @constarint = MethodConstraint.new + @constarint.method_name = method + @constarint.method_return = @method_returned + + unless method_cons.blank? + method_cons.each do |cons| + @parameters = MethodParameter.new + @parameters.parameter = method_cons[:cons][:name] + @parameters.params_type = method_cons[:cons][:type] + # @constrain.parameters << @parameters + @parameters.save + end + end + @constarint.save + end end def new From 45a2d13476bd33a7ce7c5ac286f03c3620a092b1 Mon Sep 17 00:00:00 2001 From: Khaled Date: Tue, 22 Apr 2014 15:19:01 +0200 Subject: [PATCH 172/526] Issue #193 Fixed a number of bugs and Followed conventions --- tutor/app/models/debugger.rb | 143 ++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 71 deletions(-) diff --git a/tutor/app/models/debugger.rb b/tutor/app/models/debugger.rb index 3a23e936..80ee7d4c 100644 --- a/tutor/app/models/debugger.rb +++ b/tutor/app/models/debugger.rb @@ -1,13 +1,8 @@ require "open3" class Debugger < ActiveRecord::Base - #Validations - - #Relations - - #Scoops - #Methods + # [Debugger: Debug - Story 3.6] # Gets the output from the output stream of the debugger # until the passed regex is encountered @@ -168,37 +163,41 @@ def self.change_class_name(student_id, problem_id, code) end # [Debugger: View Variables - Story 3.7] - # Fetches the variables found in the class and returns - # a list of all variables in the class with their - # associated values - # Parameters: None + # Takes a line containing an object assignment and extracts + # the object name + # Parameters: + # variable: A string containing an object assignment # Returns: - # An array. It contains the list of variables and their values + # A string. It contains the object name # Author: Khaled Helmy - def get_variables - method_arguments = [] - local_variables = [] - class_variables = get_class_variables - flag = 0 - input "locals" - output_buffer = buffer_until_complete - output_buffer.each_line do |line| - if line == "Method arguments:" - flag = 1 - next - elsif line == "Local variables:" - flag = 2 - next - end - if flag != 0 - variable_value = get_value line - if flag == 1 - method_arguments = method_arguments + variable_value - else - local_variables = local_variables + variable_value + def get_name variable + name = variable.split(" = ").first + return name + end + + # [Debugger: View Variables - Story 3.7] + # Takes an object and evaluates its value + # Parameters: + # variable: a string containing an instance object + # Returns: + # An array. It contains the values inside an object + # Author: Khaled Helmy + def get_value variable + result = [] + if variable.match("instance") + variable_name = get_name variable + input "dump " + variable_name + output_buffer1 = buffer_until_complete.split("main").first + input "print " + variable_name + output_buffer2 = buffer_until_complete.split("main").first + result << output_buffer1 + if output_buffer1 != output_buffer2 + result << output_buffer2 end + else + result << variable end - return method_arguments + local_variables + class_variables + return result end # [Debugger: View Variables - Story 3.7] @@ -211,22 +210,23 @@ def get_variables # Author: Khaled Helmy def get_class_variables result = [] - input "print this.getClass().getName()" flag = 0 + input "print this.getClass().getName()" output_buffer = buffer_until_complete output_buffer.each_line do |line| if flag == 1 - class_name = output_buffer.split(" = ").last - input "fields " + class_name + class_name = output_buffer.split(" = ").last.split("main").first + class_name = class_name[1..(class_name.size-3)] + input "fields " << class_name fields_list = buffer_until_complete - fields_list.each_line do |line| - if line.match("fields list") + fields_list.each_line do |field| + if field.match("fields list") or field.match("main") next else - field_name = line.split(" ").last + field_name = field.split(" ").last input "print this." + field_name field_result = buffer_until_complete - field_result = field_result.split(".").last + field_result = field_result.split(".").last.split("main").first result << field_result end end @@ -235,46 +235,47 @@ def get_class_variables break else flag = 1 + end end end return result end # [Debugger: View Variables - Story 3.7] - # Takes an object and evaluates its value - # Parameters: - # variable: a string containing an instance object + # Fetches the variables found in the class and returns + # a list of all variables in the class with their + # associated values + # Parameters: None # Returns: - # An array. It contains the values inside an object + # An array. It contains the list of variables and their values # Author: Khaled Helmy - def get_value variable - result = [] - if variable.match("instance") - variable_name = get_name variable - input "dump " + variable_name - output_buffer1 = buffer_until_complete - input "print " + variable_name - output_buffer2 = buffer_until_complete - result << output_buffer1 - if output_buffer1 != output_buffer2 - result << output_buffer2 - else - result << variable + def get_variables + method_arguments = [] + local_variables = [] + class_variables = get_class_variables + flag = 0 + input "locals" + output_buffer = buffer_until_complete + output_buffer.each_line do |line| + if line.match("Method arguments:") + flag = 1 + next + elsif line.match("Local variables:") + flag = 2 + next + elsif line.match("main") + break + end + if flag != 0 + variable_value = get_value line + if flag == 1 + method_arguments = method_arguments + variable_value + else + local_variables = local_variables + variable_value + end + end end - return result - end - - # [Debugger: View Variables - Story 3.7] - # Takes a line containing an object assignment and extracts - # the object name - # Parameters: - # variable: A string containing an object assignment - # Returns: - # A string. It contains the object name - # Author: Khaled Helmy - def get_name variable - name = variable.split(" = ").first - return name + return method_arguments + local_variables + class_variables end end From b02614dfa6150a47a2b50e7ad653fb533c9c47f4 Mon Sep 17 00:00:00 2001 From: Ahmed ELAssuty Date: Tue, 22 Apr 2014 15:20:26 +0200 Subject: [PATCH 173/526] Issue #223 add elasticsearch --- tutor/Gemfile | 3 +++ tutor/app/assets/stylesheets/application.css | 5 +---- tutor/app/controllers/utilities_controller.rb | 10 ++++++---- tutor/app/models/post.rb | 6 +++++- tutor/app/models/topic.rb | 6 +++++- tutor/app/views/layouts/_signed_in_header.html.erb | 12 ++++++++---- tutor/app/views/layouts/application.html.erb | 2 +- tutor/config/routes.rb | 3 ++- 8 files changed, 31 insertions(+), 16 deletions(-) diff --git a/tutor/Gemfile b/tutor/Gemfile index 7382b0e9..cda6686b 100644 --- a/tutor/Gemfile +++ b/tutor/Gemfile @@ -51,3 +51,6 @@ gem 'foreman' # Use composite primary keys in models gem 'composite_primary_keys', '~> 6.0.1' + +#search +gem 'tire' diff --git a/tutor/app/assets/stylesheets/application.css b/tutor/app/assets/stylesheets/application.css index f2a5e126..5e38f589 100644 --- a/tutor/app/assets/stylesheets/application.css +++ b/tutor/app/assets/stylesheets/application.css @@ -33,11 +33,8 @@ } .footer { - height:20px; - width:96%; + width:100%; border-radius: 2px; - margin-left:2%; - margin-right:2%; } .auto-height { diff --git a/tutor/app/controllers/utilities_controller.rb b/tutor/app/controllers/utilities_controller.rb index 4e01adc0..53ea27e4 100644 --- a/tutor/app/controllers/utilities_controller.rb +++ b/tutor/app/controllers/utilities_controller.rb @@ -6,10 +6,10 @@ class UtilitiesController < ApplicationController # Returns: A hashes with search results according to the keyword # Author: Ahmed Elassuty def simple_search - @lecturers = Lecturer.search(params[:search]) - @students = Student.search(params[:search]) - @teaching_assisstants = TeachingAssistant.search(params[:search]) - @courses = Course.search(params[:search]) + @lecturers = Lecturer.simple_search(params[:search]) + @students = Student.simple_search(params[:search]) + @teaching_assisstants = TeachingAssistant.simple_search(params[:search]) + @courses = Course.simple_search(params[:search]) respond_to do |format| format.js format.html @@ -17,5 +17,7 @@ def simple_search end def advanced_search + puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + end end diff --git a/tutor/app/models/post.rb b/tutor/app/models/post.rb index da15e87a..e9cc4cc9 100644 --- a/tutor/app/models/post.rb +++ b/tutor/app/models/post.rb @@ -1,5 +1,9 @@ class Post < ActiveRecord::Base - + + #Elasticsearch + include Tire::Model::Search + include Tire::Model::Callbacks + #Validations #Relations diff --git a/tutor/app/models/topic.rb b/tutor/app/models/topic.rb index 8dca74ad..a63cd235 100644 --- a/tutor/app/models/topic.rb +++ b/tutor/app/models/topic.rb @@ -1,5 +1,9 @@ class Topic < ActiveRecord::Base - + + #Elasticsearch + include Tire::Model::Search + include Tire::Model::Callbacks + #Validations validates :title, :description, presence: true validates :title, :description, uniqueness: true diff --git a/tutor/app/views/layouts/_signed_in_header.html.erb b/tutor/app/views/layouts/_signed_in_header.html.erb index 75842880..cf95ab51 100644 --- a/tutor/app/views/layouts/_signed_in_header.html.erb +++ b/tutor/app/views/layouts/_signed_in_header.html.erb @@ -5,10 +5,14 @@ -->
    -
    - <%= button_to "Delete Course", {:action => "destroy"}, class: "btn btn-danger" , style: "margin-top: 100px; float: right", method: :delete %> + <%= button_to "Delete Course", {:action => "destroy"}, class: "btn btn-danger", style: "margin-top: 100px; float: right", method: :delete %>
    <%= button_to "Back", {:controller => 'courses', :action => 'index'}, class: "btn btn-success" , style: "margin-left: 600px; margin-top: 250px", :method => :get%> \ No newline at end of file From 91dc12b0b6aef01d7c641de988165a9d405a109e Mon Sep 17 00:00:00 2001 From: serag Date: Tue, 22 Apr 2014 17:06:23 +0200 Subject: [PATCH 185/526] Issue #206 Added Documentation --- tutor/app/controllers/lecturers_controller.rb | 6 ++++++ tutor/app/controllers/students_controller.rb | 6 ++++++ tutor/app/controllers/teaching_assistants_controller.rb | 6 ++++++ tutor/app/views/students/show.html.erb | 2 +- tutor/config/routes.rb | 3 ++- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/tutor/app/controllers/lecturers_controller.rb b/tutor/app/controllers/lecturers_controller.rb index a64d7975..ca54b670 100644 --- a/tutor/app/controllers/lecturers_controller.rb +++ b/tutor/app/controllers/lecturers_controller.rb @@ -1,4 +1,10 @@ class LecturersController < ApplicationController + # [Profile - Story 5.8] + # Displays the profile of the lecturer chosen + # Parameters: + # id: the Lecturer's id + # Returns: none + # Author: Serag def show @lecturer = Lecturer.find(params[:id]) end diff --git a/tutor/app/controllers/students_controller.rb b/tutor/app/controllers/students_controller.rb index 84bf342d..cccc69d3 100644 --- a/tutor/app/controllers/students_controller.rb +++ b/tutor/app/controllers/students_controller.rb @@ -1,4 +1,10 @@ class StudentsController < ApplicationController + # [Profile - Story 5.8] + # Displays the profile of the student chosen + # Parameters: + # id: the Student's id + # Returns: none + # Author: Serag def show @student = Student.find(params[:id]) end diff --git a/tutor/app/controllers/teaching_assistants_controller.rb b/tutor/app/controllers/teaching_assistants_controller.rb index 10e2e7c9..a89b1d1e 100644 --- a/tutor/app/controllers/teaching_assistants_controller.rb +++ b/tutor/app/controllers/teaching_assistants_controller.rb @@ -1,4 +1,10 @@ class TeachingAssistantsController < ApplicationController + # [Profile - Story 5.8] + # Displays the profile of the teaching assistant chosen + # Parameters: + # id: the Teaching Assistant's id + # Returns: none + # Author: Serag def show @teaching_assistant = TeachingAssistant.find(params[:id]) end diff --git a/tutor/app/views/students/show.html.erb b/tutor/app/views/students/show.html.erb index d679ca3d..7fb72cfc 100644 --- a/tutor/app/views/students/show.html.erb +++ b/tutor/app/views/students/show.html.erb @@ -66,7 +66,7 @@ - CoolSoft - Java tutor | <%= @student.id%>'s Profile + <%= @student.id%>'s Profile

    <%= @student.name%>'s Profile

    diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index a82a9f2a..db026e0a 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -88,4 +88,5 @@ # # Directs /admin/products/* to Admin::ProductsController # # (app/controllers/admin/products_controller.rb) # resources :products - # end \ No newline at end of file + # end +end \ No newline at end of file From a7c55966df3e62eb8d23629c049abce849ae47e0 Mon Sep 17 00:00:00 2001 From: Khaled Date: Tue, 22 Apr 2014 17:18:30 +0200 Subject: [PATCH 186/526] Issue #193 Updated view for displaying variables --- .../assets/javascripts/solutions.js.coffee | 22 ++++++++++++++++++- tutor/app/models/debugger.rb | 8 +++---- tutor/app/views/problems/show.html.erb | 5 +++-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/tutor/app/assets/javascripts/solutions.js.coffee b/tutor/app/assets/javascripts/solutions.js.coffee index cd3c7a95..0a5dae37 100644 --- a/tutor/app/assets/javascripts/solutions.js.coffee +++ b/tutor/app/assets/javascripts/solutions.js.coffee @@ -109,9 +109,29 @@ indexNumber = 0 # Parameters: # stateNumber: The target state number. # Returns: none -# Author: Rami Khalil +# Author: Rami Khalil + Khaled Helmy @jump_state = (stateNumber) -> highlight_line variables[stateNumber]['line'] + update_memory_contents stateNumber + +# [View Variables - Story 3.7] +# Updates the variables values according to a certain state +# Parameters: +# stateNumber: The target state number. +# Returns: none +# Author: Khaled Helmy +@update_memory_contents = (stateNumber) -> + update_memory_contents = (stateNumber) -> + div = document.getElementById("memory") + list_of_variables = variables[stateNumber]["locals"] + s = "" + i = 0 + while i < list_of_variables.length + s += list_of_variables[i] + s += "
    " + i++ + div.innerHTML = s + return # [Debug - Story 3.6] # Stops the debugging session. diff --git a/tutor/app/models/debugger.rb b/tutor/app/models/debugger.rb index 80ee7d4c..9e234fc2 100644 --- a/tutor/app/models/debugger.rb +++ b/tutor/app/models/debugger.rb @@ -79,8 +79,8 @@ def start(file_path, input) buffer_until_ready input "run" num = get_line - # locals = get_variables - hash = {:line => num, :locals => []} + locals = get_variables + hash = {:line => num, :locals => locals} $all << hash debug rescue => e @@ -100,8 +100,8 @@ def debug begin input "step" num = get_line - # locals = get_variables - hash = {:line => num, :locals => []} + locals = get_variables + hash = {:line => num, :locals => locals} $all << hash counter += 1 rescue => e diff --git a/tutor/app/views/problems/show.html.erb b/tutor/app/views/problems/show.html.erb index de9d3abd..8e2a626c 100644 --- a/tutor/app/views/problems/show.html.erb +++ b/tutor/app/views/problems/show.html.erb @@ -15,8 +15,9 @@ <%= render partial: "solutions/new"%>
    - Memory Contents:

    -

    + Memory Contents: +
    +



    Hints:



    Tips:

    From 3cb39852ba0a0b9a9b82dfdb33be210fc1d51d0e Mon Sep 17 00:00:00 2001 From: MussabElDash Date: Tue, 22 Apr 2014 17:25:37 +0200 Subject: [PATCH 187/526] #250 Edited to be Compiled by Compile Model and to use Solution --- tutor/app/models/debugger.rb | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tutor/app/models/debugger.rb b/tutor/app/models/debugger.rb index bf48d059..650e94e0 100644 --- a/tutor/app/models/debugger.rb +++ b/tutor/app/models/debugger.rb @@ -66,19 +66,9 @@ def input(input) # Returns: A List of all 100 steps ahead # Authors: Mussab ElDash + Rami Khalil def start(file_path, input) - to_be_compiled = file_path - if file_path =~ /.*\.java/ - file_path = file_path[0..-6] - else - to_be_compiled = file_path + ".java" - end - if !system("javac -g " + to_be_compiled) - puts "Compilation Error" - exit - end $all = [] begin - $input, $output, $error, $wait_thread = Open3.popen3("jdb",file_path, input.strip) + $input, $output, $error, $wait_thread = Open3.popen3("jdb",file_path, input) buffer_until_ready input "stop in #{file_path}.main" buffer_until_ready @@ -146,12 +136,16 @@ def get_line # Returns: The result of the debugging # Author: Mussab ElDash def self.debug(student_id, problem_id, code, input) - code = change_class_name(student_id, problem_id, code) - file_name = 'st' + student_id.to_s + 'pr' + problem_id.to_s - File.open("#{file_name}.java", 'w') { |file| file.write(code) } - # return {done: "Done"} + solution = solution.Create({code: code, student_id: student_id, + problem_id: problem_id }) + compile_status = Compile.compiler_feedback(solution) + unless compile_status[:success] + return "Compilation Error" + end debugger = Debugger.new - return debugger.start(file_name, input) + input = input.split " " + file_path = solution.class_file_name true, false + return debugger.start(file_path, input.strip) end # [Debugger: Debug - Story 3.6] From 21dbb1a1ef5db1ba49974018c3ccbad1654a803c Mon Sep 17 00:00:00 2001 From: serag Date: Tue, 22 Apr 2014 18:44:49 +0200 Subject: [PATCH 188/526] Issue #206 Fixed Index views and added image to profiles --- tutor/app/views/lecturers/index.html.erb | 2 +- tutor/app/views/lecturers/show.html.erb | 2 +- tutor/app/views/students/index.html.erb | 2 +- tutor/app/views/students/show.html.erb | 4 +- .../views/teaching_assistants/index.html.erb | 53 +------------------ .../views/teaching_assistants/show.html.erb | 2 +- 6 files changed, 7 insertions(+), 58 deletions(-) diff --git a/tutor/app/views/lecturers/index.html.erb b/tutor/app/views/lecturers/index.html.erb index 05ef7fb7..5f5422ef 100644 --- a/tutor/app/views/lecturers/index.html.erb +++ b/tutor/app/views/lecturers/index.html.erb @@ -3,6 +3,6 @@ CoolSoft - Java Tutor -

    I am a lecturer

    +

    lecturers Index

    \ No newline at end of file diff --git a/tutor/app/views/lecturers/show.html.erb b/tutor/app/views/lecturers/show.html.erb index f4e83c4e..ed7b0f53 100644 --- a/tutor/app/views/lecturers/show.html.erb +++ b/tutor/app/views/lecturers/show.html.erb @@ -68,7 +68,7 @@ CoolSoft - Java tutor | <%= @lecturer.id%>'s Profile -

    <%= @lecturer.name%>'s Profile

    +

    <%= image_tag(@lecturer.profile_image_url.to_s) if @lecturer.profile_image? %> <%= @lecturer.name%>'s Profile

    -

    <%= @student.name%>

    -

    <%= @student.email%>

    +

    Name: <%= @student.name%>

    +

    Email: <%= @student.email%>

    @student.getStat() "to be reviewed"

    diff --git a/tutor/app/views/teaching_assistants/show.html.erb b/tutor/app/views/teaching_assistants/show.html.erb index 569fa002..af6d4082 100644 --- a/tutor/app/views/teaching_assistants/show.html.erb +++ b/tutor/app/views/teaching_assistants/show.html.erb @@ -77,8 +77,8 @@
    -

    <%= @teaching_assistant.name%>

    -

    <%= @teaching_assistant.email%>

    +

    Name: <%= @teaching_assistant.name%>

    +

    Email: <%= @teaching_assistant.email%>

    @teaching_assistant.getStat() "to be reviewed"

    From 5d28cd6b262a0bf62375207198a9d2a0d6583e2a Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Tue, 22 Apr 2014 20:11:02 +0200 Subject: [PATCH 197/526] #267 changed the way the error message is displayed --- tutor/app/views/posts/new.html.erb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tutor/app/views/posts/new.html.erb b/tutor/app/views/posts/new.html.erb index b984fd1e..1f5f5143 100644 --- a/tutor/app/views/posts/new.html.erb +++ b/tutor/app/views/posts/new.html.erb @@ -5,8 +5,20 @@

    New Post


    - <% if flash[:notice] -%> -
    <%= flash[:notice] %>
    + <% if @new_post.errors.any? %> +
    +

    + <%= pluralize(@new_post.errors.count, "error") %> + prohibited the Post from being saved: +

    +
    +
      + <% @new_post.errors.full_messages.each do |msg| %> +
    • + <%= msg %> +
    • + <% end %> +
    <% end %>


    <%= form_for :post, url: {action: "create"} do |f| %> From b70ab3617b74620a471910293bafea11b24aaf68 Mon Sep 17 00:00:00 2001 From: Mohab Date: Tue, 22 Apr 2014 20:26:17 +0200 Subject: [PATCH 198/526] Issue #200 displaying recommended problems --- tutor/app/controllers/profile_controller.rb | 2 ++ tutor/app/models/student.rb | 10 +++++----- .../app/views/layouts/_right_side_bar.html.erb | 18 ++++++++++++++++++ tutor/app/views/profile/index.html.erb | 0 4 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 tutor/app/controllers/profile_controller.rb create mode 100644 tutor/app/views/profile/index.html.erb diff --git a/tutor/app/controllers/profile_controller.rb b/tutor/app/controllers/profile_controller.rb new file mode 100644 index 00000000..c46b6546 --- /dev/null +++ b/tutor/app/controllers/profile_controller.rb @@ -0,0 +1,2 @@ +class ProfileController < ApplicationController +end diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index a563300e..a011587b 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -80,11 +80,11 @@ def getClassMatesRecommendations recommended_problems = Recommendation.where(:student_id => self.id) recommended_problems_hash = Hash.new recommended_problems.each do |problem| - recommended_problems_hash[problem.id] = Hash.new - recommender_name = Student.where(:id => problem.recommender_id).recommender_name - problem_title = Problem.where(:id => problem.id).title - recommended_problems_hash[problem.id]['recommender_name '] = recommender_name - recommended_problems_hash[problem.id]['ptoblem_title'] = problem.title + recommended_problems_hash[problem.problem_id] = Hash.new + recommender_name = Student.where(:id => problem.recommender_id).take.name + problem_title = Problem.where(:id => problem.problem_id).take.title + recommended_problems_hash[problem.problem_id]['recommender_name'] = recommender_name + recommended_problems_hash[problem.problem_id]['problem_title'] = problem_title end return recommended_problems_hash end diff --git a/tutor/app/views/layouts/_right_side_bar.html.erb b/tutor/app/views/layouts/_right_side_bar.html.erb index eddeb4be..27803dc7 100644 --- a/tutor/app/views/layouts/_right_side_bar.html.erb +++ b/tutor/app/views/layouts/_right_side_bar.html.erb @@ -4,4 +4,22 @@ # Author: Ahmed Elassuty --> \ No newline at end of file diff --git a/tutor/app/views/profile/index.html.erb b/tutor/app/views/profile/index.html.erb new file mode 100644 index 00000000..e69de29b From 0d7c2e7c2d12cdf792e0d9e38fdc4ee8aa61e46b Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Tue, 22 Apr 2014 20:32:24 +0200 Subject: [PATCH 199/526] Issue #188 saves empty records --- .../solutions_constraints_controller.rb | 53 ++----------------- .../solutions_constraints/_show_data.html.erb | 0 .../solutions_constraints/delete.html.erb | 7 --- .../views/solutions_constraints/edit.html.erb | 3 -- .../solutions_constraints/index.html.erb | 12 ----- .../views/solutions_constraints/show.html.erb | 27 ---------- 6 files changed, 5 insertions(+), 97 deletions(-) delete mode 100644 tutor/app/views/solutions_constraints/_show_data.html.erb delete mode 100644 tutor/app/views/solutions_constraints/delete.html.erb delete mode 100644 tutor/app/views/solutions_constraints/edit.html.erb delete mode 100644 tutor/app/views/solutions_constraints/index.html.erb delete mode 100644 tutor/app/views/solutions_constraints/show.html.erb diff --git a/tutor/app/controllers/solutions_constraints_controller.rb b/tutor/app/controllers/solutions_constraints_controller.rb index ae97f2f5..2af0007f 100644 --- a/tutor/app/controllers/solutions_constraints_controller.rb +++ b/tutor/app/controllers/solutions_constraints_controller.rb @@ -1,10 +1,4 @@ class SolutionsConstraintsController < ApplicationController - def index - @parameters = MethodParameter.all - @variables = VariableConstraint.all - #@methods = MethodConstraints.all - end - def create method_cons = params[:parameter_constraint] @var_cons = params[:variable_constraint] @@ -17,59 +11,22 @@ def create @constarint.method_name = method @constarint.method_return = @method_returned - unless method_cons.blank? + if method_cons.present? method_cons.each do |cons| @parameters = MethodParameter.new - @parameters.parameter = method_cons[:cons][:name] - @parameters.params_type = method_cons[:cons][:type] + puts "#{method_cons[0]} here" + @parameters.parameter = method_cons[:name] + @parameters.params_type = method_cons[:type] # @constrain.parameters << @parameters @parameters.save end end @constarint.save end + render json: true end def new @constrain = MethodConstraint.new end - - def show - @parameters = MethodParameter.find_by_id(params[:id]) - @variables = VariableConstraint.find_by_id(params[:id]) - #@methods = MethodConstraints.find_by_id(params[:id]) - if @parameters.nil? - redirect_to :action => 'index' - end - end - - 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 = MethodConstraints.find_by_id(params[:id]) - end - end - - def update - @parameters = MethodParameter.find_by_id(params[:id]) - @variables = VariableConstraint.find_by_id(params[:id]) - if @parameters.update_attributes(constraint_params) && @variables.update_attributes(constraint_params) - redirect_to :action => 'show' - else - redirect_to :action => 'index' - end - end - - def delete - @parameters = MethodParameter.find_by_id(params[:id]) - @variables = VariableConstraint.find_by_id(params[:id]) - end - - def destroy - @parameters = MethodParameter.find_by_id(params[:id]).destroy - @variables = VariableConstraint.find_by_id(params[:id]).destroy - flash[:success_deletion] = "Constraints deleted." - end - end diff --git a/tutor/app/views/solutions_constraints/_show_data.html.erb b/tutor/app/views/solutions_constraints/_show_data.html.erb deleted file mode 100644 index e69de29b..00000000 diff --git a/tutor/app/views/solutions_constraints/delete.html.erb b/tutor/app/views/solutions_constraints/delete.html.erb deleted file mode 100644 index ea29441b..00000000 --- a/tutor/app/views/solutions_constraints/delete.html.erb +++ /dev/null @@ -1,7 +0,0 @@ - -

    Delete Constraints

    - <%= form_for :parameter, url: solutions_constraints_delete_path do |delete| %> -

    Are you sure you want to delete this constraint

    - <%= @parameters.parameter %> - <%= delete.submit %> - <% end %> \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/edit.html.erb b/tutor/app/views/solutions_constraints/edit.html.erb deleted file mode 100644 index eb8f486a..00000000 --- a/tutor/app/views/solutions_constraints/edit.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= link_to "<< Back to list", :controller => 'solutions_constraints', :action => 'index' %> -

    Edit Constraints

    -<%= render "edit_method" %> \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/index.html.erb b/tutor/app/views/solutions_constraints/index.html.erb deleted file mode 100644 index f8e2cd77..00000000 --- a/tutor/app/views/solutions_constraints/index.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -

    Solutions' Constraints

    - - - <% @parameters.each do |params| %> - - - <% end %> - - -
    <%= link_to params.parameter, :controller => 'solutions_constraints', :action => 'show', :id => params.id %>
    - - <%= link_to "Create new Constraint", solutions_constraints_path %> \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/show.html.erb b/tutor/app/views/solutions_constraints/show.html.erb deleted file mode 100644 index ff0fbc2e..00000000 --- a/tutor/app/views/solutions_constraints/show.html.erb +++ /dev/null @@ -1,27 +0,0 @@ - <%= link_to "<< Back to list", :controller => 'solutions_constraints', :action => 'index' %> - - - - - - - - - - - - - -
    Constraints
    <%= @parameters.parameter %>
    <%= @variables.variable_name %>
    - <%= link_to "Edit", :controller => 'solutions_constraints', :action => 'edit' %> - -
    - - - - - - - - - \ No newline at end of file From 1c12dd810d3a2301f5aa188f4edeee206d52a0f5 Mon Sep 17 00:00:00 2001 From: Mohab Date: Tue, 22 Apr 2014 20:47:23 +0200 Subject: [PATCH 200/526] Issue #200 Inserting test records in seeds --- tutor/db/seeds.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tutor/db/seeds.rb b/tutor/db/seeds.rb index aa0556ef..63fb3d71 100644 --- a/tutor/db/seeds.rb +++ b/tutor/db/seeds.rb @@ -117,6 +117,11 @@ Attempt.create(failure: true) Attempt.create(failure: true) Attempt.create(failure: true) + +puts("#-----------------------Recommendations-----------------------") + Recommendation.create(problem_id:1, student_id:1, recommender_id:2) + Recommendation.create(problem_id:2, student_id:1, recommender_id:2) + Recommendation.create(problem_id:5, student_id:1, recommender_id:2) puts("# -------------------------------------------------------") From d8565a667464c83f0954b1bbde74dfa6c404449e Mon Sep 17 00:00:00 2001 From: Ahmed ELAssuty Date: Tue, 22 Apr 2014 20:56:38 +0200 Subject: [PATCH 201/526] Issue #223 query logic --- tutor/app/models/course.rb | 28 +++++++++++++++++++++++++ tutor/app/models/lecturer.rb | 6 ++++++ tutor/app/models/post.rb | 27 ++++++++++++++++++++++++ tutor/app/models/student.rb | 28 +++++++++++++++++++++++++ tutor/app/models/teaching_assistant.rb | 28 +++++++++++++++++++++++++ tutor/app/models/topic.rb | 29 ++++++++++++++++++++++++++ 6 files changed, 146 insertions(+) diff --git a/tutor/app/models/course.rb b/tutor/app/models/course.rb index d5655e6a..91c39fd5 100644 --- a/tutor/app/models/course.rb +++ b/tutor/app/models/course.rb @@ -45,4 +45,32 @@ def self.simple_search(keyword) where("name LIKE ? or code LIKE ?", "%#{keyword}%" , "%#{keyword}%") if keyword.present? end + # [Advanced Search - Story 1.23] + # search for courses + # Parameters: hash of search options + # Returns: A hash with search results according to the keyword and other options + # Author: Ahmed Elassuty + def self.search(params) + if params[:keyword].present? + case params[:options] + when "exactly match" + tire.search do + query { string "name:#{params[:keyword]}" } + end + when "includes" + tire.search do + query { string "name:*#{params[:keyword]}*" } + end + when "starts with" + tire.search do + query { string "name:#{params[:keyword]}*" } + end + when "ends with" + tire.search do + query { string "name:*#{params[:keyword]}" } + end + end + end + end + end diff --git a/tutor/app/models/lecturer.rb b/tutor/app/models/lecturer.rb index dbb139e9..8dfd2ef4 100644 --- a/tutor/app/models/lecturer.rb +++ b/tutor/app/models/lecturer.rb @@ -33,6 +33,12 @@ class Lecturer < ActiveRecord::Base #Scoops #Methods + + # [Advanced Search - Story 1.23] + # search for lecturers + # Parameters: hash of search options + # Returns: A hash with search results according to the keyword and other options + # Author: Ahmed Elassuty def self.search(params) if params[:keyword].present? case params[:options] diff --git a/tutor/app/models/post.rb b/tutor/app/models/post.rb index e9cc4cc9..0afbb25e 100644 --- a/tutor/app/models/post.rb +++ b/tutor/app/models/post.rb @@ -16,4 +16,31 @@ class Post < ActiveRecord::Base #Methods + # [Advanced Search - Story 1.23] + # search for posts + # Parameters: hash of search options + # Returns: A hash with search results according to the keyword and other options + # Author: Ahmed Elassuty + def self.search(params) + if params[:keyword].present? + case params[:options] + when "exactly match" + tire.search do + query { string "content:#{params[:keyword]}" } + end + when "includes" + tire.search do + query { string "content:*#{params[:keyword]}*" } + end + when "starts with" + tire.search do + query { string "content:#{params[:keyword]}*" } + end + when "ends with" + tire.search do + query { string "content:*#{params[:keyword]}" } + end + end + end + end end diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index 7a1f27f0..4f898efc 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -82,5 +82,33 @@ def getProblemsStatus end return res end + + # [Advanced Search - Story 1.23] + # search for students + # Parameters: hash of search options + # Returns: A hash with search results according to the keyword and other options + # Author: Ahmed Elassuty + def self.search(params) + if params[:keyword].present? + case params[:options] + when "exactly match" + tire.search do + query { string "name:#{params[:keyword]}" } + end + when "includes" + tire.search do + query { string "name:*#{params[:keyword]}*" } + end + when "starts with" + tire.search do + query { string "name:#{params[:keyword]}*" } + end + when "ends with" + tire.search do + query { string "name:*#{params[:keyword]}" } + end + end + end + end end diff --git a/tutor/app/models/teaching_assistant.rb b/tutor/app/models/teaching_assistant.rb index 6e766568..4df262c2 100644 --- a/tutor/app/models/teaching_assistant.rb +++ b/tutor/app/models/teaching_assistant.rb @@ -31,4 +31,32 @@ class TeachingAssistant < ActiveRecord::Base #Scoops #Methods + + # [Advanced Search - Story 1.23] + # search for students + # Parameters: hash of search options + # Returns: A hash with search results according to the keyword and other options + # Author: Ahmed Elassuty + def self.search(params) + if params[:keyword].present? + case params[:options] + when "exactly match" + tire.search do + query { string "name:#{params[:keyword]}" } + end + when "includes" + tire.search do + query { string "name:*#{params[:keyword]}*" } + end + when "starts with" + tire.search do + query { string "name:#{params[:keyword]}*" } + end + when "ends with" + tire.search do + query { string "name:*#{params[:keyword]}" } + end + end + end + end end diff --git a/tutor/app/models/topic.rb b/tutor/app/models/topic.rb index a63cd235..f16c23dc 100644 --- a/tutor/app/models/topic.rb +++ b/tutor/app/models/topic.rb @@ -13,4 +13,33 @@ class Topic < ActiveRecord::Base belongs_to :course belongs_to :owner, class_name: "Lecturer", foreign_key: :lecturer_id + #Methods + + # [Advanced Search - Story 1.23] + # search for topics + # Parameters: hash of search options + # Returns: A hash with search results according to the keyword and other options + # Author: Ahmed Elassuty + def self.search(params) + if params[:keyword].present? + case params[:options] + when "exactly match" + tire.search do + query { string "title:#{params[:keyword]}" } + end + when "includes" + tire.search do + query { string "title:*#{params[:keyword]}*" } + end + when "starts with" + tire.search do + query { string "title:#{params[:keyword]}*" } + end + when "ends with" + tire.search do + query { string "title:*#{params[:keyword]}" } + end + end + end + end end From 9ef63be41ac0376088c498edd85de4b18b610bae Mon Sep 17 00:00:00 2001 From: Ahmed ELAssuty Date: Tue, 22 Apr 2014 20:57:19 +0200 Subject: [PATCH 202/526] Issue #223 search views --- .../views/utilities/_advanced_search.html.erb | 63 +++++++++---------- .../app/views/utilities/_result_form.html.erb | 2 +- .../views/utilities/advanced_search.js.erb | 8 ++- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/tutor/app/views/utilities/_advanced_search.html.erb b/tutor/app/views/utilities/_advanced_search.html.erb index 82d1cc66..3796d1ea 100644 --- a/tutor/app/views/utilities/_advanced_search.html.erb +++ b/tutor/app/views/utilities/_advanced_search.html.erb @@ -11,44 +11,43 @@
    - -
    -
    - -
    -
    - -
    -
    - +
    - +
    - -
    +
    +
    + +
    +
    +
    -
    +
    + +
    +
    +
    +
    -
    - -
    - <%= select_tag :options , " - ".html_safe,class: "form-control"%> -
    -
    -
    -
    - -
    -
    - +
    +
    +
    + +
    + <%= select_tag :options , " + + ".html_safe,class: "form-control"%> +
    +
    +
    +
    + +
    +
    + <% end %> \ No newline at end of file From d555a4a0bafdaa6f9d028a6a289bd3169c836174 Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Tue, 22 Apr 2014 22:33:51 +0200 Subject: [PATCH 205/526] fixed the button bug, added documentation,woked on indentation. --- .../assets/javascripts/teaching_assistants.js | 0 .../teaching_assistants_controller.rb | 36 +++++++++------- tutor/app/views/courses/edit.html.erb | 4 -- .../views/teaching_assistants/new.html.erb | 41 ++++++++++++------- tutor/config/routes.rb | 1 + 5 files changed, 50 insertions(+), 32 deletions(-) create mode 100644 tutor/app/assets/javascripts/teaching_assistants.js diff --git a/tutor/app/assets/javascripts/teaching_assistants.js b/tutor/app/assets/javascripts/teaching_assistants.js new file mode 100644 index 00000000..e69de29b diff --git a/tutor/app/controllers/teaching_assistants_controller.rb b/tutor/app/controllers/teaching_assistants_controller.rb index 4a8eab61..cb4d8e59 100644 --- a/tutor/app/controllers/teaching_assistants_controller.rb +++ b/tutor/app/controllers/teaching_assistants_controller.rb @@ -1,8 +1,21 @@ class TeachingAssistantsController < ApplicationController - +# [Add TA - Story 1.4] +# this action renders the form and sets the value for checkbox +# Parameters: +# check : contains the value from the previous instance of the form +# Returns: None +# Author: Muhammad Mamdouh def new + if(@checkbox == nil) + @checkbox = true + end + @checkbox = !params[:check] end - +# [Add TA - Story 1.5,1.6] +# Adds the TA selected from the dropdown list in the view to the course and to the lecturer's history +# Parameters: teaching_assistant_id , course_id +# Returns: None +# Author: Muhammad Mamdouh def create begin @teaching_assistant = TeachingAssistant.find_by_id(params[:teaching_assistant][:id]) @@ -16,21 +29,16 @@ def create That or something went terribly wrong on our side. Either way lamo2a5za.' redirect_to :action => 'new' end - - end - - +# [Add TA - Story /] +# lists the TAs added to the course. +# Parameters: course_id +# Returns: +# @course +# @course_teaching_assistants +# Author: Muhammad Mamdouh def index @course = Course.find(params[:course_id]) @course_teaching_assistants = @course.TAs.order('name') end - - - - - - - - end diff --git a/tutor/app/views/courses/edit.html.erb b/tutor/app/views/courses/edit.html.erb index d0ff2964..d2f8c6a3 100644 --- a/tutor/app/views/courses/edit.html.erb +++ b/tutor/app/views/courses/edit.html.erb @@ -20,10 +20,6 @@ :course_id => @course.id}, class: "btn btn-success" , style: "float: left; margin-left: 15px", :method => :get%>
    - -
    <%= button_to "Acknowledge a student", {:controller => 'teaching_assistants', :action => 'new', - :course_id => @course.id}, class: "btn btn-success" , style: "float: left; margin-left: 15px", :method => :get%> -
    <% if @discussionBoard.activated == true %> diff --git a/tutor/app/views/teaching_assistants/new.html.erb b/tutor/app/views/teaching_assistants/new.html.erb index a3d91687..a8c3877b 100644 --- a/tutor/app/views/teaching_assistants/new.html.erb +++ b/tutor/app/views/teaching_assistants/new.html.erb @@ -1,24 +1,37 @@

    Add a Teaching Assistant

    +
    -<% if flash[:notice] -%> -
    <%= flash[:notice] %>
    -<% end %> + <% if flash[:notice] -%> +
    <%= flash[:notice] %>
    + <% end %>
    + <%= form_for :teaching_assistant, url: {action: "create"} do |f| %> -

    - <%= select("teaching_assistant", "id", TeachingAssistant.find(:all).collect {|p| [p.name ,p.id ] }, {:prompt => 'Select'}) %> -

    + <% if @checkbox == true %> +

    + <%= select("teaching_assistant", "id", TeachingAssistant.find(:all).collect {|p| [p.name ,p.id ] }, {:prompt => 'Select'}) %> +

    + <% else %> +

    + <%= select("teaching_assistant", "id", current_lecturer.worked_with.find(:all).collect {|p| [p.name ,p.id ] }, {:prompt => 'Select'}) %> +

    + <% end %> -

    - <%= select("teaching_assistant", "id", current_lecturer.worked_with.find(:all).collect {|p| [p.name ,p.id ] }, {:prompt => 'Select'}) %> -

    -

    - - Only show people I've worked with
    -

    - <%= f.submit "Add TA", class: "btn btn-success"%> + <%= f.submit "Add TA", class: "btn btn-success"%>

    <% end %> +
    + <% if @checkbox == true %> + <% str = "Show only TAs I worked with" %> + <% else %> + <% str = "Show All TAs" , @checkbox = nil%> + <% end %> + +
    <%= button_to str, {:controller => 'teaching_assistants', :action => 'new', check: @checkbox}, class: "btn btn-success" , style: "float: left; margin-left: 15px" %> +
    +
    + + <%= button_to "Back", {:controller => 'courses', :action =>'index'}, class: "btn btn-success", style: "float:right; margin-top:-50px", :method => :get %> \ No newline at end of file diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index 3893eb96..1056ca82 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -22,6 +22,7 @@ resources :courses do post 'topics/new' => 'topics#new' resources :teaching_assistants + post 'teaching_assistants/new' => 'teaching_assistants#new' resources :topics end resources :model_answers do From 9591f2116e99ad165cf09cef320869c4ca77d792 Mon Sep 17 00:00:00 2001 From: Ahmed ELAssuty Date: Tue, 22 Apr 2014 22:34:19 +0200 Subject: [PATCH 206/526] Issue #223 fix method --- tutor/app/models/post.rb | 8 ++++---- tutor/app/models/teaching_assistant.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tutor/app/models/post.rb b/tutor/app/models/post.rb index 0afbb25e..4525f378 100644 --- a/tutor/app/models/post.rb +++ b/tutor/app/models/post.rb @@ -26,19 +26,19 @@ def self.search(params) case params[:options] when "exactly match" tire.search do - query { string "content:#{params[:keyword]}" } + query { string "title:#{params[:keyword]}" } end when "includes" tire.search do - query { string "content:*#{params[:keyword]}*" } + query { string "title:*#{params[:keyword]}*" } end when "starts with" tire.search do - query { string "content:#{params[:keyword]}*" } + query { string "title:#{params[:keyword]}*" } end when "ends with" tire.search do - query { string "content:*#{params[:keyword]}" } + query { string "title:*#{params[:keyword]}" } end end end diff --git a/tutor/app/models/teaching_assistant.rb b/tutor/app/models/teaching_assistant.rb index 4df262c2..9945f9a2 100644 --- a/tutor/app/models/teaching_assistant.rb +++ b/tutor/app/models/teaching_assistant.rb @@ -26,7 +26,7 @@ class TeachingAssistant < ActiveRecord::Base has_many :method_parameters, as: :owner has_many :variable_constraints, as: :owner has_many :test_cases, as: :owner - has_many :hints, as: :ownert + has_many :hints, as: :owner #Scoops From 49611ec2b92cca4e47fc3e3cfb34c53a3a0dbe56 Mon Sep 17 00:00:00 2001 From: Ahmed ELAssuty Date: Tue, 22 Apr 2014 22:35:08 +0200 Subject: [PATCH 207/526] Issue #223 fix indentation --- .../app/views/utilities/_advanced_search.html.erb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tutor/app/views/utilities/_advanced_search.html.erb b/tutor/app/views/utilities/_advanced_search.html.erb index 50c81dae..b13971d4 100644 --- a/tutor/app/views/utilities/_advanced_search.html.erb +++ b/tutor/app/views/utilities/_advanced_search.html.erb @@ -1,9 +1,10 @@ -<%= form_tag utilities_advanced_search_path, method: 'get', remote: true,class: "form-horizontal" do %> +<%= form_tag utilities_advanced_search_path, method: 'get', remote: true, + class: "form-horizontal" do %>
    - <%= text_field_tag :keyword, "" , class: "form-control" %> + <%= text_field_tag :keyword, "" , class: "form-control" %>
    @@ -18,7 +19,7 @@
    +
    +
    From 535f11228b3460e9391fbb104eb4df14a7ff26f2 Mon Sep 17 00:00:00 2001 From: MussabElDash Date: Tue, 22 Apr 2014 22:40:13 +0200 Subject: [PATCH 208/526] #250 Edditing Debugger --- tutor/app/models/debugger.rb | 57 ++++++++++++++---------------------- 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/tutor/app/models/debugger.rb b/tutor/app/models/debugger.rb index 650e94e0..0f5652c0 100644 --- a/tutor/app/models/debugger.rb +++ b/tutor/app/models/debugger.rb @@ -65,22 +65,25 @@ def input(input) # input : The arguments to be passed to the main method # Returns: A List of all 100 steps ahead # Authors: Mussab ElDash + Rami Khalil - def start(file_path, input) + def start(solution, input) + class_name = solution.class_file_name $all = [] - begin - $input, $output, $error, $wait_thread = Open3.popen3("jdb",file_path, input) - buffer_until_ready - input "stop in #{file_path}.main" - buffer_until_ready - input "run" - num = get_line - # locals = get_variables - hash = {:line => num, :locals => []} - $all << hash - debug - rescue => e - p e.message - end + Dir.chdir(Solution::CLASS_PATH){ + begin + $input, $output, $error, $wait_thread = Open3.popen3("jdb", class_name, input) + p buffer_until_ready + input "stop in #{class_name}.main" + p buffer_until_ready + input "run" + num = get_line + # locals = get_variables + hash = {:line => num, :locals => []} + $all << hash + debug + rescue => e + p e.message + end + } return $all end @@ -122,7 +125,7 @@ def get_line if regex_capture return regex_capture.to_i else - raise 'Exited' + return -1 end end @@ -136,29 +139,13 @@ def get_line # Returns: The result of the debugging # Author: Mussab ElDash def self.debug(student_id, problem_id, code, input) - solution = solution.Create({code: code, student_id: student_id, + solution = Solution.create({code: code, student_id: student_id, problem_id: problem_id }) - compile_status = Compile.compiler_feedback(solution) + compile_status = Compiler.compiler_feedback(solution) unless compile_status[:success] return "Compilation Error" end debugger = Debugger.new - input = input.split " " - file_path = solution.class_file_name true, false - return debugger.start(file_path, input.strip) + return debugger.start(solution, input) end - - # [Debugger: Debug - Story 3.6] - # Renames the class name to be compiled and debugged correctly - # Parameters: - # Student_id: The id of the current signed in student - # problem_id: The id of the problem being solved - # code: The code to be debugged - # Returns: The modified code - # Author: Mussab ElDash - def self.change_class_name(student_id, problem_id, code) - name = 'st' + student_id.to_s + 'pr' + problem_id.to_s - return code.sub(code[0..code.index('{')], 'public class ' + name + ' {') - end - end From c02041628e07fba804e1a3a34847680020addd21 Mon Sep 17 00:00:00 2001 From: Ahmed ELAssuty Date: Tue, 22 Apr 2014 22:40:39 +0200 Subject: [PATCH 209/526] Issue #223 fix layout --- tutor/app/assets/stylesheets/application.css | 2 +- tutor/app/views/layouts/_right_side_bar.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tutor/app/assets/stylesheets/application.css b/tutor/app/assets/stylesheets/application.css index 5e38f589..348e58a1 100644 --- a/tutor/app/assets/stylesheets/application.css +++ b/tutor/app/assets/stylesheets/application.css @@ -27,7 +27,7 @@ margin-top:70px; margin-bottom:70px; height:auto; - width:71%; + width:76%; margin-left:2%; margin-bottom: 100px; } diff --git a/tutor/app/views/layouts/_right_side_bar.html.erb b/tutor/app/views/layouts/_right_side_bar.html.erb index eddeb4be..100ecf78 100644 --- a/tutor/app/views/layouts/_right_side_bar.html.erb +++ b/tutor/app/views/layouts/_right_side_bar.html.erb @@ -3,5 +3,5 @@ # General layout for right side bar # Author: Ahmed Elassuty --> -
    diff --git a/tutor/app/views/students/show.html.erb b/tutor/app/views/students/show.html.erb index 90e25412..64e2575c 100644 --- a/tutor/app/views/students/show.html.erb +++ b/tutor/app/views/students/show.html.erb @@ -1,19 +1,4 @@ -CoolSoft - Java tutor | <%= @student.id%>'s Profile @@ -32,7 +17,7 @@

    @student.getStat() "to be reviewed"

    -
    +
    diff --git a/tutor/app/views/teaching_assistants/show.html.erb b/tutor/app/views/teaching_assistants/show.html.erb index 683f5aaa..8d2f5fda 100644 --- a/tutor/app/views/teaching_assistants/show.html.erb +++ b/tutor/app/views/teaching_assistants/show.html.erb @@ -1,19 +1,4 @@ -CoolSoft - Java tutor | <%= @teaching_assistant.id%>'s Profile @@ -32,7 +17,7 @@

    @teaching_assistant.getStat() "to be reviewed"

    -
    +
    From 63294e6476452a6d74eae0f0ec3244058df847e8 Mon Sep 17 00:00:00 2001 From: serag Date: Wed, 23 Apr 2014 01:47:25 +0200 Subject: [PATCH 242/526] Issue #206 fixed indentations --- tutor/app/views/lecturers/index.html.erb | 1 + tutor/app/views/lecturers/show.html.erb | 1 + tutor/app/views/students/index.html.erb | 1 + tutor/app/views/students/show.html.erb | 1 + tutor/app/views/teaching_assistants/index.html.erb | 1 + tutor/app/views/teaching_assistants/show.html.erb | 1 + 6 files changed, 6 insertions(+) diff --git a/tutor/app/views/lecturers/index.html.erb b/tutor/app/views/lecturers/index.html.erb index 5f5422ef..caa85295 100644 --- a/tutor/app/views/lecturers/index.html.erb +++ b/tutor/app/views/lecturers/index.html.erb @@ -2,6 +2,7 @@ CoolSoft - Java Tutor +

    lecturers Index

    diff --git a/tutor/app/views/lecturers/show.html.erb b/tutor/app/views/lecturers/show.html.erb index 1004f0f9..43458374 100644 --- a/tutor/app/views/lecturers/show.html.erb +++ b/tutor/app/views/lecturers/show.html.erb @@ -2,6 +2,7 @@ CoolSoft - Java tutor | <%= @lecturer.id%>'s Profile +

    <%= image_tag(@lecturer.profile_image_url.to_s) if @lecturer.profile_image? %> <%= @lecturer.name%>'s Profile

    diff --git a/tutor/app/views/students/index.html.erb b/tutor/app/views/students/index.html.erb index 1b3cf910..41f1318b 100644 --- a/tutor/app/views/students/index.html.erb +++ b/tutor/app/views/students/index.html.erb @@ -2,6 +2,7 @@ CoolSoft - Java Tutor +

    students Index

    diff --git a/tutor/app/views/students/show.html.erb b/tutor/app/views/students/show.html.erb index 64e2575c..0742420e 100644 --- a/tutor/app/views/students/show.html.erb +++ b/tutor/app/views/students/show.html.erb @@ -2,6 +2,7 @@ CoolSoft - Java tutor | <%= @student.id%>'s Profile +

    <%= image_tag(@student.profile_image_url.to_s) if @student.profile_image? %> <%= @student.name%>'s Profile

    diff --git a/tutor/app/views/teaching_assistants/index.html.erb b/tutor/app/views/teaching_assistants/index.html.erb index 1a3cd106..50613671 100644 --- a/tutor/app/views/teaching_assistants/index.html.erb +++ b/tutor/app/views/teaching_assistants/index.html.erb @@ -2,6 +2,7 @@ CoolSoft - Java Tutor +

    Teaching Assistants Index

    diff --git a/tutor/app/views/teaching_assistants/show.html.erb b/tutor/app/views/teaching_assistants/show.html.erb index 8d2f5fda..91316e1c 100644 --- a/tutor/app/views/teaching_assistants/show.html.erb +++ b/tutor/app/views/teaching_assistants/show.html.erb @@ -2,6 +2,7 @@ CoolSoft - Java tutor | <%= @teaching_assistant.id%>'s Profile +

    <%= image_tag(@teaching_assistant.profile_image_url.to_s) if @teaching_assistant.profile_image? %> <%= @teaching_assistant.name%>'s Profile

    From dad22eba5dcd09c2678c143b52beb2679890efdb Mon Sep 17 00:00:00 2001 From: MussabElDash Date: Wed, 23 Apr 2014 01:47:28 +0200 Subject: [PATCH 243/526] #250 Using The compiler model and showing compilation errors --- .../assets/javascripts/solutions.js.coffee | 39 +++++++++++++++-- tutor/app/controllers/debuggers_controller.rb | 3 +- tutor/app/controllers/solutions_controller.rb | 1 + tutor/app/models/debugger.rb | 43 +++++++++++++------ 4 files changed, 67 insertions(+), 19 deletions(-) diff --git a/tutor/app/assets/javascripts/solutions.js.coffee b/tutor/app/assets/javascripts/solutions.js.coffee index 11cf9627..6b7745a4 100644 --- a/tutor/app/assets/javascripts/solutions.js.coffee +++ b/tutor/app/assets/javascripts/solutions.js.coffee @@ -19,15 +19,48 @@ index_number = 0 data: {code : input , case : test} datatype: 'json' success: (data) -> - toggleDebug() - variables = data stop_spin() + if !data["success"] + compilation_error data["data"]["errors"] + return + variables = data["data"] + toggleDebug() + debug_console() jump_state 0 error: -> stop_spin() return return +# [Debugger: Debug - Story 3.6] +# Fills the console with the compilation errors +# Parameters: noe +# Returns: none +# Author: Mussab ElDash +compilation_error = (data) -> + $('.compilation_failed').html("Compilation Failed!") + $('.compilation_feedback').html(data) + return + +# [Debugger: Debug - Story 3.6] +# Clears the console +# Parameters: noe +# Returns: none +# Author: Mussab ElDash +clear_console = -> + $('.compilation_failed').html("") + $('.compilation_feedback').html("") + return + +# [Debugger: Debug - Story 3.6] +# Write successful debug in the console +# Parameters: noe +# Returns: none +# Author: Mussab ElDash +debug_console = -> + $('.compilation_succeeded').html("Debugging Succeeded!") + return + # [Debugger: Debug - Story 3.6] # Starts the Spinner # Parameters: noe @@ -142,7 +175,7 @@ index_number = 0 # Returns: none # Author: Rami Khalil @jump_state = (stateNumber) -> - highlight_line variables[stateNumber]['line'] - 1 + highlight_line variables[stateNumber]['line'] - 2 # [Debug - Story 3.6] # Stops the debugging session. diff --git a/tutor/app/controllers/debuggers_controller.rb b/tutor/app/controllers/debuggers_controller.rb index 35fd7f70..a0c2af34 100644 --- a/tutor/app/controllers/debuggers_controller.rb +++ b/tutor/app/controllers/debuggers_controller.rb @@ -16,9 +16,8 @@ def start id = current_student.id pid = params[:id] input = params[:code] - cases = params[:case] + cases = if params[:case] then params[:case] else "" end result = Debugger.debug(id, pid, input, cases) - p result render json: result end diff --git a/tutor/app/controllers/solutions_controller.rb b/tutor/app/controllers/solutions_controller.rb index e94720f9..fe0243ba 100644 --- a/tutor/app/controllers/solutions_controller.rb +++ b/tutor/app/controllers/solutions_controller.rb @@ -77,6 +77,7 @@ def compile_solution else flash[:alert] = "You did not write any code!" end + redirect_to :back end private diff --git a/tutor/app/models/debugger.rb b/tutor/app/models/debugger.rb index 0f5652c0..93ad0b43 100644 --- a/tutor/app/models/debugger.rb +++ b/tutor/app/models/debugger.rb @@ -65,15 +65,14 @@ def input(input) # input : The arguments to be passed to the main method # Returns: A List of all 100 steps ahead # Authors: Mussab ElDash + Rami Khalil - def start(solution, input) - class_name = solution.class_file_name + def start(class_name, input) $all = [] Dir.chdir(Solution::CLASS_PATH){ begin $input, $output, $error, $wait_thread = Open3.popen3("jdb", class_name, input) - p buffer_until_ready + buffer_until_ready input "stop in #{class_name}.main" - p buffer_until_ready + buffer_until_ready input "run" num = get_line # locals = get_variables @@ -81,7 +80,9 @@ def start(solution, input) $all << hash debug rescue => e - p e.message + unless e.message === 'Exited' + return false + end end } return $all @@ -103,9 +104,8 @@ def debug $all << hash counter += 1 rescue => e - puts e.message $input.close - puts "closed" + raise 'Exited' end end end @@ -119,13 +119,20 @@ def get_line out_stream = buffer_until_complete puts out_stream list_of_lines = out_stream.split(/\n+/) + before_last_line = list_of_lines[-2] + /, line=\d+/ =~ before_last_line + before_last_regex_capture = $& + /\d+/ =~ before_last_regex_capture + before_last_regex_capture = $& last_line = list_of_lines[-2] /^\d+/=~ last_line - regex_capture = $& - if regex_capture - return regex_capture.to_i + last_regex_capture = $& + if last_regex_capture + return last_regex_capture.to_i + elsif before_last_regex_capture + return before_last_regex_capture.to_i else - return -1 + raise 'Exited' end end @@ -143,9 +150,17 @@ def self.debug(student_id, problem_id, code, input) problem_id: problem_id }) compile_status = Compiler.compiler_feedback(solution) unless compile_status[:success] - return "Compilation Error" + return {:success => false , data: compile_status} end debugger = Debugger.new - return debugger.start(solution, input) + class_name = solution.class_file_name + debugging = debugger.start(class_name, input) + puts "-----------------------------------------------------" + p debugging + java_file = solution.java_file_name true, true + class_file = solution.class_file_name true, true + File.delete(java_file) + File.delete(class_file) + return {:success => true , data: debugging} end -end +end \ No newline at end of file From ab0d8458f2889b449b894592973b7011aecb0931 Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Wed, 23 Apr 2014 02:11:10 +0200 Subject: [PATCH 244/526] Issue #188 adding documentations --- .../javascripts/solutions_constraints.js | 25 ++++++++++-- .../solutions_constraints_controller.rb | 39 ++++++++++++------- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/tutor/app/assets/javascripts/solutions_constraints.js b/tutor/app/assets/javascripts/solutions_constraints.js index b8b072c7..e0bfed78 100644 --- a/tutor/app/assets/javascripts/solutions_constraints.js +++ b/tutor/app/assets/javascripts/solutions_constraints.js @@ -4,7 +4,13 @@ var type = new Array(); var param_name = new Array(); +var var_type = new Array(); +var var_name = new Array(); +// # Description: Adds the parameters from the text_fields to array +// # Parameters:none +// # Returns: none +// # Author: Ahmed Mohamed Magdi function add_params(field) { var tmp_type = document.getElementById("params_type").value; @@ -44,6 +50,10 @@ function add_params(field) } } +// # Description: removes selected variable from method Contraints +// # Parameters:none +// # Returns: none +// # Author: Ahmed Mohamed Magdi function remove_params(field) { var index = field.id.split("_")[1]; @@ -67,9 +77,10 @@ function remove_params(field) $('#parameter').append("
    "); } -var var_type = new Array(); -var var_name = new Array(); - +// # Description: Adds the parameters from the text_fields to array +// # Parameters:none +// # Returns: none +// # Author: Ahmed Mohamed Magdi function add_variable(field) { var tmp_type = document.getElementById("variable_type").value; @@ -109,6 +120,10 @@ function add_variable(field) } } +// # Description: removes selected variable from Variable Contraints +// # Parameters:none +// # Returns: none +// # Author: Ahmed Mohamed Magdi function remove_variable(field) { var index = field.id.split("_")[1]; @@ -132,6 +147,10 @@ function remove_variable(field) $('#variable').append(""); } +// # Description: submits via ajax to the controller +// # Parameters:none +// # Returns: none +// # Author: Ahmed Mohamed Magdi function submitParams() { var hash_p = [] var hash_v = [] diff --git a/tutor/app/controllers/solutions_constraints_controller.rb b/tutor/app/controllers/solutions_constraints_controller.rb index 50914a19..fa1ef12c 100644 --- a/tutor/app/controllers/solutions_constraints_controller.rb +++ b/tutor/app/controllers/solutions_constraints_controller.rb @@ -1,35 +1,46 @@ class SolutionsConstraintsController < ApplicationController + + # Description: Creates New record for either Method or vairable constraints + # Parameters: + # method_cons: Hash containting the Method parameters + # var_cons: Hash containting the Variables Constraints + # method: value of the method name. + # method_returned: value of the method return type + # Returns: none + # Author: Ahmed Mohamed Magdi def create method_cons = params[:parameter_constraint] - @var_cons = params[:variable_constraint] - + var_cons = params[:variable_constraint] method = params[:method_name] method_returned = params[:method_return] unless method == "" - @constarint = MethodConstraint.new - @constarint.method_name = method - @constarint.method_return = @method_returned + constarint = MethodConstraint.new + constarint.method_name = method + constarint.method_return = method_returned if method_cons.present? method_cons.each do |cons| - @parameters = MethodParameter.new - @parameters.parameter = method_cons[:name] - @parameters.params_type = method_cons[:type] - # @constrain.parameters << @parameters - @parameters.save + parameters = MethodParameter.new + parameters.parameter = method_cons[:name] + parameters.params_type = method_cons[:type] + # constarint.parameters << parameters + parameters.save end render json: true - @constarint.save + constarint.save else render json: false end - end - end + # Description: init New record + # Parameters: none + # Returns: none + # Author: Ahmed Mohamed Magdi def new - @constrain = MethodConstraint.new + constrain = MethodConstraint.new + parameters = MethodParameter.new end end From a5d93804d7540dee255b1112ac10a5b7acded7f1 Mon Sep 17 00:00:00 2001 From: Khaled Date: Wed, 23 Apr 2014 02:35:28 +0200 Subject: [PATCH 245/526] Issue #143 Fixed some bugs --- tutor/app/controllers/courses_controller.rb | 38 +++++++++++++++------ tutor/app/views/courses/index.html.erb | 6 ++-- tutor/config/routes.rb | 1 + 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/tutor/app/controllers/courses_controller.rb b/tutor/app/controllers/courses_controller.rb index 6301c56f..f1361c05 100644 --- a/tutor/app/controllers/courses_controller.rb +++ b/tutor/app/controllers/courses_controller.rb @@ -150,23 +150,22 @@ def manage # occurs # Parameters: # params[:id]: The course id - # params[:share_value]: The decision of the student whether to share his + # params[:value]: The decision of the student whether to share his # performance or not # Returns: none # Author: Khaled Helmy def share - if student_signed_in + if student_signed_in? student_id = current_student.id course_id = params[:id] - share_value = params[:share_value] - result = CourseStudent.where("student_id = ? AND course_id = ?", student_id, course_id) - if result.share == true and share_value == true - render ('public/404') - elsif result.share == false and share_value == false + value = to_boolean params[:value] + result = CourseStudent.where("student_id = ? AND course_id = ?", student_id, course_id)[0] + if result.share == value render ('public/404') else - result.share = share_value + result.share = value result.save + redirect_to "/courses" end else render ('public/404') @@ -190,11 +189,12 @@ def course_params def find_state courses states = [] student_id = current_student.id + puts student_id courses.each do |c| course_id = c.id - result = CourseStudent.where("student_id = ? AND course_id = ?", student_id, course_id) - if result.share == true - states << "Share" + result = CourseStudent.where("student_id = ? AND course_id = ?", student_id, course_id)[0] + if result.share == false + states << "Show" else states << "Hide" end @@ -202,4 +202,20 @@ def find_state courses return states end + # [Share Performance - Story 5.2, 5.13] + # Description: Converts a string consisting of either "true" or "false" + # into the corresponding boolean value + # Parameters: + # value: String consisting of "true" or "false" to be converted to boolean + # Returns: + # Boolean + # Author: Khaled Helmy + def to_boolean value + if value == "true" + return true + else + return false + end + end + end \ No newline at end of file diff --git a/tutor/app/views/courses/index.html.erb b/tutor/app/views/courses/index.html.erb index 88457815..f07d12f8 100644 --- a/tutor/app/views/courses/index.html.erb +++ b/tutor/app/views/courses/index.html.erb @@ -33,10 +33,10 @@ <% if current_student %> - <% if s %> - <%= link_to "Share", {:controller => 'courses', :action => 'share', :method => :post, :id => c.id}, :share_value => true, class: "btn btn-success", style: "text-decoration:none" %> + <% if s == "Show" %> + <%= button_to "Show Performance", {:controller => 'courses', :action => 'share', :id => c.id, :value => true}, class: "btn btn-success", style: "text-decoration:none" %> <% else %> - <%= link_to "Hide", {:controller => 'courses', :action => 'share', :method => :post, :id => c.id}, :share_value => false, class: "btn btn-success", style: "text-decoration:none" %> + <%= button_to "Hide Performance", {:controller => 'courses', :action => 'share', :id => c.id, :value => false}, class: "btn btn-success", style: "text-decoration:none" %> <% end %> <% end %> diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index 378532f4..9e1aa367 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -12,6 +12,7 @@ # get 'products/index' post 'solutions/compile_solution' => 'problems#show' post 'courses/new' => 'courses#new' + post 'courses/share' => 'courses#share' get 'courses/sign_up' post 'solutions/execute' => 'problems#show' post 'debuggers/:id' => 'debuggers#start' From fab5932fd7095e27ea15cad506fdac7a1be56399 Mon Sep 17 00:00:00 2001 From: Nadine Adel Date: Wed, 23 Apr 2014 02:43:40 +0200 Subject: [PATCH 246/526] Issue #183 editing view new --- .../controllers/model_answers_controller.rb | 94 +++++++++++++++---- tutor/app/views/model_answers/_new.html.erb | 19 ---- tutor/app/views/model_answers/new.html.erb | 37 ++++++++ tutor/app/views/problems/edit.html.erb | 2 +- 4 files changed, 113 insertions(+), 39 deletions(-) delete mode 100644 tutor/app/views/model_answers/_new.html.erb create mode 100644 tutor/app/views/model_answers/new.html.erb diff --git a/tutor/app/controllers/model_answers_controller.rb b/tutor/app/controllers/model_answers_controller.rb index f1f15621..f8b0349e 100644 --- a/tutor/app/controllers/model_answers_controller.rb +++ b/tutor/app/controllers/model_answers_controller.rb @@ -1,41 +1,92 @@ class ModelAnswersController < ApplicationController + @@problemid = nil # [Add answer story 4.6] # It creates the new answer. # Parameters: + # @problem:To fetch the problem to which the answer is added. + # @@problemid :this is a global variable to save the id of the problem to which the answer is added to be able to use + # it in another views. # @answer: the new answer the user enters. # @answers: All the previous answers that had been entered before. # Return : none # Author: Nadine Adel def new - @answers = ModelAnswer.all - @answer = ModelAnswer.new + @problem = Problem.find(params[:problem_id]) + @@problemid = params[:problem_id] + session[:problem_id] = params[:problem_id] + if(@new_answer == nil) + @new_answer =ModelAnswer.new + end end # [Add answer story 4.6] - # The new answer is saved. + # The new answer is saved and check that the user is a lecturer or TA. # Parameters: - # @answer:answer provided by the user. + # @new_answer:answer provided by the user. + # @problems:The problem to which the answer is linked. # Returns: Returns a message if the answer is added and another message if answer was not added. # Author: Nadine Adel def create + @new_answer = ModelAnswer.new + @new_answer.title = post_params[:title] + @new_answer.answer = post_params[:answer] + @new_answer.problem_id = session[:problem_id] + @problems =Problem.find_by_id(session[:problem_id]) if lecturer_signed_in? - @answer = ModelAnswer.new(post_params) - @answer.owner_id = current_lecturer.id - @answer.owner_type = "lecturer" + @new_answer.owner_id = current_lecturer.id + @new_answer.owner_type = "lecturer" elsif teaching_assistant_signed_in? - @answer = ModelAnswer.new(post_params) - @answer.owner_id = current_teaching_assistant.id - @answer.owner_type = "teaching assistant" + @new_answer.owner_id = current_teaching_assistant.id + @new_answer.owner_type = "teaching assistant" end - if @answer.save - flash[:notice] = "Your Answer is now added" - redirect_to :controller => 'problems', :action => 'edit', :id => @answer.problem_id + if @new_answer.save + flash[:success_creation]= "Answer added." + @problems.model_answers << @new_answer + redirect_to :controller => 'model_answers', :action => 'edit', :id => @new_answer.id else - flash[:notice] = "Your Answer can not be added" - redirect_to :controller => 'problems', :action => 'edit', :id => @answer.problem_id + render :action=>'new' , :problem_id => post_params[:problem_id] end end + # [Edit answer story 4.7] + # Answer that has been created before is edited + # Parameters: + # @answer:answerthat is being edited. + # @problem:The problem to which the answer is linked. + # @tips:Tips that are linked to the answer being edited. + # @tips_check:used to check the type of Hint. + # @hints:Hints that are linked to the answer being edited. + # @hints_check:used to check the type of Hint. + # Returns: Returns a message if the answer is edited and another message if answer was not edited. + # Author: Nadine Adel + + def edit + @answer = ModelAnswer.find(params[:id]) + @problem = Problem.find(@answer.problem_id) + @tips = @answer.hints + @tips_check = @answer.hints + @hints = @answer.hints + @hints_check = @answer.hints + end + + # [Edit answer story 4.7] + # Answer is updated in the database. + # Parameters: + # @answer:answer that is being updated. + # Returns: None. + # Author: Nadine Adel + + def update + @answer = ModelAnswer.find(params[:id]) + if @answer.update_attributes(post_params) + flash[:notice] = "Your Answer is now updated" + redirect_to :controller => 'problems', :action => 'edit', :id => @@problemid + else + session[:errorsupdate] = @answer.errors.full_messages + redirect_to :back + end + end + # [Add answer story 4.6] # It shows answer that was entered before. # Parameters: @@ -44,26 +95,31 @@ def create # Author: Nadine Adel def show @answer = ModelAnswer.find(params[:problem_id]) + end # [Add answer story 4.6] # It shows all the answers that are saved in the database. # Parameters: - # @answers:previous answer that are saved in the database. - # Return : none + # @answers:previous answers that are saved in the database. + # @problem:problem to which the current answer is added. + # Returns : none # Author: Nadine Adel def index + @problem =Problem.find_by_id(params[:id]) @answers = ModelAnswer.all end # [Add answer story 4.6] # It requires the attributes from the form that we are interested in. # Parameters: - # @answer:the answer that the user wants to add. + # None # Return : none # Author: Nadine Adel private def post_params - params.require(:model_answer).permit(:answer, :problem_id) + params.require(:model_answer).permit(:title,:answer,:problem_id) end + + end \ No newline at end of file diff --git a/tutor/app/views/model_answers/_new.html.erb b/tutor/app/views/model_answers/_new.html.erb deleted file mode 100644 index c2f3721f..00000000 --- a/tutor/app/views/model_answers/_new.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -<%= form_for :model_answer, url: model_answers_path do |f| %> -

    Previous Answers

    - - <% @answers.each do |answer1| %> -
    - - - - <% end %> -
    <%= answer1.answer %>
    -

    -

    Please Insert your model answer

    - <%= f.text_area :answer %> - <%= f.hidden_field :problem_id, value: params[:id] %> -

    -

    - <%= f.submit %> -

    -<% end %> \ No newline at end of file diff --git a/tutor/app/views/model_answers/new.html.erb b/tutor/app/views/model_answers/new.html.erb new file mode 100644 index 00000000..f1003869 --- /dev/null +++ b/tutor/app/views/model_answers/new.html.erb @@ -0,0 +1,37 @@ + +<%= form_for :model_answer, url: model_answers_path do |f| %> + +<% if @new_answer.errors.any? %> +
    +

    <%= pluralize(@new_answer.errors.count, "error") %> prohibited this course from being saved:

    +
      + <% @new_answer.errors.full_messages.each do |msg| %> +
    • <%= msg %>
    • + <% end %> +
    +
    +<% else %> +<%= f.hidden_field :problem_id, :value => @problem.id %> + +<% end %> + + +
    + +

    +

    Please Insert your model answer

    +
    <%= f.label :Title %> + <%= f.text_field :title %>
    +
    <%= f.label :Answer %>
    + <%= f.text_area :answer,:cols => "50", :rows => "15" %> + +

    +
    + <%= f.submit "Save Model Answer", class: "btn btn-large btn-primary" %> +
    +

    +<% end %> + \ No newline at end of file diff --git a/tutor/app/views/problems/edit.html.erb b/tutor/app/views/problems/edit.html.erb index 61b4f592..030dbe1a 100644 --- a/tutor/app/views/problems/edit.html.erb +++ b/tutor/app/views/problems/edit.html.erb @@ -4,7 +4,7 @@ and a paragraph to view the problem description of the instance variable @proble

    <%= @problem.title %>

    <%= @problem.description %>

    <%= render partial: "test_cases/index" %> -<%= render partial: "model_answers/new" %> +<%= render partial: "model_answers/index" %> <% if flash[:notice] %>
    <%= flash[:notice] %>
    From ec29045aeaf9b9924f45cb28f147afbd28efb621 Mon Sep 17 00:00:00 2001 From: Nadine Adel Date: Wed, 23 Apr 2014 02:47:18 +0200 Subject: [PATCH 247/526] Issue #183 editing view index --- tutor/app/views/model_answers/index.html.erb | 70 +++++++++++++++----- 1 file changed, 55 insertions(+), 15 deletions(-) diff --git a/tutor/app/views/model_answers/index.html.erb b/tutor/app/views/model_answers/index.html.erb index 6a016e67..ead62f8c 100644 --- a/tutor/app/views/model_answers/index.html.erb +++ b/tutor/app/views/model_answers/index.html.erb @@ -1,15 +1,55 @@ -

    Previous Answers

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

    +
    + Previous Answers +
    + + + + \ No newline at end of file From bac43aa1d13971fefac74cd3697e97cbda27388c Mon Sep 17 00:00:00 2001 From: Nadine Adel Date: Wed, 23 Apr 2014 02:48:18 +0200 Subject: [PATCH 248/526] Issue #183 adding edit view --- tutor/app/views/model_answers/edit.html.erb | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tutor/app/views/model_answers/edit.html.erb diff --git a/tutor/app/views/model_answers/edit.html.erb b/tutor/app/views/model_answers/edit.html.erb new file mode 100644 index 00000000..821d8507 --- /dev/null +++ b/tutor/app/views/model_answers/edit.html.erb @@ -0,0 +1,38 @@ +<% provide(:title, "Edit Answer") %> +<%if session[:errorsupdate] %> +

    Model Answer can't be updated

    +
      + <% session[:errorsupdate].each do |msg| %> +
    • + <%= msg %> +
    • + <% end %> + + +
    + <% end %> +<%= form_for(@answer) do |f| %> + + + +<%= flash[:notice]%> +
    <%= f.label :Title %> + <%= f.text_field :title %>
    +
    <%= f.label :Answer %>
    + +

    <%= f.text_area :answer,:cols => "50", :rows => "15" %>

    + + <%= f.submit "Save changes", class: "btn btn-large btn-primary" %> + +
    <%= render partial: "tips/index" %>
    +
    <%= render partial: "hints/index" %>
    + + + + +<%end%> + \ No newline at end of file From 06a89e9d6b89de69088240e77f9ab6139215cad1 Mon Sep 17 00:00:00 2001 From: Nadine Adel Date: Wed, 23 Apr 2014 03:04:16 +0200 Subject: [PATCH 249/526] Issue #183 failure demos --- .../controllers/model_answers_controller.rb | 12 +++++----- tutor/app/models/model_answer.rb | 5 ++-- tutor/app/views/hints/_index.html.erb | 1 + .../{index.html.erb => _index.html.erb} | 0 tutor/app/views/model_answers/edit.html.erb | 24 ++++++++++--------- tutor/app/views/tips/_index.html.erb | 1 + 6 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 tutor/app/views/hints/_index.html.erb rename tutor/app/views/model_answers/{index.html.erb => _index.html.erb} (100%) create mode 100644 tutor/app/views/tips/_index.html.erb diff --git a/tutor/app/controllers/model_answers_controller.rb b/tutor/app/controllers/model_answers_controller.rb index f8b0349e..45a0c152 100644 --- a/tutor/app/controllers/model_answers_controller.rb +++ b/tutor/app/controllers/model_answers_controller.rb @@ -61,12 +61,12 @@ def create # Author: Nadine Adel def edit - @answer = ModelAnswer.find(params[:id]) - @problem = Problem.find(@answer.problem_id) - @tips = @answer.hints - @tips_check = @answer.hints - @hints = @answer.hints - @hints_check = @answer.hints + @new_answer = ModelAnswer.find(params[:id]) + @problem = Problem.find(@new_answer.problem_id) + @tips = @new_answer.hints + @tips_check = @new_answer.hints + @hints = @new_answer.hints + @hints_check = @new_answer.hints end # [Edit answer story 4.7] diff --git a/tutor/app/models/model_answer.rb b/tutor/app/models/model_answer.rb index 7297f7fb..cc7aebdd 100644 --- a/tutor/app/models/model_answer.rb +++ b/tutor/app/models/model_answer.rb @@ -1,8 +1,9 @@ class ModelAnswer < ActiveRecord::Base #Validations - validates :answer , :presence => true - validates :answer , :length => { :minimum => 1 } + validates :title , presence: true,:length => { :minimum => 1 } + + validates :answer , presence: true, :length => { :minimum => 1 } #Relations belongs_to :problem diff --git a/tutor/app/views/hints/_index.html.erb b/tutor/app/views/hints/_index.html.erb new file mode 100644 index 00000000..c0041d37 --- /dev/null +++ b/tutor/app/views/hints/_index.html.erb @@ -0,0 +1 @@ +

    prev hints

    \ No newline at end of file diff --git a/tutor/app/views/model_answers/index.html.erb b/tutor/app/views/model_answers/_index.html.erb similarity index 100% rename from tutor/app/views/model_answers/index.html.erb rename to tutor/app/views/model_answers/_index.html.erb diff --git a/tutor/app/views/model_answers/edit.html.erb b/tutor/app/views/model_answers/edit.html.erb index 821d8507..805c5a9a 100644 --- a/tutor/app/views/model_answers/edit.html.erb +++ b/tutor/app/views/model_answers/edit.html.erb @@ -1,18 +1,20 @@ <% provide(:title, "Edit Answer") %> -<%if session[:errorsupdate] %> -

    Model Answer can't be updated

    + +<%= form_for(@new_answer) do |f| %> +<% if @new_answer.errors.any? %> +
    +

    <%= pluralize(@new_answer.errors.count, "error") %> prohibited this course from being saved:

      - <% session[:errorsupdate].each do |msg| %> -
    • - <%= msg %> -
    • + <% @new_answer.errors.full_messages.each do |msg| %> +
    • <%= msg %>
    • <% end %> - -
    - <% end %> -<%= form_for(@answer) do |f| %> -
    +<% else %> +<%= f.hidden_field :problem_id, :value => @problem.id %> + +<% end %> + diff --git a/tutor/app/views/tips/_index.html.erb b/tutor/app/views/tips/_index.html.erb new file mode 100644 index 00000000..81e94315 --- /dev/null +++ b/tutor/app/views/tips/_index.html.erb @@ -0,0 +1 @@ +

    prev tips

    \ No newline at end of file From b51b1441ac1143248f55422a54f7b67173dbd5f2 Mon Sep 17 00:00:00 2001 From: Khaled Date: Wed, 23 Apr 2014 03:09:52 +0200 Subject: [PATCH 250/526] Issue #143 Fixed bugs --- tutor/app/controllers/courses_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tutor/app/controllers/courses_controller.rb b/tutor/app/controllers/courses_controller.rb index f1361c05..75dd129a 100644 --- a/tutor/app/controllers/courses_controller.rb +++ b/tutor/app/controllers/courses_controller.rb @@ -151,7 +151,7 @@ def manage # Parameters: # params[:id]: The course id # params[:value]: The decision of the student whether to share his - # performance or not + # performance or not # Returns: none # Author: Khaled Helmy def share @@ -163,8 +163,7 @@ def share if result.share == value render ('public/404') else - result.share = value - result.save + result.update(share: value) redirect_to "/courses" end else From ca80748f6d1daf602b2a29d5bd46da682745950e Mon Sep 17 00:00:00 2001 From: Nadine Adel Date: Wed, 23 Apr 2014 03:10:37 +0200 Subject: [PATCH 251/526] Issue #183 Documentation and conventions --- .../controllers/model_answers_controller.rb | 4 +- tutor/app/models/model_answer.rb | 1 - tutor/app/views/model_answers/edit.html.erb | 56 ++++++++----------- tutor/app/views/model_answers/new.html.erb | 12 +--- 4 files changed, 27 insertions(+), 46 deletions(-) diff --git a/tutor/app/controllers/model_answers_controller.rb b/tutor/app/controllers/model_answers_controller.rb index 45a0c152..e9133397 100644 --- a/tutor/app/controllers/model_answers_controller.rb +++ b/tutor/app/controllers/model_answers_controller.rb @@ -119,7 +119,5 @@ def index private def post_params params.require(:model_answer).permit(:title,:answer,:problem_id) - end - - + end end \ No newline at end of file diff --git a/tutor/app/models/model_answer.rb b/tutor/app/models/model_answer.rb index cc7aebdd..921d0645 100644 --- a/tutor/app/models/model_answer.rb +++ b/tutor/app/models/model_answer.rb @@ -2,7 +2,6 @@ class ModelAnswer < ActiveRecord::Base #Validations validates :title , presence: true,:length => { :minimum => 1 } - validates :answer , presence: true, :length => { :minimum => 1 } #Relations diff --git a/tutor/app/views/model_answers/edit.html.erb b/tutor/app/views/model_answers/edit.html.erb index 805c5a9a..6fc0dd7e 100644 --- a/tutor/app/views/model_answers/edit.html.erb +++ b/tutor/app/views/model_answers/edit.html.erb @@ -1,39 +1,29 @@ <% provide(:title, "Edit Answer") %> - <%= form_for(@new_answer) do |f| %> -<% if @new_answer.errors.any? %> -
    -

    <%= pluralize(@new_answer.errors.count, "error") %> prohibited this course from being saved:

    -
      - <% @new_answer.errors.full_messages.each do |msg| %> -
    • <%= msg %>
    • - <% end %> -
    -
    -<% else %> -<%= f.hidden_field :problem_id, :value => @problem.id %> - -<% end %> - - - -<%= flash[:notice]%> -
    <%= f.label :Title %> - <%= f.text_field :title %>
    -
    <%= f.label :Answer %>
    - -

    <%= f.text_area :answer,:cols => "50", :rows => "15" %>

    - - <%= f.submit "Save changes", class: "btn btn-large btn-primary" %> - -
    <%= render partial: "tips/index" %>
    -
    <%= render partial: "hints/index" %>
    - - - - + <% if @new_answer.errors.any? %> +
    +

    <%= pluralize(@new_answer.errors.count, "error") %> prohibited this course from being saved:

    +
      + <% @new_answer.errors.full_messages.each do |msg| %> +
    • <%= msg %>
    • + <% end %> +
    +
    + <% else %> + <%= f.hidden_field :problem_id, :value => @problem.id %> + <% end %> + + <%= flash[:notice]%> +
    <%= f.label :Title %> + <%= f.text_field :title %>
    +
    <%= f.label :Answer %>
    +

    <%= f.text_area :answer,:cols => "50", :rows => "15" %>

    + <%= f.submit "Save changes", class: "btn btn-large btn-primary" %> +
    <%= render partial: "tips/index" %>
    +
    <%= render partial: "hints/index" %>
    <%end%> + \ No newline at end of file diff --git a/tutor/app/views/model_answers/edit.html.erb b/tutor/app/views/model_answers/edit.html.erb index d5ab214b..49848019 100644 --- a/tutor/app/views/model_answers/edit.html.erb +++ b/tutor/app/views/model_answers/edit.html.erb @@ -12,7 +12,8 @@ <% else %> <%= f.hidden_field :problem_id, :value => @problem.id %> <% end %> -

    Previous Answers @@ -26,21 +26,22 @@ Title - Created At - Updated At - View or Edit + Created At + Updated At + View/Edit Remove <% @answers.each do |answer1| %> - <%= answer1.title %> + <%= answer1.title %> <%= answer1.created_at %> <%= answer1.updated_at %> - <%= link_to "View or Edit", {:controller => 'model_answers', - :action => 'edit', :method => :get, :id => answer1.id }, - {class: 'btn btn-primary btn-xs',style: "text-decoration:none"} %> + <%= link_to "View/Edit", {:controller => 'model_answers', + :action => 'edit', :method => :get, :id => answer1.id}, + {class: 'btn btn-primary btn-xs', + style: "text-decoration:none"} %> Delete diff --git a/tutor/app/views/model_answers/edit.html.erb b/tutor/app/views/model_answers/edit.html.erb index 49848019..3dc1f15b 100644 --- a/tutor/app/views/model_answers/edit.html.erb +++ b/tutor/app/views/model_answers/edit.html.erb @@ -15,15 +15,15 @@ - <%= flash[:notice]%> + <%= flash[:notice] %>
    <%= f.label :Title %> <%= f.text_field :title %>

    <%= f.label :Answer %>
    -

    <%= f.text_area :answer,:cols => "50", :rows => "15" %>

    +

    <%= f.text_area :answer, :cols => "50", :rows => "15" %>

    <%= f.submit "Save changes", class: "btn btn-large btn-primary" %>
    <%= render partial: "tips/index" %>

    <%= render partial: "hints/index" %>
    -<%end%> +<% end %> \ No newline at end of file +
    \ No newline at end of file diff --git a/tutor/app/views/model_answers/edit.html.erb b/tutor/app/views/model_answers/edit.html.erb index 3dc1f15b..eb62322c 100644 --- a/tutor/app/views/model_answers/edit.html.erb +++ b/tutor/app/views/model_answers/edit.html.erb @@ -23,9 +23,4 @@ <%= f.submit "Save changes", class: "btn btn-large btn-primary" %>
    <%= render partial: "tips/index" %>

    <%= render partial: "hints/index" %>
    -<% end %> - - \ No newline at end of file +<% end %> \ No newline at end of file diff --git a/tutor/app/views/model_answers/new.html.erb b/tutor/app/views/model_answers/new.html.erb index 0bcd67bb..34c3071e 100644 --- a/tutor/app/views/model_answers/new.html.erb +++ b/tutor/app/views/model_answers/new.html.erb @@ -1,4 +1,4 @@ -<%= form_for :model_answer, url: model_answers_path do |f| %> +<%= form_for :model_answer, url: model_answers_path do |f| %> <% if @new_answer.errors.any? %>

    <%= pluralize(@new_answer.errors.count, "error") %> prohibited this course from being saved: @@ -24,7 +24,3 @@


    <% end %> - \ No newline at end of file From 2a56087f18a643fd6129ad518643b915cbf5c90f Mon Sep 17 00:00:00 2001 From: AbdullRahman ElHusseini Date: Thu, 24 Apr 2014 14:01:38 +0200 Subject: [PATCH 435/526] Issue #208 fixing wrong documentation in master --- tutor/app/views/tracks/show.html.erb | 46 ++++++++++++---------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/tutor/app/views/tracks/show.html.erb b/tutor/app/views/tracks/show.html.erb index bfa9fa20..1ac3eb72 100644 --- a/tutor/app/views/tracks/show.html.erb +++ b/tutor/app/views/tracks/show.html.erb @@ -30,19 +30,16 @@
    - - <%= link_to problem.title, problem , style: 'color:#003366;' , - class: color %> - - <% if student_signed_in? %> -
    - Recommend to classmates
    - <% end %> -
    - - + + <%= link_to problem.title, problem , style: 'color:#003366;' , + class: color %> + + <% if student_signed_in? %> +
    + Recommend to classmates
    + <% end %> +
    <%= problem.description %> @@ -67,19 +64,16 @@
    - - <%= link_to problem.title, problem , style: 'color:#003366;' , - class: color %> - - <% if student_signed_in? %> -
    - Recommend to classmates
    - <% end %> -
    - - + + <%= link_to problem.title, problem , style: 'color:#003366;' , + class: color %> + + <% if student_signed_in? %> +
    + Recommend to classmates
    + <% end %> +
    <%= problem.description %> From 4407e62dcc339ebf6551387bb42533c77aea2e03 Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Thu, 24 Apr 2014 14:04:06 +0200 Subject: [PATCH 436/526] updating long line --- tutor/app/controllers/courses_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tutor/app/controllers/courses_controller.rb b/tutor/app/controllers/courses_controller.rb index 8617e550..b0145f59 100644 --- a/tutor/app/controllers/courses_controller.rb +++ b/tutor/app/controllers/courses_controller.rb @@ -192,7 +192,8 @@ def share student_id = current_student.id course_id = params[:id] value = to_boolean params[:value] - result = CourseStudent.where("student_id = ? AND course_id = ?", student_id, course_id)[0] + result = CourseStudent.where("student_id = ? AND course_id = ?", + student_id, course_id)[0] if result.share == value render ('public/404') else @@ -224,7 +225,8 @@ def find_state courses puts student_id courses.each do |c| course_id = c.id - result = CourseStudent.where("student_id = ? AND course_id = ?", student_id, course_id)[0] + result = CourseStudent.where("student_id = ? AND course_id = ?", + student_id, course_id)[0] if result.share == false states[result.course_id] = "Show" else From a0735042e32752fc4d2d1f00314591305d3c6aa1 Mon Sep 17 00:00:00 2001 From: MussabElDash Date: Thu, 24 Apr 2014 14:05:08 +0200 Subject: [PATCH 437/526] #250 Support Args and Killing process --- tutor/app/models/debugger.rb | 10 ++++++++-- tutor/config/routes.rb | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tutor/app/models/debugger.rb b/tutor/app/models/debugger.rb index 94cb0e29..7b71e5a8 100644 --- a/tutor/app/models/debugger.rb +++ b/tutor/app/models/debugger.rb @@ -64,7 +64,7 @@ def start(class_name, input) $all = [] Dir.chdir(Solution::CLASS_PATH){ begin - $input, $output, $error, $wait_thread = Open3.popen3("jdb", class_name, input) + $input, $output, $error, $wait_thread = Open3.popen3("jdb", class_name, *input) buffer_until_ready input "stop in #{class_name}.main" buffer_until_ready @@ -76,10 +76,16 @@ def start(class_name, input) debug rescue => e unless e.message === 'Exited' + p e.message return false end end } + begin + Process.kill("TERM", $wait_thread.pid) + rescue => e + p e.message + end return $all end @@ -149,7 +155,7 @@ def self.debug(student_id, problem_id, code, input) end debugger = Debugger.new class_name = solution.class_file_name - debugging = debugger.start(class_name, input) + debugging = debugger.start(class_name, input.split(" ")) p debugging java_file = solution.java_file_name true, true class_file = solution.class_file_name true, true diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index 940a3b91..af55c15c 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -31,7 +31,6 @@ resources :courses resources :test_cases resources :model_answers - resources :problems_by_tas resources :solutions resources :problems resources :topics From 821279fc608da5e2f776eabb1fbdf8e6cd9a56e6 Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Thu, 24 Apr 2014 14:06:14 +0200 Subject: [PATCH 438/526] changing long lines --- tutor/app/views/courses/index.html.erb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tutor/app/views/courses/index.html.erb b/tutor/app/views/courses/index.html.erb index adde3e3f..5ebcfb61 100644 --- a/tutor/app/views/courses/index.html.erb +++ b/tutor/app/views/courses/index.html.erb @@ -25,18 +25,22 @@ <%= c.code %> <% if current_lecturer %> - <%= link_to "Manage Course", { :controller => 'courses', :action => 'edit', :method => :get, :id => c.id }, class: "btn btn-success", style: "text-decoration:none" %> + <%= link_to "Manage Course", { :controller => 'courses', :action => 'edit', + :method => :get, :id => c.id }, class: "btn btn-success", style: "text-decoration:none" %> <% end %> - <%= link_to "Discussion Board", { :controller => 'discussion_boards', :action => 'show', :id => c.id }, class: "btn btn-success", method: :get, style: "text-decoration:none" %> + <%= link_to "Discussion Board", { :controller => 'discussion_boards', :action => 'show', :id => c.id }, + class: "btn btn-success", method: :get, style: "text-decoration:none" %> <% if current_student %> <% if @share[c.id] == "Show" %> - <%= button_to "Show Performance", {:controller => 'courses', :action => 'share', :id => c.id, :value => true}, class: "btn btn-success", style: "text-decoration:none" %> + <%= button_to "Show Performance", {:controller => 'courses', :action => 'share', + :id => c.id, :value => true}, class: "btn btn-success", style: "text-decoration:none" %> <% else %> - <%= button_to "Hide Performance", {:controller => 'courses', :action => 'share', :id => c.id, :value => false}, class: "btn btn-success", style: "text-decoration:none" %> + <%= button_to "Hide Performance", {:controller => 'courses', :action => 'share', + :id => c.id, :value => false}, class: "btn btn-success", style: "text-decoration:none" %> <% end %> <% end %> From fcd1123b8aba0bbe6f00096efdfae5a7f3412228 Mon Sep 17 00:00:00 2001 From: Ahmed ELAssuty Date: Thu, 24 Apr 2014 14:29:16 +0200 Subject: [PATCH 439/526] Issue #223 fix conflict --- tutor/app/views/layouts/_footer.html.erb | 2 +- .../views/layouts/_right_side_bar.html.erb | 96 ++++++++++--------- tutor/app/views/layouts/application.html.erb | 4 +- tutor/vendor/assets/stylesheets/bootstrap.css | 10 +- 4 files changed, 59 insertions(+), 53 deletions(-) diff --git a/tutor/app/views/layouts/_footer.html.erb b/tutor/app/views/layouts/_footer.html.erb index 48c4c7bb..b26c482f 100644 --- a/tutor/app/views/layouts/_footer.html.erb +++ b/tutor/app/views/layouts/_footer.html.erb @@ -3,7 +3,7 @@ # General layout for footer # Author: Ahmed Elassuty --> -
    +
    <%= link_to "About us"%> diff --git a/tutor/app/views/layouts/_right_side_bar.html.erb b/tutor/app/views/layouts/_right_side_bar.html.erb index 8b03a53f..0ace203e 100644 --- a/tutor/app/views/layouts/_right_side_bar.html.erb +++ b/tutor/app/views/layouts/_right_side_bar.html.erb @@ -3,55 +3,61 @@ # General layout for right side bar # Author: Ahmed Elassuty --> -

    -
    +
    <% if signed_in? %>
    <%= render "layouts/right_side_bar"%> @@ -55,7 +55,7 @@
    <% else %> -
    +
    <%= yield %>
    <% end %> diff --git a/tutor/vendor/assets/stylesheets/bootstrap.css b/tutor/vendor/assets/stylesheets/bootstrap.css index 75fcf62b..338f20c3 100644 --- a/tutor/vendor/assets/stylesheets/bootstrap.css +++ b/tutor/vendor/assets/stylesheets/bootstrap.css @@ -3639,7 +3639,7 @@ select[multiple].input-group-sm > .input-group-btn > .btn { } .navbar { position: relative; - min-height: 60px; + min-height: 50px; border: 1px solid transparent; } @media (min-width: 768px) { @@ -3935,7 +3935,7 @@ select[multiple].input-group-sm > .input-group-btn > .btn { } } .navbar-default { - background-color: #2c3e50; + background-color: #333333; border-color: transparent; } .navbar-default .navbar-brand { @@ -4057,10 +4057,10 @@ select[multiple].input-group-sm > .input-group-btn > .btn { } .navbar-inverse .navbar-toggle:hover, .navbar-inverse .navbar-toggle:focus { - background-color: #128f76; + background-color: #333333; } .navbar-inverse .navbar-toggle .icon-bar { - background-color: #ffffff; + background-color: #333333; } .navbar-inverse .navbar-collapse, .navbar-inverse .navbar-form { @@ -4084,7 +4084,7 @@ select[multiple].input-group-sm > .input-group-btn > .btn { } .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover, .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus { - color: #2c3e50; + color: #333333; background-color: transparent; } .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a, From d1e49f26598477fa1e94b8eeca6fe0855285cc55 Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Thu, 24 Apr 2014 14:29:34 +0200 Subject: [PATCH 440/526] fixing indentation --- tutor/app/views/courses/index.html.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutor/app/views/courses/index.html.erb b/tutor/app/views/courses/index.html.erb index 5ebcfb61..fed8b5f7 100644 --- a/tutor/app/views/courses/index.html.erb +++ b/tutor/app/views/courses/index.html.erb @@ -26,21 +26,21 @@ <% if current_lecturer %> <%= link_to "Manage Course", { :controller => 'courses', :action => 'edit', - :method => :get, :id => c.id }, class: "btn btn-success", style: "text-decoration:none" %> + :method => :get, :id => c.id }, class: "btn btn-success", style: "text-decoration:none" %> <% end %> <%= link_to "Discussion Board", { :controller => 'discussion_boards', :action => 'show', :id => c.id }, - class: "btn btn-success", method: :get, style: "text-decoration:none" %> + class: "btn btn-success", method: :get, style: "text-decoration:none" %> <% if current_student %> <% if @share[c.id] == "Show" %> <%= button_to "Show Performance", {:controller => 'courses', :action => 'share', - :id => c.id, :value => true}, class: "btn btn-success", style: "text-decoration:none" %> + :id => c.id, :value => true}, class: "btn btn-success", style: "text-decoration:none" %> <% else %> <%= button_to "Hide Performance", {:controller => 'courses', :action => 'share', - :id => c.id, :value => false}, class: "btn btn-success", style: "text-decoration:none" %> + :id => c.id, :value => false}, class: "btn btn-success", style: "text-decoration:none" %> <% end %> <% end %> From 20ad071a24c8b64776cd02b1a39fac8e703467f9 Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Thu, 24 Apr 2014 14:34:51 +0200 Subject: [PATCH 441/526] fixing indentation --- tutor/app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/controllers/courses_controller.rb b/tutor/app/controllers/courses_controller.rb index b0145f59..cc7d0a11 100644 --- a/tutor/app/controllers/courses_controller.rb +++ b/tutor/app/controllers/courses_controller.rb @@ -193,7 +193,7 @@ def share course_id = params[:id] value = to_boolean params[:value] result = CourseStudent.where("student_id = ? AND course_id = ?", - student_id, course_id)[0] + student_id, course_id)[0] if result.share == value render ('public/404') else From 003c7cd25a35eff6dc6696b341333cf7fb825633 Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Thu, 24 Apr 2014 14:35:27 +0200 Subject: [PATCH 442/526] fixing indentation --- tutor/app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/controllers/courses_controller.rb b/tutor/app/controllers/courses_controller.rb index cc7d0a11..e78b3e9a 100644 --- a/tutor/app/controllers/courses_controller.rb +++ b/tutor/app/controllers/courses_controller.rb @@ -226,7 +226,7 @@ def find_state courses courses.each do |c| course_id = c.id result = CourseStudent.where("student_id = ? AND course_id = ?", - student_id, course_id)[0] + student_id, course_id)[0] if result.share == false states[result.course_id] = "Show" else From af752f9bd6168efd25e62daadb1b67bc0c5225c5 Mon Sep 17 00:00:00 2001 From: serag Date: Thu, 24 Apr 2014 14:41:55 +0200 Subject: [PATCH 443/526] Issue #206 fixed descriptivity and indentation --- tutor/app/assets/javascripts/lecturers.js | 4 ++-- tutor/app/assets/javascripts/students.js | 4 ++-- .../app/assets/javascripts/teaching_assistants.js | 4 ++-- tutor/app/views/lecturers/show.html.erb | 14 +++++++------- tutor/app/views/students/show.html.erb | 14 +++++++------- tutor/app/views/teaching_assistants/show.html.erb | 14 ++++++++------ 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/tutor/app/assets/javascripts/lecturers.js b/tutor/app/assets/javascripts/lecturers.js index 974a8030..5857b2e3 100644 --- a/tutor/app/assets/javascripts/lecturers.js +++ b/tutor/app/assets/javascripts/lecturers.js @@ -1,5 +1,5 @@ $(document).ready(function() { - $('.tabs .tab-links a').on('click', function(e) { + $('.tabs .tab-links a').on('click', function(element) { var currentAttrValue = $(this).attr('href'); // Show/Hide Tabs $('.tabs ' + currentAttrValue).siblings().slideUp(400); @@ -8,6 +8,6 @@ $(document).ready(function() { //$('.tabs ' + currentAttrValue).fadeIn(400).siblings().hide(); // Change/remove current tab to active $(this).parent('li').addClass('active').siblings().removeClass('active'); - e.preventDefault(); + element.preventDefault(); }); }); \ No newline at end of file diff --git a/tutor/app/assets/javascripts/students.js b/tutor/app/assets/javascripts/students.js index 974a8030..5857b2e3 100644 --- a/tutor/app/assets/javascripts/students.js +++ b/tutor/app/assets/javascripts/students.js @@ -1,5 +1,5 @@ $(document).ready(function() { - $('.tabs .tab-links a').on('click', function(e) { + $('.tabs .tab-links a').on('click', function(element) { var currentAttrValue = $(this).attr('href'); // Show/Hide Tabs $('.tabs ' + currentAttrValue).siblings().slideUp(400); @@ -8,6 +8,6 @@ $(document).ready(function() { //$('.tabs ' + currentAttrValue).fadeIn(400).siblings().hide(); // Change/remove current tab to active $(this).parent('li').addClass('active').siblings().removeClass('active'); - e.preventDefault(); + element.preventDefault(); }); }); \ No newline at end of file diff --git a/tutor/app/assets/javascripts/teaching_assistants.js b/tutor/app/assets/javascripts/teaching_assistants.js index 974a8030..5857b2e3 100644 --- a/tutor/app/assets/javascripts/teaching_assistants.js +++ b/tutor/app/assets/javascripts/teaching_assistants.js @@ -1,5 +1,5 @@ $(document).ready(function() { - $('.tabs .tab-links a').on('click', function(e) { + $('.tabs .tab-links a').on('click', function(element) { var currentAttrValue = $(this).attr('href'); // Show/Hide Tabs $('.tabs ' + currentAttrValue).siblings().slideUp(400); @@ -8,6 +8,6 @@ $(document).ready(function() { //$('.tabs ' + currentAttrValue).fadeIn(400).siblings().hide(); // Change/remove current tab to active $(this).parent('li').addClass('active').siblings().removeClass('active'); - e.preventDefault(); + element.preventDefault(); }); }); \ No newline at end of file diff --git a/tutor/app/views/lecturers/show.html.erb b/tutor/app/views/lecturers/show.html.erb index 19230bc4..456e3b28 100644 --- a/tutor/app/views/lecturers/show.html.erb +++ b/tutor/app/views/lecturers/show.html.erb @@ -16,16 +16,16 @@ Options - <% @courses.each do |c| %> + <% @courses.each do |course| %> - <%= link_to c.name, + <%= link_to course.name, :controller => 'courses', :action => 'show', - :id => c.id, :method => :get, + :id => course.id, :method => :get, class: "btn btn-success" %> - <%= c.code %> + <%= course.code %> <% if current_lecturer %> <%= link_to "Manage Course", @@ -33,7 +33,7 @@ :controller => 'courses', :action => 'edit', :method => :get, - :id => c.id + :id => course.id }, class: "btn btn-success", style: "text-decoration:none" %> @@ -44,8 +44,8 @@ { :controller => 'discussion_boards', :action => 'show', - :id => c.id - }, + :id => course.id + }, class: "btn btn-success", method: :get, style: "text-decoration:none" %> diff --git a/tutor/app/views/students/show.html.erb b/tutor/app/views/students/show.html.erb index 60bd3a65..075b0dee 100644 --- a/tutor/app/views/students/show.html.erb +++ b/tutor/app/views/students/show.html.erb @@ -17,17 +17,17 @@ Options - <% @courses.each do |c| %> + <% @courses.each do |course| %> - <%= link_to c.name, + <%= link_to course.name, :controller => 'courses', :action => 'show', - :id => c.id, + :id => course.id, :method => :get, class: "btn btn-success" %> - <%= c.code %> + <%= course.code %> <% if current_lecturer %> <%= link_to "Manage Course", @@ -35,7 +35,7 @@ :controller => 'courses', :action => 'edit', :method => :get, - :id => c.id + :id => course.id }, class: "btn btn-success", style: "text-decoration:none" %> @@ -46,8 +46,8 @@ { :controller => 'discussion_boards', :action => 'show', - :id => c.id - }, + :id => course.id + }, class: "btn btn-success", method: :get, style: "text-decoration:none" %> diff --git a/tutor/app/views/teaching_assistants/show.html.erb b/tutor/app/views/teaching_assistants/show.html.erb index edfda86c..ddeae09a 100644 --- a/tutor/app/views/teaching_assistants/show.html.erb +++ b/tutor/app/views/teaching_assistants/show.html.erb @@ -16,23 +16,24 @@ Options - <% @courses.each do |c| %> + <% @courses.each do |course| %> - <%= link_to c.name, + <%= link_to course.name, :controller => 'courses', - :action => 'show', :id => c.id, + :action => 'show', :id => course.id, :method => :get, class: "btn btn-success" %> - <%= c.code %> + <%= course.code %> <% if current_lecturer %> <%= link_to "Manage Course", { :controller => 'courses', :action => 'edit', - :method => :get, :id => c.id + :method => :get, + :id => course.id }, class: "btn btn-success", style: "text-decoration:none" %> @@ -42,7 +43,8 @@ <%= link_to "Discussion Board", { :controller => 'discussion_boards', - :action => 'show', :id => c.id + :action => 'show', + :id => course.id }, class: "btn btn-success", method: :get, From 7089dbec0e5c71b124631474614aee06f6b3a9ef Mon Sep 17 00:00:00 2001 From: Ahmed ELAssuty Date: Thu, 24 Apr 2014 14:49:49 +0200 Subject: [PATCH 444/526] Issue #223 fix conventions --- tutor/app/models/lecturer.rb | 1 + tutor/app/models/student.rb | 6 ++---- tutor/app/models/teaching_assistant.rb | 6 ++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tutor/app/models/lecturer.rb b/tutor/app/models/lecturer.rb index b7474fd4..53473ce1 100644 --- a/tutor/app/models/lecturer.rb +++ b/tutor/app/models/lecturer.rb @@ -1,4 +1,5 @@ class Lecturer < ActiveRecord::Base + devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index 801caabb..38ce5564 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -1,9 +1,7 @@ class Student < ActiveRecord::Base - # Include default devise modules. Others available are: - # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, - :recoverable, :rememberable, :trackable, :validatable + :recoverable, :rememberable, :trackable, :validatable #Elasticsearch include Tire::Model::Search @@ -198,4 +196,4 @@ def self.send_reminder_mails end end -end +end \ No newline at end of file diff --git a/tutor/app/models/teaching_assistant.rb b/tutor/app/models/teaching_assistant.rb index f29e28a7..c8718069 100644 --- a/tutor/app/models/teaching_assistant.rb +++ b/tutor/app/models/teaching_assistant.rb @@ -1,7 +1,7 @@ class TeachingAssistant < ActiveRecord::Base devise :database_authenticatable, :registerable, - :recoverable, :rememberable, :trackable, - :validatable, :confirmable + :recoverable, :rememberable, :trackable, + :validatable, :confirmable #Elasticsearch include Tire::Model::Search @@ -43,8 +43,6 @@ class TeachingAssistant < ActiveRecord::Base has_many :test_cases, as: :owner has_many :hints, as: :owner - #Scoops - #Methods # [Advanced Search - Story 1.23] From af496edd56e84fcdea0e6bbad512ed0d34149176 Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Thu, 24 Apr 2014 15:06:18 +0200 Subject: [PATCH 445/526] fixed course editing vulnerabilities --- tutor/app/controllers/acknowledgements_controller.rb | 4 ++++ tutor/app/controllers/courses_controller.rb | 3 +++ tutor/app/controllers/teaching_assistants_controller.rb | 4 ++++ tutor/app/controllers/topics_controller.rb | 3 +++ 4 files changed, 14 insertions(+) diff --git a/tutor/app/controllers/acknowledgements_controller.rb b/tutor/app/controllers/acknowledgements_controller.rb index f363a62d..76c60a4c 100644 --- a/tutor/app/controllers/acknowledgements_controller.rb +++ b/tutor/app/controllers/acknowledgements_controller.rb @@ -8,6 +8,10 @@ class AcknowledgementsController < ApplicationController # Author: Muhammad Mamdouh def new @course = Course.find(params[:course_id]) + if !@course.can_edit(current_lecturer) + redirect_to :root + end + end # [Student Acknowledgement - Story 1.7] diff --git a/tutor/app/controllers/courses_controller.rb b/tutor/app/controllers/courses_controller.rb index e78b3e9a..244b1f72 100644 --- a/tutor/app/controllers/courses_controller.rb +++ b/tutor/app/controllers/courses_controller.rb @@ -135,6 +135,9 @@ def create # Author: Mohamed Mamdouh def edit @course = Course.find_by_id(params[:id]) + if !@course.can_edit(current_lecturer) + redirect_to :root + end @discussionBoard = @course.discussion_board end diff --git a/tutor/app/controllers/teaching_assistants_controller.rb b/tutor/app/controllers/teaching_assistants_controller.rb index 602e80b0..82b5efd5 100644 --- a/tutor/app/controllers/teaching_assistants_controller.rb +++ b/tutor/app/controllers/teaching_assistants_controller.rb @@ -7,6 +7,10 @@ class TeachingAssistantsController < ApplicationController # Returns: None # Author: Muhammad Mamdouh def new + @course = Course.find_by_id(params[:course_id]) + if !@course.can_edit(current_lecturer) + redirect_to :root + end if @checkbox == nil @checkbox = true end diff --git a/tutor/app/controllers/topics_controller.rb b/tutor/app/controllers/topics_controller.rb index e42b836a..51504a49 100644 --- a/tutor/app/controllers/topics_controller.rb +++ b/tutor/app/controllers/topics_controller.rb @@ -43,6 +43,9 @@ def show # Author: Ahmed Akram def new @course = Course.find(params[:course_id]) + if !@course.can_edit(current_lecturer) + redirect_to :root + end @new_topic = Topic.new end From ec867e56e36a2ded5881eef98580626556008cf4 Mon Sep 17 00:00:00 2001 From: Ahmed ELAssuty Date: Thu, 24 Apr 2014 15:10:16 +0200 Subject: [PATCH 446/526] Issue #223 fix conventions --- tutor/Gemfile | 4 ++-- tutor/app/models/lecturer.rb | 3 ++- tutor/app/views/layouts/_right_side_bar.html.erb | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tutor/Gemfile b/tutor/Gemfile index ada1df18..96d666af 100644 --- a/tutor/Gemfile +++ b/tutor/Gemfile @@ -59,7 +59,7 @@ gem 'composite_primary_keys', '~> 6.0.1' #search gem 'tire' -gem 'json_builder', '3.1.0' +gem 'json_builder', '3.1.0' # whenever gem for scheduling tasks -gem 'whenever', :require => false +gem 'whenever', :require => false \ No newline at end of file diff --git a/tutor/app/models/lecturer.rb b/tutor/app/models/lecturer.rb index 53473ce1..b26bbdf7 100644 --- a/tutor/app/models/lecturer.rb +++ b/tutor/app/models/lecturer.rb @@ -69,7 +69,8 @@ def self.search(params) query { string "name:*#{params[:keyword]}" } end end - + end + end # [User Authentication Advanced - Story 5.9, 5.10, 5.11, 5.14, 5.15] # Checks if the email is already registered in tables: Student and TeachingAssistant # before registering the email for table: Lecturer diff --git a/tutor/app/views/layouts/_right_side_bar.html.erb b/tutor/app/views/layouts/_right_side_bar.html.erb index 0ace203e..9f7b4b64 100644 --- a/tutor/app/views/layouts/_right_side_bar.html.erb +++ b/tutor/app/views/layouts/_right_side_bar.html.erb @@ -4,7 +4,7 @@ # Author: Ahmed Elassuty -->
    -
    \ No newline at end of file +
    From 8e67a01b7099ed22e8326b219aa000664f05c57b Mon Sep 17 00:00:00 2001 From: AbdullRahman ElHusseini Date: Thu, 24 Apr 2014 16:30:22 +0200 Subject: [PATCH 456/526] Issue #208 fixing extra lines --- tutor/app/controllers/problems_controller.rb | 3 ++- tutor/app/views/problems/_description.html.erb | 4 +--- tutor/app/views/problems/_title.html.erb | 2 -- tutor/app/views/problems/edit.html.erb | 7 ++----- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/tutor/app/controllers/problems_controller.rb b/tutor/app/controllers/problems_controller.rb index 7b868512..7cf1a145 100644 --- a/tutor/app/controllers/problems_controller.rb +++ b/tutor/app/controllers/problems_controller.rb @@ -136,7 +136,8 @@ def done @problem = Problem.find_by_id(params[:problem_id]) if @problem.model_answers.empty? || @problem.test_cases.empty? @failure = true - flash.keep[:notice] = "Problem is incomplete, please add necessary paramaters or save as incomplete" + flash.keep[:notice] = "Problem is incomplete, + please add necessary paramaters or save as incomplete" redirect_to :action => "edit", :id => @problem.id else @problem.incomplete = false diff --git a/tutor/app/views/problems/_description.html.erb b/tutor/app/views/problems/_description.html.erb index 82c252bd..4a3ea5f4 100644 --- a/tutor/app/views/problems/_description.html.erb +++ b/tutor/app/views/problems/_description.html.erb @@ -1,10 +1,8 @@

    <%= @problem.description %>

    <%= form_for :Problem, url: problem_path(@problem), method: :patch, remote: true do |problem| %> - <%= problem.text_area :description, :cols => "50", :rows => "10" %>

    - <%= problem.submit('update description') %> + <%= problem.submit('update description') %>

    <%= problem.hidden_field :title, value: @problem.title %> - <% end %> \ No newline at end of file diff --git a/tutor/app/views/problems/_title.html.erb b/tutor/app/views/problems/_title.html.erb index c3ed139a..f21b5c39 100644 --- a/tutor/app/views/problems/_title.html.erb +++ b/tutor/app/views/problems/_title.html.erb @@ -1,8 +1,6 @@

    <%= @problem.title %>

    <%= form_for :Problem, url: problem_path(@problem), method: :patch, remote: true do |problem| %> - <%= problem.text_field :title %> <%= problem.hidden_field :description, value: @problem.description %> <%= problem.submit('update title') %> - <% end %> \ No newline at end of file diff --git a/tutor/app/views/problems/edit.html.erb b/tutor/app/views/problems/edit.html.erb index 81980774..f3d5e0ad 100644 --- a/tutor/app/views/problems/edit.html.erb +++ b/tutor/app/views/problems/edit.html.erb @@ -7,23 +7,20 @@

    <%= @problem.title %>

    <%= form_for :Problem, url: problem_path(@problem), method: :patch, remote: true do |problem| %> - <%= problem.text_field :title %> <%= problem.hidden_field :description, value: @problem.description %> <%= problem.submit('update title') %> - <% end %>
    +

    <%= @problem.description %>

    <%= form_for :Problem, url: problem_path(@problem), method: :patch, remote: true do |problem| %> - <%= problem.text_area :description, :cols => "50", :rows => "10" %>

    - <%= problem.submit('update description') %> + <%= problem.submit('update description') %>

    <%= problem.hidden_field :title, value: @problem.title %> - <% end %>
    From 439d8364d7a997113cdea014ea147f1584d1ead8 Mon Sep 17 00:00:00 2001 From: Nadine Adel Date: Thu, 24 Apr 2014 16:34:15 +0200 Subject: [PATCH 457/526] Issue #183 Conventions4 --- .../app/assets/stylesheets/model_answers.css | 11 +++++---- tutor/app/views/hints/_index.html.erb | 2 +- tutor/app/views/model_answers/_index.html.erb | 24 +++++++++---------- tutor/app/views/model_answers/edit.html.erb | 4 ++-- tutor/app/views/model_answers/new.html.erb | 3 +-- tutor/app/views/tips/_index.html.erb | 2 +- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/tutor/app/assets/stylesheets/model_answers.css b/tutor/app/assets/stylesheets/model_answers.css index dab22f9f..435a38e9 100644 --- a/tutor/app/assets/stylesheets/model_answers.css +++ b/tutor/app/assets/stylesheets/model_answers.css @@ -1,9 +1,12 @@ -.red { color: #FF0000; } -.bold { font-weight: bold; } +.red { + color: #FF0000; +} +.bold { + font-weight: bold; +} a.Lst { font-size: 30px; line-height: 0px; padding-left: 0px; font-weight: normal; -} - +} \ No newline at end of file diff --git a/tutor/app/views/hints/_index.html.erb b/tutor/app/views/hints/_index.html.erb index c0041d37..5269492d 100644 --- a/tutor/app/views/hints/_index.html.erb +++ b/tutor/app/views/hints/_index.html.erb @@ -1 +1 @@ -

    prev hints

    \ No newline at end of file +

    Previous hints

    \ No newline at end of file diff --git a/tutor/app/views/model_answers/_index.html.erb b/tutor/app/views/model_answers/_index.html.erb index 08f1228e..573cdc00 100644 --- a/tutor/app/views/model_answers/_index.html.erb +++ b/tutor/app/views/model_answers/_index.html.erb @@ -2,16 +2,16 @@ -

    +


    Previous Answers @@ -33,8 +33,8 @@ - - <% @answers.each do |answer1| %> + <% @answers.each do |answer1| %> + <%= answer1.title %> <%= answer1.created_at %> <%= answer1.updated_at %> @@ -43,9 +43,9 @@ {class: 'btn btn-primary btn-xs', style: "text-decoration:none"} %> Delete - - - <% end %> + + <% end %> + <% end %> -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/tutor/app/views/model_answers/edit.html.erb b/tutor/app/views/model_answers/edit.html.erb index eb62322c..f4b123fa 100644 --- a/tutor/app/views/model_answers/edit.html.erb +++ b/tutor/app/views/model_answers/edit.html.erb @@ -21,6 +21,6 @@
    <%= f.label :Answer %>

    <%= f.text_area :answer, :cols => "50", :rows => "15" %>

    <%= f.submit "Save changes", class: "btn btn-large btn-primary" %> -
    <%= render partial: "tips/index" %>
    -
    <%= render partial: "hints/index" %>
    +
    <%= render partial: "tips/index" %>
    +
    <%= render partial: "hints/index" %>
    <% end %> \ No newline at end of file diff --git a/tutor/app/views/model_answers/new.html.erb b/tutor/app/views/model_answers/new.html.erb index 34c3071e..8e287136 100644 --- a/tutor/app/views/model_answers/new.html.erb +++ b/tutor/app/views/model_answers/new.html.erb @@ -22,5 +22,4 @@
    <%= f.submit "Save Model Answer", class: "btn btn-large btn-primary" %>
    -

    -<% end %> +<% end %> \ No newline at end of file diff --git a/tutor/app/views/tips/_index.html.erb b/tutor/app/views/tips/_index.html.erb index 81e94315..aa92785f 100644 --- a/tutor/app/views/tips/_index.html.erb +++ b/tutor/app/views/tips/_index.html.erb @@ -1 +1 @@ -

    prev tips

    \ No newline at end of file +

    Previous tips

    \ No newline at end of file From 20ac7540a5b282b7388bd90a8b4240eedc397ab8 Mon Sep 17 00:00:00 2001 From: Nadine Adel Date: Thu, 24 Apr 2014 16:39:16 +0200 Subject: [PATCH 458/526] Issue #183 Conventions5 --- tutor/app/views/model_answers/_index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutor/app/views/model_answers/_index.html.erb b/tutor/app/views/model_answers/_index.html.erb index 573cdc00..c0af148b 100644 --- a/tutor/app/views/model_answers/_index.html.erb +++ b/tutor/app/views/model_answers/_index.html.erb @@ -10,8 +10,8 @@

    + {:controller => 'model_answers', :action => 'new', + :problem_id => @problem.id }, {class: 'btn btn-primary btn'} %>

    Previous Answers From 6f4359ab844f2e3998aa57bfd5703b5fc120622d Mon Sep 17 00:00:00 2001 From: AbdullRahman ElHusseini Date: Thu, 24 Apr 2014 16:40:20 +0200 Subject: [PATCH 459/526] Issue #208 removing empty line from routes --- tutor/config/routes.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index 4601527d..fcca8a21 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -32,7 +32,6 @@ resources :test_cases resources :model_answers resources :solutions - resources :topics resources :posts resources :facebook From a3285375205216abdae39fb0ecb5e8e7b9c8299a Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Thu, 24 Apr 2014 16:53:18 +0200 Subject: [PATCH 460/526] changing warning/messages layout --- tutor/app/controllers/acknowledgements_controller.rb | 8 ++++---- tutor/app/controllers/courses_controller.rb | 2 +- tutor/app/views/acknowledgements/new.html.erb | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tutor/app/controllers/acknowledgements_controller.rb b/tutor/app/controllers/acknowledgements_controller.rb index f1688a37..420309d4 100644 --- a/tutor/app/controllers/acknowledgements_controller.rb +++ b/tutor/app/controllers/acknowledgements_controller.rb @@ -27,7 +27,7 @@ def new # Author: Muhammad Mamdouh def create if params[:students] == nil - flash[:notice] = "Acknowledgement failed. Please select a student" + flash[:failure_notice] = "Acknowledgement failed. Please select a student" else params[:students].each do |student| @student = Student.find_by_id(student) @@ -37,15 +37,15 @@ def create bool = @acknowledgement.save if bool == true if @student == nil - flash[:notice]= "Please choose a student to acknowledge." + flash[:failure_notice]= "Please choose a student to acknowledge." else - flash[:notice] = "Acknowledgement successfully created" + flash[:success_notice] = "Acknowledgement successfully created" @student.acknowledgements << @acknowledgement current_lecturer.acknowledgements << @acknowledgement @course.acknowledgements << @acknowledgement end else - flash[:notice] = "Acknowledgement failed." + flash[:failure_notice] = "Acknowledgement failed." end end end diff --git a/tutor/app/controllers/courses_controller.rb b/tutor/app/controllers/courses_controller.rb index 27d49b88..b456e77e 100644 --- a/tutor/app/controllers/courses_controller.rb +++ b/tutor/app/controllers/courses_controller.rb @@ -256,4 +256,4 @@ def to_boolean value end end -end +end \ No newline at end of file diff --git a/tutor/app/views/acknowledgements/new.html.erb b/tutor/app/views/acknowledgements/new.html.erb index 8ca78f9e..705ca67b 100644 --- a/tutor/app/views/acknowledgements/new.html.erb +++ b/tutor/app/views/acknowledgements/new.html.erb @@ -1,8 +1,11 @@

    Acknowledge A student


    -<% if flash[:notice] -%> -
    <%= flash[:notice] %>
    +<% if flash[:failure_notice] -%> +
    <%= flash[:failure_notice] %>
    +<% end %> +<% if flash[:success_notice] -%> +
    <%= flash[:success_notice] %>
    <% end %>
    From e8868d8f212d2cdc8f5d7f6493dfd48110bd6ac4 Mon Sep 17 00:00:00 2001 From: AbdullRahman ElHusseini Date: Thu, 24 Apr 2014 17:07:10 +0200 Subject: [PATCH 461/526] Issue #208 remove extra line --- tutor/app/views/problems/edit.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/tutor/app/views/problems/edit.html.erb b/tutor/app/views/problems/edit.html.erb index f3d5e0ad..86783af6 100644 --- a/tutor/app/views/problems/edit.html.erb +++ b/tutor/app/views/problems/edit.html.erb @@ -26,7 +26,6 @@ <%= render partial: "test_cases/index" %> <%= render partial: "model_answers/new" %> - <%= render partial: "problems/success_options" %> <% if @problem.model_answers.empty? || @problem.test_cases.empty? %> <%= render partial: "problems/failure_options" %> From d213142e8a1b6c2e40b509c92753083ff6e75eac Mon Sep 17 00:00:00 2001 From: Nadine Adel Date: Thu, 24 Apr 2014 17:19:22 +0200 Subject: [PATCH 462/526] Issue #183 Conventions6 --- tutor/app/views/model_answers/_index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutor/app/views/model_answers/_index.html.erb b/tutor/app/views/model_answers/_index.html.erb index c0af148b..573cdc00 100644 --- a/tutor/app/views/model_answers/_index.html.erb +++ b/tutor/app/views/model_answers/_index.html.erb @@ -10,8 +10,8 @@

    + {:controller => 'model_answers', :action => 'new', + :problem_id => @problem.id }, {class: 'btn btn-primary btn'} %>

    Previous Answers From 6efe75f41d5f5a79001acb73e6c525bfc000db5d Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Thu, 24 Apr 2014 17:44:36 +0200 Subject: [PATCH 463/526] changing warning/messages layout --- tutor/Gemfile | 2 +- tutor/Gemfile.lock | 2 + tutor/app/assets/stylesheets/courses.css.scss | 4 ++ tutor/app/views/courses/index.html.erb | 13 ++++-- tutor/app/views/courses/new.html.erb | 41 ++++++++++++++----- tutor/app/views/topics/new.html.erb | 2 +- 6 files changed, 49 insertions(+), 15 deletions(-) diff --git a/tutor/Gemfile b/tutor/Gemfile index 7a4e0334..f031660f 100644 --- a/tutor/Gemfile +++ b/tutor/Gemfile @@ -58,4 +58,4 @@ gem 'foreman' gem 'composite_primary_keys', '~> 6.0.1' # whenever gem for scheduling tasks -gem 'whenever', :require => false +gem 'whenever', :require => false \ No newline at end of file diff --git a/tutor/Gemfile.lock b/tutor/Gemfile.lock index 8d6c1306..99230f2d 100644 --- a/tutor/Gemfile.lock +++ b/tutor/Gemfile.lock @@ -52,6 +52,7 @@ GEM dotenv (0.11.0) dotenv-deployment (= 0.0.1) dotenv-deployment (0.0.1) + dynamic_form (1.1.4) erubis (2.7.0) execjs (2.0.2) foreman (0.63.0) @@ -145,6 +146,7 @@ DEPENDENCIES coffee-rails (~> 4.0.0) composite_primary_keys (~> 6.0.1) devise + dynamic_form foreman jbuilder (~> 1.2) jquery-rails (~> 3.1.0) diff --git a/tutor/app/assets/stylesheets/courses.css.scss b/tutor/app/assets/stylesheets/courses.css.scss index 911dd8de..d8b93842 100644 --- a/tutor/app/assets/stylesheets/courses.css.scss +++ b/tutor/app/assets/stylesheets/courses.css.scss @@ -5,4 +5,8 @@ font-weight: bold; font-family: Courier; float: left; +} + +#error_explanation { + color: red; } \ No newline at end of file diff --git a/tutor/app/views/courses/index.html.erb b/tutor/app/views/courses/index.html.erb index fed8b5f7..dad2002a 100644 --- a/tutor/app/views/courses/index.html.erb +++ b/tutor/app/views/courses/index.html.erb @@ -5,9 +5,16 @@ <%= button_to "Create course", { :action => 'new', :controller => 'courses' }, { class: 'btn btn-primary'} %> <% end %> -
    -<%= flash[:success_deletion] %> -<%= flash[:success_creation] %> + +
    +<% if flash[:success_creation] -%> +
    <%= flash[:success_creation] %>
    +<% end %> +<% if flash[:success_deletion] -%> +
    <%= flash[:success_deletion] %>
    +<% end %> +
    + <% if @courses.any? %>

    Your Courses

    diff --git a/tutor/app/views/courses/new.html.erb b/tutor/app/views/courses/new.html.erb index 059723c3..8ff69da4 100644 --- a/tutor/app/views/courses/new.html.erb +++ b/tutor/app/views/courses/new.html.erb @@ -1,35 +1,56 @@

    Create New Course

    -<% if @new_course.errors.any? %> -
    -

    <%= pluralize(@new_course.errors.count, "error") %> prohibited this course from being saved:

    -
      - <% @new_course.errors.full_messages.each do |msg| %> -
    • <%= msg %>
    • - <% end %> -
    -
    -<% end %> <%= form_for :course, url: courses_path do |f| %>

    <%= f.label :Name %>
    + <% unless @new_course.errors[:name].blank? %> + + Name <%= @new_course.errors[:name].join(", ") %> + + <% end %> +
    <%= f.text_field :name, :value => @new_course.name%> +

    <%= f.label :Code %>
    + <% unless @new_course.errors[:code].blank? %> + + Code <%= @new_course.errors[:code].join(", ") %> + + <% end %> +
    <%= f.text_field :code, :value => @new_course.code %>

    <%= f.label :Description %>
    + <% unless @new_course.errors[:description].blank? %> + + Description <%= @new_course.errors[:description].join(", ") %> + + <% end %> +
    <%= f.text_area :description, class:"form-control", style:"width:300px",placeholder:"Description", :value => @new_course.description %>

    <%= f.label :Semester %>
    + <% unless @new_course.errors[:semester].blank? %> + + Semester <%= @new_course.errors[:semester].join(", ") %> + + <% end %> +
    <%= f.text_field :semester, :value => @new_course.semester %>

    <%= f.label :Year %>
    + <% unless @new_course.errors[:year].blank? %> + + Year <%= @new_course.errors[:year].join(", ") %> + + <% end %> +
    <%= f.text_field :year, :value => @new_course.year %>

    diff --git a/tutor/app/views/topics/new.html.erb b/tutor/app/views/topics/new.html.erb index ad67820c..4ba2b8af 100644 --- a/tutor/app/views/topics/new.html.erb +++ b/tutor/app/views/topics/new.html.erb @@ -6,7 +6,7 @@

    New Topic


    <% if flash[:notice] -%> -
    <%= flash[:notice] %>
    +
    <%= flash[:notice] %>
    <% end %>


    From 6d1442e652ebb79f054df700eb0faa08741e7c9b Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Thu, 24 Apr 2014 17:47:24 +0200 Subject: [PATCH 464/526] fixing conventions --- .../javascripts/solutions_constraints.js | 62 +++++++++---------- .../solutions_constraints_controller.rb | 2 - .../_edit_method.html.erb | 10 +-- .../_edit_variable.html.erb | 8 +-- .../solutions_constraints/_form.html.erb | 20 +++--- .../views/solutions_constraints/new.html.erb | 12 ++-- 6 files changed, 55 insertions(+), 59 deletions(-) diff --git a/tutor/app/assets/javascripts/solutions_constraints.js b/tutor/app/assets/javascripts/solutions_constraints.js index 9d727740..63ab229b 100644 --- a/tutor/app/assets/javascripts/solutions_constraints.js +++ b/tutor/app/assets/javascripts/solutions_constraints.js @@ -11,8 +11,7 @@ var var_name = new Array(); // # Parameters:none // # Returns: none // # Author: Ahmed Mohamed Magdi -function add_params(field) -{ +function add_params(field) { var tmp_type = document.getElementById("params_type").value; var tmp_name = document.getElementById("params_name").value; @@ -23,9 +22,9 @@ function add_params(field) document.getElementById("params_type").value = ""; param_name[param_name.length] = tmp_name; document.getElementById("params_name").value = ""; - document.getElementById("parameter").innerHTML = "

    Paramters Constraints

    "; - for (var i = 0; i < type.length; i++) { + + for (var i = 0; i < type.length; i++) { $('#parameter').append(""); $('#parameter').append(""); $('#parameter').append(""); @@ -41,10 +40,12 @@ function add_params(field) if (tmp_name == "" && tmp_type == "") { document.getElementById("params_type").style.border= "red 1px solid"; document.getElementById("params_name").style.border= "red 1px solid"; - }else if(tmp_name == "") { + } + else if(tmp_name == "") { document.getElementById("params_type").style.border= ""; document.getElementById("params_name").style.border= "red 1px solid"; - }else{ + } + else{ document.getElementById("params_type").style.border= "red 1px solid"; document.getElementById("params_name").style.border= ""; } @@ -55,14 +56,12 @@ function add_params(field) // # Parameters:none // # Returns: none // # Author: Ahmed Mohamed Magdi -function remove_params(field) -{ +function remove_params(field) { var index = field.id.split("_")[1]; type.splice(index,1); param_name.splice(index,1); document.getElementById("parameter").innerHTML = "

    Paramters Constraints

    "; - if(type.length == 0) - { + if(type.length == 0) { $('#parameter').append("No paramter"); } for (var i = 0; i < type.length; i++) { @@ -82,8 +81,7 @@ function remove_params(field) // # Parameters:none // # Returns: none // # Author: Ahmed Mohamed Magdi -function add_variable(field) -{ +function add_variable(field) { var tmp_type = document.getElementById("variable_type").value; var tmp_name = document.getElementById("variable_name").value; @@ -94,9 +92,9 @@ function add_variable(field) document.getElementById("variable_type").value = ""; var_name[var_name.length] = tmp_name; document.getElementById("variable_name").value = ""; - document.getElementById("variable").innerHTML = "

    Variables Constraints

    "; - for (var i = 0; i < var_type.length; i++) { + + for (var i = 0; i < var_type.length; i++) { $('#variable').append(""); $('#variable').append(""); $('#variable').append(""); @@ -107,14 +105,17 @@ function add_variable(field) $('#variable').append(""); } $('#variable').append("
    "); - }else { + } + else { if (tmp_name == "" && tmp_type == "") { document.getElementById("variable_type").style.border= "red 1px solid"; document.getElementById("variable_name").style.border= "red 1px solid"; - }else if(tmp_name == "") { + } + else if(tmp_name == "") { document.getElementById("variable_type").style.border= ""; document.getElementById("variable_name").style.border= "red 1px solid"; - }else{ + } + else { document.getElementById("variable_type").style.border= "red 1px solid"; document.getElementById("variable_name").style.border= ""; } @@ -125,14 +126,12 @@ function add_variable(field) // # Parameters:none // # Returns: none // # Author: Ahmed Mohamed Magdi -function remove_variable(field) -{ +function remove_variable(field){ var index = field.id.split("_")[1]; var_type.splice(index,1); var_name.splice(index,1); document.getElementById("variable").innerHTML = "

    Variables Constraints

    "; - if(var_type.length == 0) - { + if(var_type.length == 0) { $('#variable').append("No Variables"); } for (var i = 0; i < var_type.length; i++) { @@ -168,9 +167,9 @@ function testingValidation(errorArray,method,name) { if (type.length == 0 && var_type.length == 0 && method == 0 && - name == 0) - { - errorArray.push("Can not submit an empty Data, Try filling either Method Constraint for Variable Constraint"); + name == 0) { + errorArray.push("Can not submit an empty Data, + Try filling either Method Constraint for Variable Constraint"); return false; }; if (type.length > 0) { @@ -184,7 +183,8 @@ function testingValidation(errorArray,method,name) { document.getElementById("_constrain_method_name").style.border= ""; document.getElementById("_constrain_method_return").style.border= "red 1px solid"; errorArray.push("Enter method return type .."); - }else if(name == "" && method != "") { + } + else if(name == "" && method != "") { document.getElementById("_constrain_method_name").style.border= "red 1px solid"; document.getElementById("_constrain_method_return").style.border= ""; errorArray.push("Enter method name .."); @@ -196,20 +196,18 @@ function testingValidation(errorArray,method,name) { // # Parameters:none // # Returns: none // # Author: Ahmed Mohamed Magdi -function submitParams() -{ +function submitParams() { $("#errors").html(""); errorArray = new Array(); - + var hash_p = new Array(); + var hash_v = new Array(); method = $('#_constrain_method_return').val() name = $('#_constrain_method_name').val() + if (!testingValidation(errorArray,method,name)) { showErrorMessage(errorArray); return; }; - - var hash_p = [] - var hash_v = [] for (var i = 0; i < type.length; i++) { hash_p.push({ type: type[i] , @@ -237,7 +235,7 @@ function submitParams() alert("Data have been Added successfully"); window.location = window.location } - else{ + else { alert("Data messigin/incorrect !"); } }, diff --git a/tutor/app/controllers/solutions_constraints_controller.rb b/tutor/app/controllers/solutions_constraints_controller.rb index f7835de9..93afd2d2 100644 --- a/tutor/app/controllers/solutions_constraints_controller.rb +++ b/tutor/app/controllers/solutions_constraints_controller.rb @@ -13,7 +13,6 @@ def create var_cons = params[:variable_constraint] method = params[:method_name] method_returned = params[:method_return] - unless method == "" constarint = MethodConstraint.new constarint.method_name = method @@ -29,7 +28,6 @@ def create end constarint.save end - if var_cons.present? var_cons.each do |index,value| variable = VariableConstraint.new diff --git a/tutor/app/views/solutions_constraints/_edit_method.html.erb b/tutor/app/views/solutions_constraints/_edit_method.html.erb index 94aa0aac..bba0a708 100644 --- a/tutor/app/views/solutions_constraints/_edit_method.html.erb +++ b/tutor/app/views/solutions_constraints/_edit_method.html.erb @@ -2,9 +2,9 @@
    - + - +
    @@ -12,11 +12,11 @@ <%= fields_for :@params do |u| %> - + - + - + <% end %> diff --git a/tutor/app/views/solutions_constraints/_edit_variable.html.erb b/tutor/app/views/solutions_constraints/_edit_variable.html.erb index ca27359c..a9356ba1 100644 --- a/tutor/app/views/solutions_constraints/_edit_variable.html.erb +++ b/tutor/app/views/solutions_constraints/_edit_variable.html.erb @@ -2,13 +2,13 @@
    Method Constrains <%= f.text_field :method_return, placeholder: "Return Type" %> <%= f.text_field :method_name, placeholder: "Method Name" %>
    Method Parameter <%= u.text_field :params_type, placeholder: "Variable Type", id:"params_type" %> <%= u.text_field :parameter, placeholder: "Variable Name", id:"params_name" %> <%= image_tag "add_buttom.png", id:"params", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_params(this);" %>
    - + - + - +
    Variable Constraints <%= f.text_field :variable_type, placeholder: "Variable Type" %> <%= f.text_field :variable_name, placeholder: "Variable Name" %>

    - <%= f.submit "Save Changes", class: "btn btn-default"%> + <%= f.submit "Save Changes", class: "btn btn-default "%> <% end %> \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/_form.html.erb b/tutor/app/views/solutions_constraints/_form.html.erb index 490883a0..5126076d 100644 --- a/tutor/app/views/solutions_constraints/_form.html.erb +++ b/tutor/app/views/solutions_constraints/_form.html.erb @@ -3,7 +3,7 @@ Method Constrains - <%= f.text_field :method_return, placeholder: "Return Type"%> + <%= f.text_field :method_return, placeholder: "Return Type" %> <%= f.text_field :method_name, placeholder: "Method Name" %>
    @@ -17,7 +17,7 @@ <%= u.text_field :parameter, placeholder: "Variable Name", id:"params_name" %> - <%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_params(this);"%> + <%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_params(this);" %> <% end %> @@ -25,12 +25,12 @@

    Add Variable Constraints


    + display: block; + height: 1px; + border: 0; + border-top: 1px solid #ccc; + margin: 1em 0; + padding: 0;"> @@ -41,7 +41,7 @@ <%= u.text_field :variable_name, placeholder: "Variable Name", id:"variable_name" %> - <%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_variable(this);"%> + <%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_variable(this);" %> <% end %> @@ -54,5 +54,5 @@

    No variables


    - <%= button_tag "Save Changes", type: "button", class: "btn btn-large btn-success", onclick:"submitParams();"%> + <%= button_tag "Save Changes", type: "button", class: "btn btn-large btn-success", onclick:"submitParams();" %> <% end %> \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/new.html.erb b/tutor/app/views/solutions_constraints/new.html.erb index 5b791746..5b1f6ed3 100644 --- a/tutor/app/views/solutions_constraints/new.html.erb +++ b/tutor/app/views/solutions_constraints/new.html.erb @@ -3,11 +3,11 @@

    Add Method Constraints


    + display: block; + height: 1px; + border: 0; + border-top: 1px solid #ccc; + margin: 1em 0; + padding: 0;"> <%= render 'form' %> \ No newline at end of file From 4c22a18e9583d4544f4b6d8fba84ac8f2b816550 Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Thu, 24 Apr 2014 17:55:25 +0200 Subject: [PATCH 465/526] changing layout for the create course form --- tutor/app/views/courses/new.html.erb | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tutor/app/views/courses/new.html.erb b/tutor/app/views/courses/new.html.erb index 8ff69da4..527ab782 100644 --- a/tutor/app/views/courses/new.html.erb +++ b/tutor/app/views/courses/new.html.erb @@ -6,28 +6,27 @@ <%= f.label :Name %>
    <% unless @new_course.errors[:name].blank? %> - Name <%= @new_course.errors[:name].join(", ") %> + Name <%= @new_course.errors[:name].join(", ") %> <% end %>
    - <%= f.text_field :name, :value => @new_course.name%> - + <%= f.text_field :name, :value => @new_course.name, class:"form-control", style: "width:300px" %>

    <%= f.label :Code %>
    <% unless @new_course.errors[:code].blank? %> - Code <%= @new_course.errors[:code].join(", ") %> + Code <%= @new_course.errors[:code].join(", ") %> <% end %>
    - <%= f.text_field :code, :value => @new_course.code %> + <%= f.text_field :code, :value => @new_course.code, class:"form-control", style: "width:300px" %>

    <%= f.label :Description %>
    <% unless @new_course.errors[:description].blank? %> - Description <%= @new_course.errors[:description].join(", ") %> + Description <%= @new_course.errors[:description].join(", ") %> <% end %>
    @@ -37,23 +36,23 @@ <%= f.label :Semester %>
    <% unless @new_course.errors[:semester].blank? %> - Semester <%= @new_course.errors[:semester].join(", ") %> + Semester <%= @new_course.errors[:semester].join(", ") %> <% end %>
    - <%= f.text_field :semester, :value => @new_course.semester %> + <%= f.text_field :semester, :value => @new_course.semester, class:"form-control", style: "width:50px" %>

    <%= f.label :Year %>
    <% unless @new_course.errors[:year].blank? %> - Year <%= @new_course.errors[:year].join(", ") %> + Year <%= @new_course.errors[:year].join(", ") %> <% end %>
    - <%= f.text_field :year, :value => @new_course.year %> + <%= f.text_field :year, :value => @new_course.year, class:"form-control", style: "width:100px" %>

    - <%= f.submit %> + <%= f.submit "Save", class: "btn btn-success" %>

    <% end %> \ No newline at end of file From 37cddedcf8f123b79bb7c131324913f82529299a Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Thu, 24 Apr 2014 17:57:57 +0200 Subject: [PATCH 466/526] changing layout for the create course form --- tutor/app/views/courses/new.html.erb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tutor/app/views/courses/new.html.erb b/tutor/app/views/courses/new.html.erb index 527ab782..15f67d88 100644 --- a/tutor/app/views/courses/new.html.erb +++ b/tutor/app/views/courses/new.html.erb @@ -8,8 +8,8 @@ Name <%= @new_course.errors[:name].join(", ") %> +
    <% end %> -
    <%= f.text_field :name, :value => @new_course.name, class:"form-control", style: "width:300px" %>

    @@ -18,8 +18,8 @@ Code <%= @new_course.errors[:code].join(", ") %> +
    <% end %> -
    <%= f.text_field :code, :value => @new_course.code, class:"form-control", style: "width:300px" %>

    @@ -28,8 +28,8 @@ Description <%= @new_course.errors[:description].join(", ") %> +
    <% end %> -
    <%= f.text_area :description, class:"form-control", style:"width:300px",placeholder:"Description", :value => @new_course.description %>

    @@ -38,8 +38,8 @@ Semester <%= @new_course.errors[:semester].join(", ") %> +
    <% end %> -
    <%= f.text_field :semester, :value => @new_course.semester, class:"form-control", style: "width:50px" %>

    @@ -48,8 +48,8 @@ Year <%= @new_course.errors[:year].join(", ") %> +
    <% end %> -
    <%= f.text_field :year, :value => @new_course.year, class:"form-control", style: "width:100px" %>

    From 43904ed16c51b2e37e2e137b9a87cd6da3c04d13 Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Thu, 24 Apr 2014 18:09:25 +0200 Subject: [PATCH 467/526] fixing design --- tutor/app/views/courses/edit.html.erb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tutor/app/views/courses/edit.html.erb b/tutor/app/views/courses/edit.html.erb index c002425b..81d20307 100644 --- a/tutor/app/views/courses/edit.html.erb +++ b/tutor/app/views/courses/edit.html.erb @@ -3,12 +3,6 @@ -->

    - -
    - <%= button_to "Topics", {:controller => 'topics', :action => 'index', - :course_id => @course.id}, class: "btn btn-success", style: "float: left;", method: :get %> -
    -
    <%= button_to "Add Topics", {:controller => 'topics', :action => 'new', From a3b9e2bd6c5f8d41d8749e57c801d249e9add95b Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Thu, 24 Apr 2014 18:23:32 +0200 Subject: [PATCH 468/526] fixing long lines --- .../javascripts/solutions_constraints.js | 22 +++++++++++++------ .../_edit_method.html.erb | 3 ++- .../solutions_constraints/_form.html.erb | 6 +++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/tutor/app/assets/javascripts/solutions_constraints.js b/tutor/app/assets/javascripts/solutions_constraints.js index 63ab229b..c07848de 100644 --- a/tutor/app/assets/javascripts/solutions_constraints.js +++ b/tutor/app/assets/javascripts/solutions_constraints.js @@ -31,7 +31,9 @@ function add_params(field) { $('#parameter').append(""); $('#parameter').append(""); $('#parameter').append(""); - $('#parameter').append("\"delete"); + $('#parameter').append("\"delete"); $('#parameter').append(""); } $('#parameter').append(""); @@ -71,7 +73,9 @@ function remove_params(field) { $('#parameter').append(""); $('#parameter').append(""); $('#parameter').append(""); - $('#parameter').append("\"delete"); + $('#parameter').append("\"delete"); $('#parameter').append(""); } $('#parameter').append(""); @@ -101,7 +105,9 @@ function add_variable(field) { $('#variable').append(""); $('#variable').append(""); $('#variable').append(""); - $('#variable').append("\"delete"); + $('#variable').append("\"delete"); $('#variable').append(""); } $('#variable').append(""); @@ -126,7 +132,7 @@ function add_variable(field) { // # Parameters:none // # Returns: none // # Author: Ahmed Mohamed Magdi -function remove_variable(field){ +function remove_variable(field) { var index = field.id.split("_")[1]; var_type.splice(index,1); var_name.splice(index,1); @@ -141,7 +147,9 @@ function remove_variable(field){ $('#variable').append(""); $('#variable').append(""); $('#variable').append(""); - $('#variable').append("\"delete"); + $('#variable').append("\"delete"); $('#variable').append(""); } $('#variable').append(""); @@ -168,8 +176,8 @@ function testingValidation(errorArray,method,name) { var_type.length == 0 && method == 0 && name == 0) { - errorArray.push("Can not submit an empty Data, - Try filling either Method Constraint for Variable Constraint"); + errorArray.push("Can not submit an empty Data,\ + Try filling either Method Constraint for Variable Constraint"); return false; }; if (type.length > 0) { diff --git a/tutor/app/views/solutions_constraints/_edit_method.html.erb b/tutor/app/views/solutions_constraints/_edit_method.html.erb index bba0a708..08cca49a 100644 --- a/tutor/app/views/solutions_constraints/_edit_method.html.erb +++ b/tutor/app/views/solutions_constraints/_edit_method.html.erb @@ -17,7 +17,8 @@ <%= u.text_field :parameter, placeholder: "Variable Name", id:"params_name" %> - <%= image_tag "add_buttom.png", id:"params", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_params(this);" %> + <%= image_tag "add_buttom.png", id:"params", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", + onclick: "add_params(this);" %> <% end %> diff --git a/tutor/app/views/solutions_constraints/_form.html.erb b/tutor/app/views/solutions_constraints/_form.html.erb index 5126076d..475dc477 100644 --- a/tutor/app/views/solutions_constraints/_form.html.erb +++ b/tutor/app/views/solutions_constraints/_form.html.erb @@ -17,7 +17,8 @@ <%= u.text_field :parameter, placeholder: "Variable Name", id:"params_name" %> - <%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_params(this);" %> + <%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", + onclick: "add_params(this);" %> <% end %> @@ -41,7 +42,8 @@ <%= u.text_field :variable_name, placeholder: "Variable Name", id:"variable_name" %> - <%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_variable(this);" %> + <%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", + onclick: "add_variable(this);" %> <% end %> From 8003eb96a274c8fb269e3b4191c46d2dc986562c Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Thu, 24 Apr 2014 18:29:54 +0200 Subject: [PATCH 469/526] fixing design --- .../teaching_assistants_controller.rb | 6 ++--- .../views/teaching_assistants/new.html.erb | 9 +++++--- tutor/app/views/topics/new.html.erb | 23 ++++++++++++------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/tutor/app/controllers/teaching_assistants_controller.rb b/tutor/app/controllers/teaching_assistants_controller.rb index 82b5efd5..821ce0e1 100644 --- a/tutor/app/controllers/teaching_assistants_controller.rb +++ b/tutor/app/controllers/teaching_assistants_controller.rb @@ -26,12 +26,12 @@ def create begin @teaching_assistant = TeachingAssistant.find_by_id(params[:teaching_assistant][:id]) if params[:teaching_assistant][:id] == '' - flash[:notice] = 'Error! you need to select a TA' + flash[:failure_notice] = 'Error! you need to select a TA' redirect_to :action => 'new' else @course = Course.find_by_id(params[:course_id]) @course.TAs << @teaching_assistant - flash[:notice]='TA added!' + flash[:success_notice]='TA added!' @notification = NotificationMail.new @notification.subject = 'Invitation to join tutor' @notification.email = @teaching_assistant.email @@ -40,7 +40,7 @@ def create redirect_to :action => 'index' end rescue - flash[:notice]='Error! TA is already added to the course.' + flash[:failure_notice]='Error! TA is already added to the course.' redirect_to :action => 'new' end end diff --git a/tutor/app/views/teaching_assistants/new.html.erb b/tutor/app/views/teaching_assistants/new.html.erb index a7a1363e..ea9c60f9 100644 --- a/tutor/app/views/teaching_assistants/new.html.erb +++ b/tutor/app/views/teaching_assistants/new.html.erb @@ -1,9 +1,12 @@

    Add a Teaching Assistant


    - <% if flash[:notice] -%> -
    <%= flash[:notice] %>
    - <% end %> +<% if flash[:failure_notice] -%> +
    <%= flash[:failure_notice] %>
    +<% end %> +<% if flash[:success_notice] -%> +
    <%= flash[:success_notice] %>
    +<% end %>
    <%= form_for :teaching_assistant, url: {action: "create"} do |f| %> diff --git a/tutor/app/views/topics/new.html.erb b/tutor/app/views/topics/new.html.erb index 4ba2b8af..1ba306b9 100644 --- a/tutor/app/views/topics/new.html.erb +++ b/tutor/app/views/topics/new.html.erb @@ -2,23 +2,30 @@ Author: Ahmed Akram --> -
    +

    New Topic

    -
    - <% if flash[:notice] -%> -
    <%= flash[:notice] %>
    - <% end %> -


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

    <%= f.label "Title" %>
    + <% unless @new_topic.errors[:title].blank? %> + + Name <%= @new_topic.errors[:title].join(", ") %> + +
    + <% end %> <%= f.text_field :title, autofocus: true, class:"form-control", style: "width:300px", placeholder: "Title", :value => @new_topic.title %>

    <%= f.label :description %>
    - <%= f.text_area :description, class:"form-control", style: "margin-left:auto; - margin-right:auto;height:200px;width:500px;resize:none", placeholder: "Description", :value => @new_topic.description %> + <% unless @new_topic.errors[:description].blank? %> + + Description <%= @new_topic.errors[:description].join(", ") %> + +
    + <% end %> + <%= f.text_area :description, class:"form-control", style: "height:200px;width:500px;resize:none", placeholder: "Description", :value => @new_topic.description %>

    <%= f.submit "Save", class: "btn btn-success"%> From fcc391595e4a391a6ba724df8c60cc87cb62d225 Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Thu, 24 Apr 2014 18:35:01 +0200 Subject: [PATCH 470/526] fixing design --- tutor/app/views/acknowledgements/new.html.erb | 2 +- tutor/app/views/courses/edit.html.erb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tutor/app/views/acknowledgements/new.html.erb b/tutor/app/views/acknowledgements/new.html.erb index 705ca67b..3b8685f8 100644 --- a/tutor/app/views/acknowledgements/new.html.erb +++ b/tutor/app/views/acknowledgements/new.html.erb @@ -12,7 +12,7 @@ <%= form_for :acknowledgement, url: {action: "create"} do |f| %>

    <%=select_tag 'students[]', options_for_select( - @course.students.map {|p| [p.name, p.id]}), :multiple => true %> + @course.students.map {|p| [p.name, p.id]}), :multiple => true, style: "width:300px" %>

    diff --git a/tutor/app/views/courses/edit.html.erb b/tutor/app/views/courses/edit.html.erb index 81d20307..bc6801bf 100644 --- a/tutor/app/views/courses/edit.html.erb +++ b/tutor/app/views/courses/edit.html.erb @@ -12,7 +12,7 @@

    <%= button_to "Add a TA", {:controller => 'teaching_assistants', :action => 'new', - :course_id => @course.id}, class: "btn btn-success", style: "float: left; margin-left: 15px", :method => :get%> + :course_id => @course.id}, class: "btn btn-success", style: "float: left; margin-left: 15px", :method => :get %>
    @@ -25,9 +25,9 @@
    <% if @discussion_board.activated == true %> - <%str = "Deactivate DiscussionBoard" %> + <% str = "Deactivate DiscussionBoard" %> <% else %> - <%str = "Activate DiscussionBoard"%> + <% str = "Activate DiscussionBoard" %> <% end %> <%= button_to str, {:controller => :discussion_boards, :action => 'toggle', :id => @discussion_board.id}, class: "btn btn-success", style: "float: left; margin-left: 15px" %> From 5f5dec7c0f508222e6e5602896754774812a5ff7 Mon Sep 17 00:00:00 2001 From: Khaled Date: Thu, 24 Apr 2014 18:55:32 +0200 Subject: [PATCH 471/526] Issue #367 Fixing bugs in layout and viewing variables --- tutor/app/assets/stylesheets/solutions.css | 2 +- tutor/app/models/debugger.rb | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/tutor/app/assets/stylesheets/solutions.css b/tutor/app/assets/stylesheets/solutions.css index 89a1cab9..622b7fa9 100644 --- a/tutor/app/assets/stylesheets/solutions.css +++ b/tutor/app/assets/stylesheets/solutions.css @@ -38,7 +38,7 @@ textarea { } .fixed-horizontal { - max-width: 250px; + max-width: 175px; overflow-x:scroll; overflow-y:hidden; } diff --git a/tutor/app/models/debugger.rb b/tutor/app/models/debugger.rb index 68a38942..0687cbb8 100644 --- a/tutor/app/models/debugger.rb +++ b/tutor/app/models/debugger.rb @@ -64,8 +64,6 @@ def start(class_name, input) $all = [] Dir.chdir(Solution::CLASS_PATH){ begin - puts input - input = input.split(" ") $input, $output, $error, $wait_thread = Open3.popen3("jdb", class_name, input) buffer_until_ready input "stop in #{class_name}.main" @@ -114,7 +112,6 @@ def debug # Author: Mussab ElDash def get_line out_stream = buffer_until_complete - puts out_stream list_of_lines = out_stream.split(/\n+/) before_last_line = list_of_lines[-2] /, line=\d+/ =~ before_last_line From 5ba4af835b6052ba3a1d850c788d527f014ba39f Mon Sep 17 00:00:00 2001 From: Khaled Date: Thu, 24 Apr 2014 18:57:40 +0200 Subject: [PATCH 472/526] Issue #367 Deleted debug printings --- tutor/app/models/debugger.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/tutor/app/models/debugger.rb b/tutor/app/models/debugger.rb index 0687cbb8..6f444f97 100644 --- a/tutor/app/models/debugger.rb +++ b/tutor/app/models/debugger.rb @@ -149,7 +149,6 @@ def self.debug(student_id, problem_id, code, input) debugger = Debugger.new class_name = solution.class_file_name debugging = debugger.start(class_name, input) - p debugging java_file = solution.java_file_name true, true class_file = solution.class_file_name true, true File.delete(java_file) From e8ab2c66f1e28e38240dd9f37fb5f55edc0f7997 Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Thu, 24 Apr 2014 18:59:33 +0200 Subject: [PATCH 473/526] fixing indextations --- tutor/app/assets/javascripts/solutions_constraints.js | 3 +-- tutor/app/views/solutions_constraints/_form.html.erb | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tutor/app/assets/javascripts/solutions_constraints.js b/tutor/app/assets/javascripts/solutions_constraints.js index c07848de..5864732f 100644 --- a/tutor/app/assets/javascripts/solutions_constraints.js +++ b/tutor/app/assets/javascripts/solutions_constraints.js @@ -237,8 +237,7 @@ function submitParams() { method_return: method, method_name: name }, - success: function(data) - { + success: function(data) { if (data) { alert("Data have been Added successfully"); window.location = window.location diff --git a/tutor/app/views/solutions_constraints/_form.html.erb b/tutor/app/views/solutions_constraints/_form.html.erb index 475dc477..47407cc0 100644 --- a/tutor/app/views/solutions_constraints/_form.html.erb +++ b/tutor/app/views/solutions_constraints/_form.html.erb @@ -28,11 +28,11 @@
    - + border: 0; + border-top: 1px solid #ccc; + margin: 1em 0; + padding: 0;"> + <%= fields_for :@variables do |u| %> From 0d1acff1313a5eb14838e46577a66d69069ca848 Mon Sep 17 00:00:00 2001 From: Ahmed ELAssuty Date: Thu, 24 Apr 2014 19:02:12 +0200 Subject: [PATCH 474/526] fix layout sizing issues --- tutor/app/assets/stylesheets/application.css | 7 +++++++ tutor/app/views/layouts/_footer.html.erb | 2 +- tutor/app/views/layouts/_right_side_bar.html.erb | 3 +-- tutor/app/views/layouts/application.html.erb | 9 +++++---- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/tutor/app/assets/stylesheets/application.css b/tutor/app/assets/stylesheets/application.css index 5dd23c89..2288e797 100644 --- a/tutor/app/assets/stylesheets/application.css +++ b/tutor/app/assets/stylesheets/application.css @@ -28,6 +28,9 @@ margin-bottom:70px; width:78%; margin-left:1%; + min-width:500px; + overflow:scroll; + position:static; } .footer { @@ -46,4 +49,8 @@ .button-devise { margin-top: 10px; +} + +.home { + overflow:scroll; } \ No newline at end of file diff --git a/tutor/app/views/layouts/_footer.html.erb b/tutor/app/views/layouts/_footer.html.erb index b26c482f..94abcf86 100644 --- a/tutor/app/views/layouts/_footer.html.erb +++ b/tutor/app/views/layouts/_footer.html.erb @@ -3,7 +3,7 @@ # General layout for footer # Author: Ahmed Elassuty --> -
    +
    <%= link_to "About us"%> diff --git a/tutor/app/views/layouts/_right_side_bar.html.erb b/tutor/app/views/layouts/_right_side_bar.html.erb index 29814900..58035bf4 100644 --- a/tutor/app/views/layouts/_right_side_bar.html.erb +++ b/tutor/app/views/layouts/_right_side_bar.html.erb @@ -3,7 +3,7 @@ # General layout for right side bar # Author: Ahmed Elassuty --> -

    From 8370abbc6589975520ce41322d20d021a94f3068 Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Thu, 24 Apr 2014 19:25:17 +0200 Subject: [PATCH 481/526] fixing indentation --- tutor/app/controllers/teaching_assistants_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/controllers/teaching_assistants_controller.rb b/tutor/app/controllers/teaching_assistants_controller.rb index 821ce0e1..4b22f3a1 100644 --- a/tutor/app/controllers/teaching_assistants_controller.rb +++ b/tutor/app/controllers/teaching_assistants_controller.rb @@ -40,7 +40,7 @@ def create redirect_to :action => 'index' end rescue - flash[:failure_notice]='Error! TA is already added to the course.' + flash[:failure_notice] = 'Error! TA is already added to the course.' redirect_to :action => 'new' end end From b9251b13895f4a81606d8f6ad0b34081f66ac78e Mon Sep 17 00:00:00 2001 From: Muhammad Mamdouh Date: Thu, 24 Apr 2014 19:26:08 +0200 Subject: [PATCH 482/526] fixing indentation --- tutor/app/controllers/teaching_assistants_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/controllers/teaching_assistants_controller.rb b/tutor/app/controllers/teaching_assistants_controller.rb index 4b22f3a1..56631b76 100644 --- a/tutor/app/controllers/teaching_assistants_controller.rb +++ b/tutor/app/controllers/teaching_assistants_controller.rb @@ -31,7 +31,7 @@ def create else @course = Course.find_by_id(params[:course_id]) @course.TAs << @teaching_assistant - flash[:success_notice]='TA added!' + flash[:success_notice] = 'TA added!' @notification = NotificationMail.new @notification.subject = 'Invitation to join tutor' @notification.email = @teaching_assistant.email From 116cde8b7f42f077334e0ea7cc27d07863c21159 Mon Sep 17 00:00:00 2001 From: Khaled Date: Thu, 24 Apr 2014 19:32:32 +0200 Subject: [PATCH 483/526] Issue #367 Added Gemfile.lock --- tutor/Gemfile.lock | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tutor/Gemfile.lock b/tutor/Gemfile.lock index 8d6c1306..7bf9ea70 100644 --- a/tutor/Gemfile.lock +++ b/tutor/Gemfile.lock @@ -25,6 +25,7 @@ GEM multi_json (~> 1.3) thread_safe (~> 0.1) tzinfo (~> 0.3.37) + ansi (1.4.3) arel (4.0.2) bcrypt (3.1.7) builder (3.1.4) @@ -49,14 +50,13 @@ GEM railties (>= 3.2.6, < 5) thread_safe (~> 0.1) warden (~> 1.2.3) - dotenv (0.11.0) - dotenv-deployment (= 0.0.1) - dotenv-deployment (0.0.1) + dotenv (0.7.0) erubis (2.7.0) execjs (2.0.2) - foreman (0.63.0) - dotenv (>= 0.7) - thor (>= 0.13.6) + foreman (0.66.0) + dotenv (~> 0.7.0) + thor (~> 0.19.1) + hashr (0.0.22) hike (1.2.3) i18n (0.6.9) jbuilder (1.5.3) @@ -66,6 +66,8 @@ GEM railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.8.1) + json_builder (3.1.0) + activesupport (>= 2.0.0) kgio (2.9.2) mail (2.5.4) mime-types (~> 1.16) @@ -95,6 +97,8 @@ GEM rake (10.3.1) rdoc (4.1.1) json (~> 1.4) + rest-client (1.6.7) + mime-types (>= 1.16) rmagick (2.13.2) sass (3.2.19) sass-rails (4.0.3) @@ -118,6 +122,14 @@ GEM thor (0.19.1) thread_safe (0.3.3) tilt (1.4.1) + tire (0.6.2) + activemodel (>= 3.0) + activesupport + ansi + hashr (~> 0.0.19) + multi_json (~> 1.3) + rake + rest-client (~> 1.6) treetop (1.4.15) polyglot polyglot (>= 0.3.1) @@ -148,11 +160,13 @@ DEPENDENCIES foreman jbuilder (~> 1.2) jquery-rails (~> 3.1.0) + json_builder (= 3.1.0) rails (= 4.0.4) rmagick sass-rails (~> 4.0.2) sdoc sqlite3 + tire turbolinks uglifier (>= 1.3.0) unicorn From 9fa6a4ffedac014367d38eb7db819b7141ea283e Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Thu, 24 Apr 2014 20:37:51 +0200 Subject: [PATCH 484/526] fixing doc --- .../javascripts/solutions_constraints.js | 23 ++++++++++++------- .../solutions_constraints_controller.rb | 6 +++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/tutor/app/assets/javascripts/solutions_constraints.js b/tutor/app/assets/javascripts/solutions_constraints.js index 5864732f..1483ac96 100644 --- a/tutor/app/assets/javascripts/solutions_constraints.js +++ b/tutor/app/assets/javascripts/solutions_constraints.js @@ -7,8 +7,9 @@ var param_name = new Array(); var var_type = new Array(); var var_name = new Array(); +// # [Add Solutions' constraints - Story 4.14] // # Description: Adds the parameters from the text_fields to array -// # Parameters:none +// # Parameters: none // # Returns: none // # Author: Ahmed Mohamed Magdi function add_params(field) { @@ -54,8 +55,9 @@ function add_params(field) { } } +// # [Add Solutions' constraints - Story 4.14] // # Description: removes selected variable from method Contraints -// # Parameters:none +// # Parameters: none // # Returns: none // # Author: Ahmed Mohamed Magdi function remove_params(field) { @@ -81,8 +83,9 @@ function remove_params(field) { $('#parameter').append(""); } +// # [Add Solutions' constraints - Story 4.14] // # Description: Adds the parameters from the text_fields to array -// # Parameters:none +// # Parameters: none // # Returns: none // # Author: Ahmed Mohamed Magdi function add_variable(field) { @@ -128,8 +131,9 @@ function add_variable(field) { } } +// # [Add Solutions' constraints - Story 4.14] // # Description: removes selected variable from Variable Contraints -// # Parameters:none +// # Parameters: none // # Returns: none // # Author: Ahmed Mohamed Magdi function remove_variable(field) { @@ -155,9 +159,10 @@ function remove_variable(field) { $('#variable').append(""); } -// # Description: TO show the error massages +// # [Add Solutions' constraints - Story 4.14] +// # Description: for showing the error massages for the user // # Parameters: -// # errorArray: array of Error, for multi error massage show +// # errorArray: array of Error, for multi error massage show // # Returns: none // # Author: Ahmed Mohamed Magdi function showErrorMessage(arrayOfErrors) { @@ -166,9 +171,10 @@ function showErrorMessage(arrayOfErrors) { }; } +// # [Add Solutions' constraints - Story 4.14] // # Description: Validates Data before sending it to the Server side // # Parameters: -// # errorArray: array of Error, for multi error massage show +// # errorArray: array of Error, for multi error massage show // # Returns: none // # Author: Ahmed Mohamed Magdi function testingValidation(errorArray,method,name) { @@ -200,8 +206,9 @@ function testingValidation(errorArray,method,name) { return errorArray.length == 0; } +// # [Add Solutions' constraints - Story 4.14] // # Description: submits via ajax to the controller -// # Parameters:none +// # Parameters: none // # Returns: none // # Author: Ahmed Mohamed Magdi function submitParams() { diff --git a/tutor/app/controllers/solutions_constraints_controller.rb b/tutor/app/controllers/solutions_constraints_controller.rb index 93afd2d2..4c4efe4a 100644 --- a/tutor/app/controllers/solutions_constraints_controller.rb +++ b/tutor/app/controllers/solutions_constraints_controller.rb @@ -1,6 +1,7 @@ class SolutionsConstraintsController < ApplicationController - # Description: Creates New record for either Method or variable constraints + # [Add Solutions' constraints - Story 4.14] + # Description: Creates new record for either method or variable constraints # Parameters: # method_cons: Hash containting the Method parameters # var_cons: Hash containting the Variables Constraints @@ -39,7 +40,8 @@ def create render json: true end - # Description: init New record + # [Add Solutions' constraints - Story 4.14] + # Description: init new record # Parameters: none # Returns: none # Author: Ahmed Mohamed Magdi From ef516ab827bb9de0121d3d738e14e676cefd61f2 Mon Sep 17 00:00:00 2001 From: Ahmed ELAssuty Date: Thu, 24 Apr 2014 20:42:18 +0200 Subject: [PATCH 485/526] fix convention --- tutor/app/views/layouts/application.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/views/layouts/application.html.erb b/tutor/app/views/layouts/application.html.erb index b1309413..fca81845 100644 --- a/tutor/app/views/layouts/application.html.erb +++ b/tutor/app/views/layouts/application.html.erb @@ -62,7 +62,7 @@

    From 8266f002eed23b3212698aacf30ddcf905561626 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Thu, 24 Apr 2014 21:01:15 +0200 Subject: [PATCH 486/526] added gems --- tutor/Gemfile.lock | 2 -- 1 file changed, 2 deletions(-) diff --git a/tutor/Gemfile.lock b/tutor/Gemfile.lock index 4fdf2468..38a6f7e4 100644 --- a/tutor/Gemfile.lock +++ b/tutor/Gemfile.lock @@ -53,7 +53,6 @@ GEM dotenv (0.11.0) dotenv-deployment (= 0.0.1) dotenv-deployment (0.0.1) - dynamic_form (1.1.4) erubis (2.7.0) execjs (2.0.2) foreman (0.63.0) @@ -160,7 +159,6 @@ DEPENDENCIES coffee-rails (~> 4.0.0) composite_primary_keys (~> 6.0.1) devise - dynamic_form foreman jbuilder (~> 1.2) jquery-rails (~> 3.1.0) From b0ec7237f26ea149ea82a36553fbede542e0a596 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Thu, 24 Apr 2014 21:12:27 +0200 Subject: [PATCH 487/526] gem --- tutor/Gemfile.lock | 2 -- 1 file changed, 2 deletions(-) diff --git a/tutor/Gemfile.lock b/tutor/Gemfile.lock index 4fdf2468..38a6f7e4 100644 --- a/tutor/Gemfile.lock +++ b/tutor/Gemfile.lock @@ -53,7 +53,6 @@ GEM dotenv (0.11.0) dotenv-deployment (= 0.0.1) dotenv-deployment (0.0.1) - dynamic_form (1.1.4) erubis (2.7.0) execjs (2.0.2) foreman (0.63.0) @@ -160,7 +159,6 @@ DEPENDENCIES coffee-rails (~> 4.0.0) composite_primary_keys (~> 6.0.1) devise - dynamic_form foreman jbuilder (~> 1.2) jquery-rails (~> 3.1.0) From bb200c860a0f69ccd850278b269918aafaba4348 Mon Sep 17 00:00:00 2001 From: Ahmed Akram Date: Thu, 24 Apr 2014 21:12:52 +0200 Subject: [PATCH 488/526] deactivating imagemagick --- tutor/Gemfile | 4 ++-- tutor/Gemfile.lock | 10 ---------- tutor/app/models/lecturer.rb | 2 +- tutor/app/models/student.rb | 2 +- tutor/app/models/teaching_assistant.rb | 2 +- 5 files changed, 5 insertions(+), 15 deletions(-) diff --git a/tutor/Gemfile b/tutor/Gemfile index 96d666af..412fa977 100644 --- a/tutor/Gemfile +++ b/tutor/Gemfile @@ -9,8 +9,8 @@ gem 'rails', '4.0.4' gem 'devise' # File uploading -gem 'carrierwave' -gem 'rmagick' +# gem 'carrierwave' +# gem 'rmagick' # Use sqlite3 as the database for Active Record gem 'sqlite3' diff --git a/tutor/Gemfile.lock b/tutor/Gemfile.lock index 4fdf2468..db3c98e9 100644 --- a/tutor/Gemfile.lock +++ b/tutor/Gemfile.lock @@ -29,11 +29,6 @@ GEM arel (4.0.2) bcrypt (3.1.7) builder (3.1.4) - carrierwave (0.10.0) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - json (>= 1.7) - mime-types (>= 1.16) chronic (0.10.2) coffee-rails (4.0.1) coffee-script (>= 2.2.0) @@ -53,7 +48,6 @@ GEM dotenv (0.11.0) dotenv-deployment (= 0.0.1) dotenv-deployment (0.0.1) - dynamic_form (1.1.4) erubis (2.7.0) execjs (2.0.2) foreman (0.63.0) @@ -102,7 +96,6 @@ GEM json (~> 1.4) rest-client (1.6.7) mime-types (>= 1.16) - rmagick (2.13.2) sass (3.2.19) sass-rails (4.0.3) railties (>= 4.0.0, < 5.0) @@ -156,17 +149,14 @@ PLATFORMS ruby DEPENDENCIES - carrierwave coffee-rails (~> 4.0.0) composite_primary_keys (~> 6.0.1) devise - dynamic_form foreman jbuilder (~> 1.2) jquery-rails (~> 3.1.0) json_builder (= 3.1.0) rails (= 4.0.4) - rmagick sass-rails (~> 4.0.2) sdoc sqlite3 diff --git a/tutor/app/models/lecturer.rb b/tutor/app/models/lecturer.rb index b26bbdf7..b1e3c5e7 100644 --- a/tutor/app/models/lecturer.rb +++ b/tutor/app/models/lecturer.rb @@ -11,7 +11,7 @@ class Lecturer < ActiveRecord::Base include Searchable #Uploader - mount_uploader :profile_image, ProfileImageUploader + # mount_uploader :profile_image, ProfileImageUploader #Validations validate :duplicate_email diff --git a/tutor/app/models/student.rb b/tutor/app/models/student.rb index 38ce5564..3072902f 100644 --- a/tutor/app/models/student.rb +++ b/tutor/app/models/student.rb @@ -14,7 +14,7 @@ class Student < ActiveRecord::Base :recoverable, :rememberable, :trackable, :validatable, :confirmable - mount_uploader :profile_image, ProfileImageUploader + # mount_uploader :profile_image, ProfileImageUploader #Validations validate :duplicate_email diff --git a/tutor/app/models/teaching_assistant.rb b/tutor/app/models/teaching_assistant.rb index c8718069..5f93df67 100644 --- a/tutor/app/models/teaching_assistant.rb +++ b/tutor/app/models/teaching_assistant.rb @@ -10,7 +10,7 @@ class TeachingAssistant < ActiveRecord::Base #concerns include Searchable - mount_uploader :profile_image, ProfileImageUploader + # mount_uploader :profile_image, ProfileImageUploader #Validations validate :duplicate_email From d3a7c19ff35061ee962ebc874fa09c67540be665 Mon Sep 17 00:00:00 2001 From: Mohab Date: Thu, 24 Apr 2014 21:17:08 +0200 Subject: [PATCH 489/526] Adding tabs for course navigation --- tutor/app/views/courses/edit.html.erb | 12 +- tutor/app/views/courses/index.html.erb | 116 +++++++++--------- tutor/app/views/courses/new.html.erb | 122 +++++++++--------- tutor/app/views/courses/show.html.erb | 104 +++++++++------- tutor/app/views/courses/sign_up.html.erb | 150 ++++++++++++----------- 5 files changed, 277 insertions(+), 227 deletions(-) diff --git a/tutor/app/views/courses/edit.html.erb b/tutor/app/views/courses/edit.html.erb index 8c83ff6a..4ea8a085 100644 --- a/tutor/app/views/courses/edit.html.erb +++ b/tutor/app/views/courses/edit.html.erb @@ -1,3 +1,10 @@ +
    + +
    @@ -78,4 +85,7 @@
    <%= button_to "Back", {:controller => 'courses', :action => 'index'}, class: "btn btn-success" , style: "margin-left: - 600px; margin-top: 250px", :method => :get%> \ No newline at end of file + 600px; margin-top: 250px", :method => :get%> +
    +
    +
    \ No newline at end of file diff --git a/tutor/app/views/courses/index.html.erb b/tutor/app/views/courses/index.html.erb index 37388dff..4f2b3e4b 100644 --- a/tutor/app/views/courses/index.html.erb +++ b/tutor/app/views/courses/index.html.erb @@ -1,57 +1,61 @@ -<% if !@courses.any? %> -

    You have no courses

    -<% end %> -<% if current_lecturer %> - <%= button_to "Create course", { :action => 'new', :controller => 'courses' }, { - class: 'btn btn-primary'} %> -<% end %> - -
    -<% if flash[:success_creation] %> -
    <%= flash[:success_creation] %>
    -<% end %> -<% if flash[:success_deletion] %> -
    <%= flash[:success_deletion] %>
    -<% end %> -
    - -<% if @courses.any? %> -

    Your Courses

    - - - - - - - - - <% @courses.each do |c| %> - - - - - - - + +
    +
    NameCodeOptions
    <%= link_to c.name, { :controller => 'courses', :action => 'show', :id => c.id }, - :method => :get, class: "btn btn-success" %><%= c.code %> - <% if current_lecturer %> - <%= link_to "Manage Course", { :controller => 'courses', :action => 'edit', - :method => :get, :id => c.id }, class: "btn btn-success", style: "text-decoration:none" %> - <% end %> - - <%= link_to "Discussion Board", { :controller => 'discussion_boards', :action => 'show', :id => c.id }, - class: "btn btn-success", method: :get, style: "text-decoration:none" %> - - <% if current_student %> - <% if @share[c.id] == "Show" %> - <%= button_to "Show Performance", {:controller => 'courses', :action => 'share', - :id => c.id, :value => true}, class: "btn btn-success", style: "text-decoration:none" %> - <% else %> - <%= button_to "Hide Performance", {:controller => 'courses', :action => 'share', - :id => c.id, :value => false}, class: "btn btn-success", style: "text-decoration:none" %> - <% end %> - <% end %> -
    -<% end %> + +
    +
    + <% if !@courses.any? %> +

    You have no courses

    + <% end %> +
    + <%= flash[:success_deletion] %> + <%= flash[:success_creation] %> + <% if @courses.any? %> +

    Your Courses

    + + + + + + + + + <% @courses.each do |c| %> + + + + + + + + <% end %> +
    NameCodeOptions
    <%= link_to c.name, { :controller => 'courses', :action => 'show', :id => c.id }, + :method => :get, class: "btn btn-success" %><%= c.code %> + <% if current_lecturer %> + <%= link_to "Manage Course", { :controller => 'courses', :action => 'edit', + :method => :get, :id => c.id }, class: "btn btn-success", style: "text-decoration:none" %> + <% end %> + + <%= link_to "Discussion Board", { :controller => 'discussion_boards', :action => 'show', :id => c.id }, + class: "btn btn-success", method: :get, style: "text-decoration:none" %> + + <% if current_student %> + <% if @share[c.id] == "Show" %> + <%= button_to "Show Performance", {:controller => 'courses', :action => 'share', + :id => c.id, :value => true}, class: "btn btn-success", style: "text-decoration:none" %> + <% else %> + <%= button_to "Hide Performance", {:controller => 'courses', :action => 'share', + :id => c.id, :value => false}, class: "btn btn-success", style: "text-decoration:none" %> + <% end %> + <% end %> +
    + <% end %> +
    +
    +
    diff --git a/tutor/app/views/courses/new.html.erb b/tutor/app/views/courses/new.html.erb index 15f67d88..fbacdd7f 100644 --- a/tutor/app/views/courses/new.html.erb +++ b/tutor/app/views/courses/new.html.erb @@ -1,58 +1,68 @@ -

    Create New Course

    + +
    + +
    +
    +

    Create New Course

    + <%= form_for :course, url: courses_path do |f| %> +

    + <%= f.label :Name %>
    + <% unless @new_course.errors[:name].blank? %> + + Name <%= @new_course.errors[:name].join(", ") %> + +
    + <% end %> + <%= f.text_field :name, :value => @new_course.name, class:"form-control", style: "width:300px" %> +

    +

    + <%= f.label :Code %>
    + <% unless @new_course.errors[:code].blank? %> + + Code <%= @new_course.errors[:code].join(", ") %> + +
    + <% end %> + <%= f.text_field :code, :value => @new_course.code, class:"form-control", style: "width:300px" %> +

    +

    + <%= f.label :Description %>
    + <% unless @new_course.errors[:description].blank? %> + + Description <%= @new_course.errors[:description].join(", ") %> + +
    + <% end %> + <%= f.text_area :description, class:"form-control", style:"width:300px",placeholder:"Description", :value => @new_course.description %> +

    +

    + <%= f.label :Semester %>
    + <% unless @new_course.errors[:semester].blank? %> + + Semester <%= @new_course.errors[:semester].join(", ") %> + +
    + <% end %> + <%= f.text_field :semester, :value => @new_course.semester, class:"form-control", style: "width:50px" %> +

    +

    + <%= f.label :Year %>
    + <% unless @new_course.errors[:year].blank? %> + + Year <%= @new_course.errors[:year].join(", ") %> + +
    + <% end %> + <%= f.text_field :year, :value => @new_course.year, class:"form-control", style: "width:100px" %> +

    +

    + <%= f.submit "Save", class: "btn btn-success" %> +

    <% end %> - <%= f.text_field :year, :value => @new_course.year, class:"form-control", style: "width:100px" %> -

    -

    - <%= f.submit "Save", class: "btn btn-success" %> -

    -<% end %> \ No newline at end of file +
    +
    +
    diff --git a/tutor/app/views/courses/show.html.erb b/tutor/app/views/courses/show.html.erb index d1574083..a0032e2f 100644 --- a/tutor/app/views/courses/show.html.erb +++ b/tutor/app/views/courses/show.html.erb @@ -1,50 +1,64 @@ -

    <%= @course.name %>

    -
    -
    -

    - Code: - <%= @course.code %> -

    -

    - Year: - <%= @course.year %> -

    -

    - Semester: - <%= @course.semester %> -

    -

    - Description: - <%= @course.description %> -

    -
    - -
    - <%= link_to "View Discussion Board", { :controller => 'discussion_boards', :action => 'show', :id => @course.id }, class: "btn btn-success", method: :get, style: "text-decoration:none" %> -
    +
    + +
    +
    +

    <%= @course.name %>

    +
    +
    +

    + Code: + <%= @course.code %> +

    +

    + Year: + <%= @course.year %> +

    +

    + Semester: + <%= @course.semester %> +

    +

    + Description: + <%= @course.description %> +

    +
    -
    - <% @topics.each do |t| %> -
    -
    - - <%= link_to t.title, t, style: 'color:#003366;'%> - <%= t.tracks.count %> +
    + <%= link_to "View Discussion Board", { :controller => 'discussion_boards', :action => 'show', :id => @course.id }, class: "btn btn-success", method: :get, style: "text-decoration:none" %>
    -
    -
      - <% t.tracks.each do |tt|%> - <% color = "label label-default" %> -
    • - <%= link_to tt.title, tt, class: color %> -
    • - <% end %> -
    + +
    + <% @topics.each do |t| %> +
    +
    + + <%= link_to t.title, t, style: 'color:#003366;'%> + <%= t.tracks.count %> +
    +
    +
      + <% t.tracks.each do |tt|%> + <% color = "label label-default" %> +
    • + <%= link_to tt.title, tt, class: color %> +
    • + <% end %> +
    +
    +
    + <% end %>
    -
    - <% end %> +
    +
    diff --git a/tutor/app/views/courses/sign_up.html.erb b/tutor/app/views/courses/sign_up.html.erb index 7ef61281..494e1fb6 100644 --- a/tutor/app/views/courses/sign_up.html.erb +++ b/tutor/app/views/courses/sign_up.html.erb @@ -1,69 +1,81 @@ - -

    Course Sign-Up

    - - - <% case @status%> - <% when "0" %> -

    Sorry, only students can sign up for courses!

    - <% when "1" %> -

    <%=@status%> / 6

    -

    Please choose a University

    - <% @courses.each do |course| %> - - - - <% end %> - <% when "2" %> -

    <%=@status%> / 6

    -

    Please choose a Semester

    - <% @courses.each do |course| %> - - - - <% end %> - <% when "3" %> -

    <%=@status%> / 6

    -

    Please choose a Course

    - <% @courses.each do |course| %> - - - - <% end %> - <% when "4" %> -

    <%=@status%> / 6

    -

    Pleas choose an Instructor

    - <% @course.lecturers.each do |lecturer| %> - - - - <% end %> - <% when "5" %> -

    <%=@status%> / 6

    -

    Semester: <%=@course.semester%> - Course: <%=@course.name%> - Instructor: <%=@lecturer.name%>

    - - - - <% when "6" %> -

    <%=@status%> / 6

    -

    You have signed up to:

    -

    Semester: <%=@course.semester%> - Course: <%=@course.name%> - Instructor: <%=@lecturer.name%>

    - <% when "7" %> -

    You are already signed up to this course!

    - <% end %> - -
    - <%= link_to(course.university, {:action => "sign_up", :university => course.university, - :status => "2"}) %> -
    - <%= link_to(course.semester, {:action => "sign_up", :university => params[:university], - :semester => course.semester, :status => "3"}) %> -
    - <%= link_to(course.name, {:action => "sign_up", :university => params[:university], - :semester =>course.semester, :id => course.id, :status => "4"} )%> -
    - <%= link_to(lecturer.name, {:action => "sign_up", :university => params[:university], - :semester =>@course.semester, :id => @course.id, :lecturer => lecturer.id, :status => "5"} )%> -
    - <%= link_to("Sign-Up!", {:action => "sign_up", :university => params[:university], - :semester => @course.semester, :id => @course.id, :lecturer => params[:lecturer], :status => "6"} )%> -
    \ No newline at end of file + +
    + +
    +
    + +

    Course Sign-Up

    + + + <% case @status%> + <% when "0" %> +

    Sorry, only students can sign up for courses!

    + <% when "1" %> +

    <%=@status%> / 6

    +

    Please choose a University

    + <% @courses.each do |course| %> + + + + <% end %> + <% when "2" %> +

    <%=@status%> / 6

    +

    Please choose a Semester

    + <% @courses.each do |course| %> + + + + <% end %> + <% when "3" %> +

    <%=@status%> / 6

    +

    Please choose a Course

    + <% @courses.each do |course| %> + + + + <% end %> + <% when "4" %> +

    <%=@status%> / 6

    +

    Pleas choose an Instructor

    + <% @course.lecturers.each do |lecturer| %> + + + + <% end %> + <% when "5" %> +

    <%=@status%> / 6

    +

    Semester: <%=@course.semester%> - Course: <%=@course.name%> - Instructor: <%=@lecturer.name%>

    + + + + <% when "6" %> +

    <%=@status%> / 6

    +

    You have signed up to:

    +

    Semester: <%=@course.semester%> - Course: <%=@course.name%> - Instructor: <%=@lecturer.name%>

    + <% when "7" %> +

    You are already signed up to this course!

    + <% end %> + +
    + <%= link_to(course.university, {:action => "sign_up", :university => course.university, + :status => "2"}) %> +
    + <%= link_to(course.semester, {:action => "sign_up", :university => params[:university], + :semester => course.semester, :status => "3"}) %> +
    + <%= link_to(course.name, {:action => "sign_up", :university => params[:university], + :semester =>course.semester, :id => course.id, :status => "4"} )%> +
    + <%= link_to(lecturer.name, {:action => "sign_up", :university => params[:university], + :semester =>@course.semester, :id => @course.id, :lecturer => lecturer.id, :status => "5"} )%> +
    + <%= link_to("Sign-Up!", {:action => "sign_up", :university => params[:university], + :semester => @course.semester, :id => @course.id, :lecturer => params[:lecturer], :status => "6"} )%> +
    +
    +
    +
    \ No newline at end of file From a9d09899b2a23226eacbd42c8a242ad068d37dc6 Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Thu, 24 Apr 2014 21:17:24 +0200 Subject: [PATCH 490/526] fixing indentations --- .../javascripts/solutions_constraints.js | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/tutor/app/assets/javascripts/solutions_constraints.js b/tutor/app/assets/javascripts/solutions_constraints.js index 1483ac96..6217872e 100644 --- a/tutor/app/assets/javascripts/solutions_constraints.js +++ b/tutor/app/assets/javascripts/solutions_constraints.js @@ -1,17 +1,17 @@ -// # 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/ +//# 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/ var type = new Array(); var param_name = new Array(); var var_type = new Array(); var var_name = new Array(); -// # [Add Solutions' constraints - Story 4.14] -// # Description: Adds the parameters from the text_fields to array -// # Parameters: none -// # Returns: none -// # Author: Ahmed Mohamed Magdi +//# [Add Solutions' constraints - Story 4.14] +//# Description: Adds the parameters from the text_fields to array +//# Parameters: none +//# Returns: none +//# Author: Ahmed Mohamed Magdi function add_params(field) { var tmp_type = document.getElementById("params_type").value; var tmp_name = document.getElementById("params_name").value; @@ -55,11 +55,11 @@ function add_params(field) { } } -// # [Add Solutions' constraints - Story 4.14] -// # Description: removes selected variable from method Contraints -// # Parameters: none -// # Returns: none -// # Author: Ahmed Mohamed Magdi +//# [Add Solutions' constraints - Story 4.14] +//# Description: removes selected variable from method Contraints +//# Parameters: none +//# Returns: none +//# Author: Ahmed Mohamed Magdi function remove_params(field) { var index = field.id.split("_")[1]; type.splice(index,1); @@ -83,11 +83,11 @@ function remove_params(field) { $('#parameter').append(""); } -// # [Add Solutions' constraints - Story 4.14] -// # Description: Adds the parameters from the text_fields to array -// # Parameters: none -// # Returns: none -// # Author: Ahmed Mohamed Magdi +//# [Add Solutions' constraints - Story 4.14] +//# Description: Adds the parameters from the text_fields to array +//# Parameters: none +//# Returns: none +//# Author: Ahmed Mohamed Magdi function add_variable(field) { var tmp_type = document.getElementById("variable_type").value; var tmp_name = document.getElementById("variable_name").value; @@ -131,11 +131,11 @@ function add_variable(field) { } } -// # [Add Solutions' constraints - Story 4.14] -// # Description: removes selected variable from Variable Contraints -// # Parameters: none -// # Returns: none -// # Author: Ahmed Mohamed Magdi +//# [Add Solutions' constraints - Story 4.14] +//# Description: removes selected variable from Variable Contraints +//# Parameters: none +//# Returns: none +//# Author: Ahmed Mohamed Magdi function remove_variable(field) { var index = field.id.split("_")[1]; var_type.splice(index,1); @@ -159,24 +159,24 @@ function remove_variable(field) { $('#variable').append(""); } -// # [Add Solutions' constraints - Story 4.14] -// # Description: for showing the error massages for the user -// # Parameters: -// # errorArray: array of Error, for multi error massage show -// # Returns: none -// # Author: Ahmed Mohamed Magdi +//# [Add Solutions' constraints - Story 4.14] +//# Description: for showing the error massages for the user +//# Parameters: +//# errorArray: array of Errors, for multi error massage show +//# Returns: none +//# Author: Ahmed Mohamed Magdi function showErrorMessage(arrayOfErrors) { for (var i = 0; i < arrayOfErrors.length; i++) { $("#errors").append("
    "+arrayOfErrors[i]+"
    "); }; } -// # [Add Solutions' constraints - Story 4.14] -// # Description: Validates Data before sending it to the Server side -// # Parameters: -// # errorArray: array of Error, for multi error massage show -// # Returns: none -// # Author: Ahmed Mohamed Magdi +//# [Add Solutions' constraints - Story 4.14] +//# Description: Validates Data before sending it to the Server side +//# Parameters: +//# errorArray: array of Errors, for multi error massage show +//# Returns: none +//# Author: Ahmed Mohamed Magdi function testingValidation(errorArray,method,name) { if (type.length == 0 && var_type.length == 0 && @@ -206,11 +206,11 @@ function testingValidation(errorArray,method,name) { return errorArray.length == 0; } -// # [Add Solutions' constraints - Story 4.14] -// # Description: submits via ajax to the controller -// # Parameters: none -// # Returns: none -// # Author: Ahmed Mohamed Magdi +//# [Add Solutions' constraints - Story 4.14] +//# Description: submits via ajax to the controller +//# Parameters: none +//# Returns: none +//# Author: Ahmed Mohamed Magdi function submitParams() { $("#errors").html(""); errorArray = new Array(); From cb7e1b92090830a0048355233824558fd2e29d81 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Thu, 24 Apr 2014 21:20:58 +0200 Subject: [PATCH 491/526] Fixed conflicts in posts controller --- tutor/app/controllers/posts_controller.rb | 7 +------ tutor/app/views/posts/edit.html.erb | 3 ++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index 6ef7e136..8cc453c3 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -12,12 +12,7 @@ def new @discussion_board = DiscussionBoard.find_by_id(params[:discussion_board_id]) @new_post = Post.new end - - def show - @post = Post.find(params[:id]) - @replies = @post.replies.order("created_at desc") - end - + # [Edit Post - Story 1.18] # Description: This action takes the passed post id # to be passed to the Edit form. diff --git a/tutor/app/views/posts/edit.html.erb b/tutor/app/views/posts/edit.html.erb index e8f20b3d..f15e2146 100644 --- a/tutor/app/views/posts/edit.html.erb +++ b/tutor/app/views/posts/edit.html.erb @@ -29,7 +29,8 @@

    <%= f.label :content %>
    <%= f.text_area :content, class:"form-control", style: "margin-left:auto; - margin-right:auto;height:200px;width:500px;resize:none", placeholder: "Enter your post",:value => @post.content%> + margin-right:auto;height:200px;width:500px;resize:none", + placeholder: "Enter your post",:value => @post.content%>

    <%= f.submit "Update Post", class: "btn btn-success" %> From 6c90bdfae53f854c66454ceafe6f0c3f1e2bd070 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Thu, 24 Apr 2014 21:29:05 +0200 Subject: [PATCH 492/526] Fixing conflicts in problem controller --- tutor/app/controllers/problems_controller.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tutor/app/controllers/problems_controller.rb b/tutor/app/controllers/problems_controller.rb index 7389b747..d5ba96aa 100644 --- a/tutor/app/controllers/problems_controller.rb +++ b/tutor/app/controllers/problems_controller.rb @@ -84,7 +84,6 @@ def new end end -<<<<<<< HEAD # [Remove Problem - Story 4.18] # This action takes the problem id, remove it from the database # and then redirects the user to the show page of the track that had the problem @@ -103,7 +102,6 @@ def destroy end end -======= # [Edit Problem - 4.5] # Update the problem's title or description # Parameters: @@ -178,5 +176,5 @@ def done def problem_params params.require(:Problem).permit(:title, :description, :track_id) end ->>>>>>> master + end \ No newline at end of file From ba340937815d4f7e41f6ee56b740da64ececf51e Mon Sep 17 00:00:00 2001 From: Mohab Date: Thu, 24 Apr 2014 21:29:21 +0200 Subject: [PATCH 493/526] fixing TA problem --- tutor/app/views/courses/index.html.erb | 2 +- tutor/app/views/courses/new.html.erb | 2 +- tutor/app/views/courses/show.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tutor/app/views/courses/index.html.erb b/tutor/app/views/courses/index.html.erb index 4f2b3e4b..0ce82820 100644 --- a/tutor/app/views/courses/index.html.erb +++ b/tutor/app/views/courses/index.html.erb @@ -4,7 +4,7 @@

  • My Courses
  • <% if lecturer_signed_in? %>
  • Create new Course
  • - <% else %> + <% elsif student_signed_in? %>
  • Sign up for a course
  • <% end %> diff --git a/tutor/app/views/courses/new.html.erb b/tutor/app/views/courses/new.html.erb index fbacdd7f..70618fcf 100644 --- a/tutor/app/views/courses/new.html.erb +++ b/tutor/app/views/courses/new.html.erb @@ -65,4 +65,4 @@ <% end %>
    -
    +
    \ No newline at end of file diff --git a/tutor/app/views/courses/show.html.erb b/tutor/app/views/courses/show.html.erb index a0032e2f..18f5a9e4 100644 --- a/tutor/app/views/courses/show.html.erb +++ b/tutor/app/views/courses/show.html.erb @@ -3,7 +3,7 @@
  • My Courses
  • <% if lecturer_signed_in? %>
  • Create new Course
  • - <% else %> + <% elsif student_signed_in? %>
  • Sign up for a course
  • <% end %> From ec8cf1129432b8d561c08ac730c58c6123631e00 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Thu, 24 Apr 2014 21:36:05 +0200 Subject: [PATCH 494/526] Fixed typo --- tutor/app/views/problems/edit.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/views/problems/edit.html.erb b/tutor/app/views/problems/edit.html.erb index ee3ce125..6bf63c14 100644 --- a/tutor/app/views/problems/edit.html.erb +++ b/tutor/app/views/problems/edit.html.erb @@ -25,7 +25,7 @@
    <%= render partial: "test_cases/index" %> -<%= render partial: "model_answers/new" %> +<%= render partial: "model_answers/index" %> <%= render partial: "problems/success_options" %> <% if flash[:notice] %> From 6ec78f639ff17ea0c9eda66496b6c9c5febb055f Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Thu, 24 Apr 2014 21:49:01 +0200 Subject: [PATCH 495/526] hadling error --- tutor/app/assets/javascripts/solutions_constraints.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutor/app/assets/javascripts/solutions_constraints.js b/tutor/app/assets/javascripts/solutions_constraints.js index 6217872e..4b764148 100644 --- a/tutor/app/assets/javascripts/solutions_constraints.js +++ b/tutor/app/assets/javascripts/solutions_constraints.js @@ -161,8 +161,8 @@ function remove_variable(field) { //# [Add Solutions' constraints - Story 4.14] //# Description: for showing the error massages for the user -//# Parameters: -//# errorArray: array of Errors, for multi error massage show +//# Parameters: +//# errorArray: array of Errors,for multi error massage show //# Returns: none //# Author: Ahmed Mohamed Magdi function showErrorMessage(arrayOfErrors) { @@ -173,8 +173,8 @@ function showErrorMessage(arrayOfErrors) { //# [Add Solutions' constraints - Story 4.14] //# Description: Validates Data before sending it to the Server side -//# Parameters: -//# errorArray: array of Errors, for multi error massage show +//# Parameters: +//# method_cons: Hash containting the Method parameters //# Returns: none //# Author: Ahmed Mohamed Magdi function testingValidation(errorArray,method,name) { From a31d85f4a7d8364e30856c651019834652ef543e Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Thu, 24 Apr 2014 22:06:38 +0200 Subject: [PATCH 496/526] adding space before tag --- tutor/app/views/courses/edit.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutor/app/views/courses/edit.html.erb b/tutor/app/views/courses/edit.html.erb index 4ea8a085..32b758d5 100644 --- a/tutor/app/views/courses/edit.html.erb +++ b/tutor/app/views/courses/edit.html.erb @@ -85,7 +85,7 @@
    <%= button_to "Back", {:controller => 'courses', :action => 'index'}, class: "btn btn-success" , style: "margin-left: - 600px; margin-top: 250px", :method => :get%> + 600px; margin-top: 250px", :method => :get %>
    -
    \ No newline at end of file +
    From 33e35e6588571e0e1542f8508c0c74b6c4ab4cc1 Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Thu, 24 Apr 2014 22:09:19 +0200 Subject: [PATCH 497/526] adding space before tag --- tutor/app/views/courses/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/views/courses/show.html.erb b/tutor/app/views/courses/show.html.erb index 18f5a9e4..62dad37a 100644 --- a/tutor/app/views/courses/show.html.erb +++ b/tutor/app/views/courses/show.html.erb @@ -49,7 +49,7 @@ <% t.tracks.each do |tt|%> <% color = "label label-default" %>
  • + data-placement="top" title="<%= tt.difficulty %>"> <%= link_to tt.title, tt, class: color %>
  • <% end %> From 46271ed02ddaaaa69c57af75903bb111b7a21b60 Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Thu, 24 Apr 2014 22:09:53 +0200 Subject: [PATCH 498/526] removing empty line --- tutor/app/views/courses/sign_up.html.erb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tutor/app/views/courses/sign_up.html.erb b/tutor/app/views/courses/sign_up.html.erb index 494e1fb6..47b7d4f0 100644 --- a/tutor/app/views/courses/sign_up.html.erb +++ b/tutor/app/views/courses/sign_up.html.erb @@ -3,7 +3,6 @@
    @@ -78,4 +77,4 @@
    -
    \ No newline at end of file +
    From 0b137cf619c5ab85f969c4429855f76d8f1d8917 Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Thu, 24 Apr 2014 22:11:05 +0200 Subject: [PATCH 499/526] removing empty line --- tutor/app/views/courses/edit.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/tutor/app/views/courses/edit.html.erb b/tutor/app/views/courses/edit.html.erb index 32b758d5..9eb04e8d 100644 --- a/tutor/app/views/courses/edit.html.erb +++ b/tutor/app/views/courses/edit.html.erb @@ -2,7 +2,6 @@
    + +<%= link_to "back", {:action => 'show', :controller => 'discussion_boards', + :id => DiscussionBoard.find_by_id(@post.discussion_board_id).course_id}, { + class: 'btn btn-primary'} %>
    <% if current_lecturer %> <% @userID = current_lecturer.id %> <% end %> - <% if current_student %> - <% @userID = current_student.id %> - <% end %> - <%if current_teaching_assistant %> - <% @userID = current_teaching_assistant.id %> - <%end%> + <% if current_student %> + <% @userID = current_student.id %> + <% end %> + <%if current_teaching_assistant %> + <% @userID = current_teaching_assistant.id %> + <% end %>

    <%=@post.title%>

    <%= @post.content %> @@ -27,5 +34,4 @@ <%= link_to "Edit Post", {:action => 'edit', :controller => 'posts'}, { class: 'btn btn-primary',:id => @post.id} %> <% end %> -
    \ No newline at end of file From f8a147892547a70d77b5317ef2b3e01119166283 Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Thu, 24 Apr 2014 22:14:20 +0200 Subject: [PATCH 503/526] fixing extra lines --- tutor/app/views/solutions_constraints/_edit_method.html.erb | 1 - tutor/app/views/solutions_constraints/new.html.erb | 2 -- 2 files changed, 3 deletions(-) diff --git a/tutor/app/views/solutions_constraints/_edit_method.html.erb b/tutor/app/views/solutions_constraints/_edit_method.html.erb index 08cca49a..3c85741b 100644 --- a/tutor/app/views/solutions_constraints/_edit_method.html.erb +++ b/tutor/app/views/solutions_constraints/_edit_method.html.erb @@ -28,5 +28,4 @@

    <%= f.submit "Save Changes", class: "btn btn-default", onclick:"submitParams();" %> - <% end %> \ No newline at end of file diff --git a/tutor/app/views/solutions_constraints/new.html.erb b/tutor/app/views/solutions_constraints/new.html.erb index 5b1f6ed3..c732821c 100644 --- a/tutor/app/views/solutions_constraints/new.html.erb +++ b/tutor/app/views/solutions_constraints/new.html.erb @@ -1,6 +1,5 @@
    -

    Add Method Constraints


    - <%= render 'form' %> \ No newline at end of file From 1bf3d3c863f26a50bb746372f685738fc0f09345 Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Thu, 24 Apr 2014 22:16:45 +0200 Subject: [PATCH 504/526] dividing line --- tutor/app/views/courses/new.html.erb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tutor/app/views/courses/new.html.erb b/tutor/app/views/courses/new.html.erb index 70618fcf..c754a63d 100644 --- a/tutor/app/views/courses/new.html.erb +++ b/tutor/app/views/courses/new.html.erb @@ -37,7 +37,8 @@
    <% end %> - <%= f.text_area :description, class:"form-control", style:"width:300px",placeholder:"Description", :value => @new_course.description %> + <%= f.text_area :description, class:"form-control", style:"width:300px", + placeholder:"Description", :value => @new_course.description %>

    <%= f.label :Semester %>
    @@ -65,4 +66,4 @@ <% end %>

    - \ No newline at end of file + From 63491981aae6a95c8a4d141edcf71b5bbcf0f718 Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Thu, 24 Apr 2014 22:18:09 +0200 Subject: [PATCH 505/526] fixing indentation --- tutor/app/views/courses/show.html.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutor/app/views/courses/show.html.erb b/tutor/app/views/courses/show.html.erb index 62dad37a..b2d10b43 100644 --- a/tutor/app/views/courses/show.html.erb +++ b/tutor/app/views/courses/show.html.erb @@ -39,10 +39,10 @@
    - - <%= link_to t.title, t, style: 'color:#003366;'%> - <%= t.tracks.count %> + href="#<%= t.id.to_s %>"> + + <%= link_to t.title, t, style: 'color:#003366;'%> + <%= t.tracks.count %>
      From f05b955ece4e7503700084812ad0f2c9fe0caa13 Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Thu, 24 Apr 2014 22:18:47 +0200 Subject: [PATCH 506/526] dividing line --- tutor/app/views/courses/show.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tutor/app/views/courses/show.html.erb b/tutor/app/views/courses/show.html.erb index b2d10b43..2e9d15b3 100644 --- a/tutor/app/views/courses/show.html.erb +++ b/tutor/app/views/courses/show.html.erb @@ -31,7 +31,8 @@
    - <%= link_to "View Discussion Board", { :controller => 'discussion_boards', :action => 'show', :id => @course.id }, class: "btn btn-success", method: :get, style: "text-decoration:none" %> + <%= link_to "View Discussion Board", { :controller => 'discussion_boards', + :action => 'show', :id => @course.id }, class: "btn btn-success", method: :get, style: "text-decoration:none" %>
    From 8ac7f01cd8f78008355d825104ca07dbacbcf1c4 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Thu, 24 Apr 2014 22:21:07 +0200 Subject: [PATCH 507/526] fixed inentation --- tutor/app/views/posts/edit.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tutor/app/views/posts/edit.html.erb b/tutor/app/views/posts/edit.html.erb index 27a06347..cc0791e9 100644 --- a/tutor/app/views/posts/edit.html.erb +++ b/tutor/app/views/posts/edit.html.erb @@ -24,16 +24,16 @@ <%= form_for :post, url: {action: "update", :id => @post.id} do |f| %>

    <%= f.label "Title" %>
    - <%= f.text_field :title, autofocus: true, class:"form-control", style: "width:300px", placeholder: "Title",:value => @post.title%> + <%= f.text_field :title, autofocus: true, class:"form-control", style: "width:300px", placeholder: "Title",:value => @post.title %>

    <%= f.label :content %>
    <%= f.text_area :content, class:"form-control", style: "margin-left:auto; margin-right:auto;height:200px;width:500px;resize:none", - placeholder: "Enter your post",:value => @post.content%> + placeholder: "Enter your post",:value => @post.content %>

    - <%= f.submit "Update Post", class: "btn btn-success" %> + <%= f.submit "Update Post", class: "btn btn-success" %>

    <% end %>
    \ No newline at end of file From 80946180269e3c59838cac18357487d380c598f5 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Thu, 24 Apr 2014 22:23:53 +0200 Subject: [PATCH 508/526] fixed extra tab --- tutor/app/controllers/posts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index 8cc453c3..4caafb62 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -80,7 +80,7 @@ def create # Returns: # flash[:notice]: A message indicating the success or failure of the creation # Author: Ahmed Atef - def update + def update @post = Post.find(params[:id]) if @post.update_attributes(post_params) flash[:notice] = "Post successfully updated" From a260fc3abb2a360bb2bfd03a29d9a160e8f3b321 Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Thu, 24 Apr 2014 22:25:24 +0200 Subject: [PATCH 509/526] adding space before tag --- tutor/app/views/courses/sign_up.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/views/courses/sign_up.html.erb b/tutor/app/views/courses/sign_up.html.erb index 47b7d4f0..9ed4a190 100644 --- a/tutor/app/views/courses/sign_up.html.erb +++ b/tutor/app/views/courses/sign_up.html.erb @@ -69,7 +69,7 @@ <% when "6" %>

    <%=@status%> / 6

    You have signed up to:

    -

    Semester: <%=@course.semester%> - Course: <%=@course.name%> - Instructor: <%=@lecturer.name%>

    +

    Semester: <%=@course.semester%> - Course: <%= @course.name %> - Instructor: <%= @lecturer.name %>

    <% when "7" %>

    You are already signed up to this course!

    <% end %> From 57a0c8af72748bffb0ee73e28f7f1e519569c73d Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Thu, 24 Apr 2014 22:29:50 +0200 Subject: [PATCH 510/526] fixing long lines --- .../views/solutions_constraints/_edit_method.html.erb | 5 +++-- tutor/app/views/solutions_constraints/_form.html.erb | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tutor/app/views/solutions_constraints/_edit_method.html.erb b/tutor/app/views/solutions_constraints/_edit_method.html.erb index 3c85741b..f3ea8d16 100644 --- a/tutor/app/views/solutions_constraints/_edit_method.html.erb +++ b/tutor/app/views/solutions_constraints/_edit_method.html.erb @@ -17,8 +17,9 @@ <%= u.text_field :parameter, placeholder: "Variable Name", id:"params_name" %> - <%= image_tag "add_buttom.png", id:"params", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", - onclick: "add_params(this);" %> + <%= image_tag "add_buttom.png", id:"params", + style: "width:15%;height:15%;margin_top:10px;cursor:pointer", + onclick: "add_params(this);" %> <% end %> diff --git a/tutor/app/views/solutions_constraints/_form.html.erb b/tutor/app/views/solutions_constraints/_form.html.erb index 47407cc0..681fa266 100644 --- a/tutor/app/views/solutions_constraints/_form.html.erb +++ b/tutor/app/views/solutions_constraints/_form.html.erb @@ -17,7 +17,8 @@ <%= u.text_field :parameter, placeholder: "Variable Name", id:"params_name" %> - <%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", + <%= image_tag "add_buttom.png", + style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_params(this);" %> <% end %> @@ -42,7 +43,8 @@ <%= u.text_field :variable_name, placeholder: "Variable Name", id:"variable_name" %> - <%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", + <%= image_tag "add_buttom.png", + style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_variable(this);" %> <% end %> @@ -56,5 +58,6 @@

    No variables


    - <%= button_tag "Save Changes", type: "button", class: "btn btn-large btn-success", onclick:"submitParams();" %> + <%= button_tag "Save Changes", type: "button", + class: "btn btn-large btn-success", onclick:"submitParams();" %> <% end %> \ No newline at end of file From 9c7132d20ab74367f73c579584ca75ed6400095b Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Thu, 24 Apr 2014 22:32:00 +0200 Subject: [PATCH 511/526] fixing indentations --- tutor/app/views/solutions_constraints/_form.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutor/app/views/solutions_constraints/_form.html.erb b/tutor/app/views/solutions_constraints/_form.html.erb index 681fa266..68380f1d 100644 --- a/tutor/app/views/solutions_constraints/_form.html.erb +++ b/tutor/app/views/solutions_constraints/_form.html.erb @@ -20,7 +20,7 @@ <%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_params(this);" %> - <% end %> + <% end %> @@ -46,7 +46,7 @@ <%= image_tag "add_buttom.png", style: "width:15%;height:15%;margin_top:10px;cursor:pointer", onclick: "add_variable(this);" %> - <% end %> + <% end %>
    From 0ae37827577adde5619af024068d376c30438542 Mon Sep 17 00:00:00 2001 From: ahmed93 Date: Thu, 24 Apr 2014 22:37:22 +0200 Subject: [PATCH 512/526] fixing lines --- tutor/app/controllers/solutions_constraints_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/tutor/app/controllers/solutions_constraints_controller.rb b/tutor/app/controllers/solutions_constraints_controller.rb index a5f966a6..9955a709 100644 --- a/tutor/app/controllers/solutions_constraints_controller.rb +++ b/tutor/app/controllers/solutions_constraints_controller.rb @@ -48,4 +48,5 @@ def create def new constrain = MethodConstraint.new end + end From a7068d30d9d7cb7139116f285b83567f2c46ab30 Mon Sep 17 00:00:00 2001 From: Mohab Date: Thu, 24 Apr 2014 22:37:34 +0200 Subject: [PATCH 513/526] removing image magic --- .../views/lecturers/registrations/new.html.erb | 9 --------- .../views/students/registrations/new.html.erb | 16 ---------------- .../registrations/new.html.erb | 11 +---------- 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/tutor/app/views/lecturers/registrations/new.html.erb b/tutor/app/views/lecturers/registrations/new.html.erb index 591f53f8..221650d5 100644 --- a/tutor/app/views/lecturers/registrations/new.html.erb +++ b/tutor/app/views/lecturers/registrations/new.html.erb @@ -44,15 +44,6 @@ <%= f.text_field :department, class: "form-control", placeholder: "Department" %>
    -
    -
    - <%= f.label :profile_image %>
    - <%= image_tag(@lecturer.profile_image_url.to_s) if @lecturer.profile_image? %> - <%= f.file_field :profile_image, {:accept => 'image/png,image/gif,image/jpeg'} %> - <%= f.hidden_field :profile_image_cache %> -
    -
    -
    <%= f.submit "Sign up", class: "btn btn-success button-devise" %>
    <% end %> diff --git a/tutor/app/views/students/registrations/new.html.erb b/tutor/app/views/students/registrations/new.html.erb index d80e79b0..1d0d9265 100644 --- a/tutor/app/views/students/registrations/new.html.erb +++ b/tutor/app/views/students/registrations/new.html.erb @@ -48,22 +48,6 @@ <%= f.number_field :semester, class: "form-control", placeholder: "Semester" %> -
    - <%= f.label :advising %> - <%= f.select(:advising, [['No', false], ['Yes', true]]) %> - <%= f.label :probation %> - <%= f.select(:probation, [['No', false], ['Yes', true]]) %> -
    - -
    -
    - <%= f.label :profile_image %>
    - <%= image_tag(@student.profile_image_url.to_s) if @student.profile_image? %> - <%= f.file_field :profile_image, {:accept => 'image/png,image/gif,image/jpeg'} %> - <%= f.hidden_field :profile_image_cache %> -
    -
    -
    <%= f.submit "Sign up", class: "btn btn-success button-devise" %>
    <% end %> diff --git a/tutor/app/views/teaching_assistants/registrations/new.html.erb b/tutor/app/views/teaching_assistants/registrations/new.html.erb index 434617da..4043f1d0 100644 --- a/tutor/app/views/teaching_assistants/registrations/new.html.erb +++ b/tutor/app/views/teaching_assistants/registrations/new.html.erb @@ -51,16 +51,7 @@
    <%= f.text_field :department, class: "form-control", placeholder: "Department" %>
    - -
    -
    - <%= f.label :profile_image %>
    - <%= image_tag(@teaching_assistant.profile_image_url.to_s) if @teaching_assistant.profile_image? %> - <%= f.file_field :profile_image, {:accept => 'image/png,image/gif,image/jpeg'} %> - <%= f.hidden_field :profile_image_cache %> -
    -
    - +
    <%= f.submit "Sign up", class: "btn btn-success button-devise" %>
    <% end %> From 0accf4fa7a886d019ca581b25eae894a870f9522 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Thu, 24 Apr 2014 22:37:42 +0200 Subject: [PATCH 514/526] Extra line --- tutor/app/views/discussion_boards/show.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/tutor/app/views/discussion_boards/show.html.erb b/tutor/app/views/discussion_boards/show.html.erb index f5889c0a..07d27796 100644 --- a/tutor/app/views/discussion_boards/show.html.erb +++ b/tutor/app/views/discussion_boards/show.html.erb @@ -11,7 +11,6 @@ <%= link_to post.title, :controller => 'posts', :action=> 'show', :id => post.id,:method => :get, class: "btn btn-success" %> ->>>>>>> 7eb9faa02cd949c47035b7b7f69f9e74a5f97b7d <%= post.views_count %>
    From ec0f151de3e86c484ff804465866889188e703fe Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Thu, 24 Apr 2014 22:39:12 +0200 Subject: [PATCH 515/526] conflicts with master --- tutor/app/controllers/posts_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index c3844454..1adf7bbf 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -40,10 +40,11 @@ def edit # flash[:notice]: A message indicating the success of the deletion # Author: Ahmed Atef def destroy - @dis = Post.find_by_id(params[:id]).discussion_board_id + @disscusion_board = Post.find_by_id(params[:id]).discussion_board_id if Post.find_by_id(params[:id]).destroy flash[:notice] = "Post successfully Deleted" - redirect_to(:controller => 'discussion_boards' , :action => 'show' ,:id => @dis) + redirect_to(:controller => 'discussion_boards' , + :action => 'show' ,:id => @disscussion_board) end end # [Add Post - Story 1.13] From b2dec3e4ea61660009f901aabc751559edfebdc7 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Thu, 24 Apr 2014 22:47:49 +0200 Subject: [PATCH 516/526] fixed conflicts --- tutor/config/routes.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index 615ef930..8c167b04 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -17,15 +17,11 @@ post 'courses/new' => 'courses#new' post 'courses/share' => 'courses#share' get 'courses/sign_up' -<<<<<<< HEAD - post 'posts/new' => 'posts#new' post '/posts/:id' => 'posts#update' -======= get 'tracks/show_classmates/:id' => 'tracks#show_classmates' post 'tracks/insert_recommendation' => 'tracks#insert_recommendation' post 'solutions/execute' => 'problems#show' post 'debuggers/:id' => 'debuggers#start' ->>>>>>> 7eb9faa02cd949c47035b7b7f69f9e74a5f97b7d # You can have the root of your site routed with "root" root 'site#index' From 5805c141ad31b33cb45c6ac5ce8fb89cb41534cf Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Fri, 25 Apr 2014 01:52:13 +0200 Subject: [PATCH 517/526] fixed indentaiton --- tutor/app/controllers/posts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index 8cf0bfe7..657ef770 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -60,7 +60,7 @@ def show # and assigns it to the respective discussion board.If the # creation fails the user is redirected to the form # Parameters: - # topic_params[]: A list that has all fields entered by the user to in the + # topic_params[]: A list that has all fields entered by the user to in the # add_post_form # Returns: # flash[:notice]: A message indicating the success or failure of the creation From 43ab6bb75ebf37f2ae63d0a0ffb855a0d31aa3da Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Fri, 25 Apr 2014 02:21:05 +0200 Subject: [PATCH 518/526] fixed redirect in destroy funtion and fixed button delete post --- tutor/app/controllers/posts_controller.rb | 7 ++++--- tutor/app/views/posts/edit.html.erb | 4 ++-- tutor/app/views/posts/show.html.erb | 24 ----------------------- 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index 657ef770..9e7558eb 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -35,11 +35,12 @@ def edit # flash[:notice]: A message indicating the success of the deletion # Author: Ahmed Atef def destroy - @disscusion_board = Post.find_by_id(params[:id]).discussion_board_id + @disscusion_board = DiscussionBoard.find_by_id + (Post.find_by_id(params[:id]).discussion_board_id) if Post.find_by_id(params[:id]).destroy flash[:notice] = "Post successfully Deleted" redirect_to(:controller => 'discussion_boards' , - :action => 'show' ,:id => @disscussion_board) + :action => 'show' ,:id => @disscusion_board.course_id) end end # [Add Post - Story 1.13] @@ -93,7 +94,7 @@ def create # update fails the user is redirected to the form # Parameters: # topic_params[]: A list that has all fields entered by the user to in the - # Edit_post_form + # Edit_post_form # Returns: # flash[:notice]: A message indicating the success or failure of the creation # Author: Ahmed Atef diff --git a/tutor/app/views/posts/edit.html.erb b/tutor/app/views/posts/edit.html.erb index 9748159e..76530768 100644 --- a/tutor/app/views/posts/edit.html.erb +++ b/tutor/app/views/posts/edit.html.erb @@ -36,6 +36,6 @@ <%= f.submit "Update Post", class: "btn btn-success" %>

    <% end %> - <%= button_to "Delete Post", {:action => 'destroy'}, method: :delete, - class: 'btn btn-primary',:id => params[:id] , :confirm => "Are you sure??" %> + <%= button_to "Delete Post", {:action => 'destroy', :id => params[:id]}, method: :delete, + class: 'btn btn-primary', :confirm => "Are you sure??" %> \ No newline at end of file diff --git a/tutor/app/views/posts/show.html.erb b/tutor/app/views/posts/show.html.erb index 5d4af1c5..6b06d14c 100644 --- a/tutor/app/views/posts/show.html.erb +++ b/tutor/app/views/posts/show.html.erb @@ -6,10 +6,6 @@ :id => DiscussionBoard.find_by_id(@post.discussion_board_id).course_id}, { class: 'btn btn-primary'} %>
    -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> 9f5d2de792278daa7a008d66fca60495ffe3465e <% if current_lecturer %> <% @userID = current_lecturer.id %> <% end %> @@ -38,24 +34,4 @@ <%= link_to "Edit Post", {:action => 'edit', :controller => 'posts'}, { class: 'btn btn-primary',:id => @post.id} %> <% end %> -<<<<<<< HEAD -======= -
    -

    <%=@post.title%>

    - <%= @post.content %> -
    - <% unless @replies.blank? %> - <% @replies.each do |reply| %> -
    - <%= reply.content %>
    -
    -
    - <% end %> - <% else %> - No Replies in this post yet . - <% end %> -
    ->>>>>>> 7eb9faa02cd949c47035b7b7f69f9e74a5f97b7d -======= ->>>>>>> 9f5d2de792278daa7a008d66fca60495ffe3465e
    \ No newline at end of file From cb2c59ab2a43d18d4ec0ce404f4570ce9d1aaf73 Mon Sep 17 00:00:00 2001 From: Mohab Date: Fri, 25 Apr 2014 02:25:50 +0200 Subject: [PATCH 519/526] Placing System recommendations in right side bar --- tutor/app/views/layouts/_right_side_bar.html.erb | 10 ++++++++++ tutor/app/views/layouts/application.html.erb | 1 - .../app/views/problems/_system_recommendation.html.erb | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tutor/app/views/layouts/_right_side_bar.html.erb b/tutor/app/views/layouts/_right_side_bar.html.erb index 58035bf4..08663f35 100644 --- a/tutor/app/views/layouts/_right_side_bar.html.erb +++ b/tutor/app/views/layouts/_right_side_bar.html.erb @@ -57,6 +57,16 @@ <% end %> +
    + + + + + +
    System Recommendations
    + <%= render "problems/system_recommendation" if student_signed_in? %> +
    +
    <% end %> \ No newline at end of file diff --git a/tutor/app/views/layouts/application.html.erb b/tutor/app/views/layouts/application.html.erb index fca81845..a69400de 100644 --- a/tutor/app/views/layouts/application.html.erb +++ b/tutor/app/views/layouts/application.html.erb @@ -50,7 +50,6 @@
    <%= render "layouts/right_side_bar" %>
    - <%= render "problems/system_recommendation" if student_signed_in? %> <%= yield %>
    diff --git a/tutor/app/views/problems/_system_recommendation.html.erb b/tutor/app/views/problems/_system_recommendation.html.erb index 4682f010..afedfb52 100644 --- a/tutor/app/views/problems/_system_recommendation.html.erb +++ b/tutor/app/views/problems/_system_recommendation.html.erb @@ -1,7 +1,7 @@ <% suggestion = current_student.get_a_system_suggested_problem if suggestion != nil then - concat link_to "Recommended problem: " + suggestion.title, suggestion + concat link_to suggestion.title, suggestion %>
    <% end %> \ No newline at end of file From cc6a78d5e4639760868e61cdf7929cce975c4b85 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Fri, 25 Apr 2014 02:44:32 +0200 Subject: [PATCH 520/526] Fixed indentation and removed extra space --- tutor/app/controllers/posts_controller.rb | 7 ++++--- tutor/app/views/posts/show.html.erb | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index 9e7558eb..51924c1a 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -39,10 +39,11 @@ def destroy (Post.find_by_id(params[:id]).discussion_board_id) if Post.find_by_id(params[:id]).destroy flash[:notice] = "Post successfully Deleted" - redirect_to(:controller => 'discussion_boards' , - :action => 'show' ,:id => @disscusion_board.course_id) + redirect_to(:controller => 'discussion_boards', + :action => 'show', :id => @disscusion_board.course_id) end - end + end + # [Add Post - Story 1.13] # Description: Displays the post that the user chose # Parameters: diff --git a/tutor/app/views/posts/show.html.erb b/tutor/app/views/posts/show.html.erb index 6b06d14c..8d0756e0 100644 --- a/tutor/app/views/posts/show.html.erb +++ b/tutor/app/views/posts/show.html.erb @@ -32,6 +32,6 @@ <% if @post.owner_id == @userID %> <%= link_to "Edit Post", {:action => 'edit', :controller => 'posts'}, { - class: 'btn btn-primary',:id => @post.id} %> + class: 'btn btn-primary',:id => @post.id} %> <% end %> \ No newline at end of file From 81b057ceaa5eeae28d65fa7cb054ef46a436d7f0 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Fri, 25 Apr 2014 02:46:58 +0200 Subject: [PATCH 521/526] removed extra tabs --- tutor/app/views/posts/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/views/posts/show.html.erb b/tutor/app/views/posts/show.html.erb index 8d0756e0..7f06d3b2 100644 --- a/tutor/app/views/posts/show.html.erb +++ b/tutor/app/views/posts/show.html.erb @@ -32,6 +32,6 @@ <% if @post.owner_id == @userID %> <%= link_to "Edit Post", {:action => 'edit', :controller => 'posts'}, { - class: 'btn btn-primary',:id => @post.id} %> + class: 'btn btn-primary',:id => @post.id} %> <% end %> \ No newline at end of file From 2546e0cfaf6625965473fa8d02654cc359db3f9e Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Fri, 25 Apr 2014 02:57:07 +0200 Subject: [PATCH 522/526] Fixed wrong indentation --- tutor/app/views/posts/edit.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/views/posts/edit.html.erb b/tutor/app/views/posts/edit.html.erb index 76530768..2a22740a 100644 --- a/tutor/app/views/posts/edit.html.erb +++ b/tutor/app/views/posts/edit.html.erb @@ -36,6 +36,6 @@ <%= f.submit "Update Post", class: "btn btn-success" %>

    <% end %> - <%= button_to "Delete Post", {:action => 'destroy', :id => params[:id]}, method: :delete, + <%= button_to "Delete Post", {:action => 'destroy', :id => params[:id]}, method: :delete, class: 'btn btn-primary', :confirm => "Are you sure??" %> \ No newline at end of file From 0ad4ae7ffae9a1db0c99911619c922e478510f81 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Fri, 25 Apr 2014 03:07:36 +0200 Subject: [PATCH 523/526] Fixed indentation and removed extra spaces --- tutor/app/controllers/posts_controller.rb | 14 +++++++------- tutor/app/views/discussion_boards/show.html.erb | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index 51924c1a..ab30d6ca 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -35,13 +35,13 @@ def edit # flash[:notice]: A message indicating the success of the deletion # Author: Ahmed Atef def destroy - @disscusion_board = DiscussionBoard.find_by_id - (Post.find_by_id(params[:id]).discussion_board_id) - if Post.find_by_id(params[:id]).destroy - flash[:notice] = "Post successfully Deleted" - redirect_to(:controller => 'discussion_boards', - :action => 'show', :id => @disscusion_board.course_id) - end + @disscusion_board = DiscussionBoard.find_by_id + (Post.find_by_id(params[:id]).discussion_board_id) + if Post.find_by_id(params[:id]).destroy + flash[:notice] = "Post successfully Deleted" + redirect_to(:controller => 'discussion_boards', + :action => 'show', :id => @disscusion_board.course_id) + end end # [Add Post - Story 1.13] diff --git a/tutor/app/views/discussion_boards/show.html.erb b/tutor/app/views/discussion_boards/show.html.erb index 07d27796..7733d2f5 100644 --- a/tutor/app/views/discussion_boards/show.html.erb +++ b/tutor/app/views/discussion_boards/show.html.erb @@ -1,7 +1,7 @@
    <% if flash[:notice] %> -
    <%= flash[:notice] %>
    - <% end %> +
    <%= flash[:notice] %>
    + <% end %> <% if @discussionBoard.activated == true %>

    <%= @discussionBoard.title %>

    From 2c552e0a62f9357050acbbaf0c79e969a422a6b9 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Fri, 25 Apr 2014 03:16:13 +0200 Subject: [PATCH 524/526] Added missing tab --- tutor/app/views/discussion_boards/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/views/discussion_boards/show.html.erb b/tutor/app/views/discussion_boards/show.html.erb index 7733d2f5..9688d8b1 100644 --- a/tutor/app/views/discussion_boards/show.html.erb +++ b/tutor/app/views/discussion_boards/show.html.erb @@ -1,6 +1,6 @@
    <% if flash[:notice] %> -
    <%= flash[:notice] %>
    +
    <%= flash[:notice] %>
    <% end %> <% if @discussionBoard.activated == true %>
    From a88cf2bbb80bfa10188b6fc0221679640f80ebe0 Mon Sep 17 00:00:00 2001 From: Ahmed Atef Date: Fri, 25 Apr 2014 03:37:11 +0200 Subject: [PATCH 525/526] removed extra tab --- tutor/app/controllers/posts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/app/controllers/posts_controller.rb b/tutor/app/controllers/posts_controller.rb index ab30d6ca..afb13e76 100644 --- a/tutor/app/controllers/posts_controller.rb +++ b/tutor/app/controllers/posts_controller.rb @@ -95,7 +95,7 @@ def create # update fails the user is redirected to the form # Parameters: # topic_params[]: A list that has all fields entered by the user to in the - # Edit_post_form + # Edit_post_form # Returns: # flash[:notice]: A message indicating the success or failure of the creation # Author: Ahmed Atef From aecc976236f2f297fefb21b79ab28c50f9545f32 Mon Sep 17 00:00:00 2001 From: MohabGhanim Date: Fri, 25 Apr 2014 05:27:11 +0300 Subject: [PATCH 526/526] putting spaces before and after the equal --- tutor/app/views/layouts/_right_side_bar.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutor/app/views/layouts/_right_side_bar.html.erb b/tutor/app/views/layouts/_right_side_bar.html.erb index 08663f35..bd94c82c 100644 --- a/tutor/app/views/layouts/_right_side_bar.html.erb +++ b/tutor/app/views/layouts/_right_side_bar.html.erb @@ -61,7 +61,7 @@ - @@ -69,4 +69,4 @@ <% end %> - \ No newline at end of file +
    System Recommendations
    + <%= render "problems/system_recommendation" if student_signed_in? %>