kevinques 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kevinques.gemspec
4
+ gemspec
@@ -0,0 +1,39 @@
1
+ # Kevinques
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/kevinques`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'kevinques'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install kevinques
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/kevinques/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kevinques"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kevinques/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kevinques"
8
+ spec.version = '0.0.1'
9
+ spec.authors = ["Kevin Gleeson"]
10
+ spec.email = ["kevingleeson115@gmail.com"]
11
+
12
+ spec.summary = %q{Gem that manages questions in my 4th year cloud project.}
13
+ spec.description = %q{Gem that manages questions in my 4th year cloud project.}
14
+ spec.homepage = 'http://rubygems.org/gems/kevinques'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ if spec.respond_to?(:metadata)
22
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
23
+ end
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.9"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ end
@@ -0,0 +1,113 @@
1
+ require "kevinques/version"
2
+
3
+ class Kevinques
4
+ rescue_from "Exception", with: :errorHandling
5
+ def errorHandling(exception)
6
+ render text: exception.message
7
+ end
8
+ before_filter :authenticate_user! #ensure user is logged in
9
+ $resultlist ||= Array.new # creates an array list to store all results
10
+ def create
11
+ @quiz = Quiz.create(quiz_params)
12
+ @quiz.user = current_user
13
+ redirect_to :back
14
+ end
15
+ def index
16
+ $randomNumForQ1a = 10+rand(500)
17
+ $randomNumForQ1b = 10+rand(400)
18
+ $randomNumForQ2a = 200+rand(400)
19
+ $randomNumForQ2b = 10+rand(199)
20
+ $randomNumForQ3a = 200+rand(400)
21
+ $randomNumForQ3b = 10+rand(199)
22
+ $randomNumForQ4a = 200+rand(400)
23
+ $randomNumForQ4b = 10+rand(199)
24
+ $randomNumForQ5a = 2+rand(25)
25
+ $randomNumForQ5b = 1+rand(5)
26
+ $timesForQ1 = $randomNumForQ1a * $randomNumForQ1b
27
+ $divideForQ2 = ($randomNumForQ2a.to_f/ $randomNumForQ2b.to_f).round(2)
28
+ $divideForQ3 = ($randomNumForQ3a.to_f/ $randomNumForQ3b.to_f).round(2)
29
+ $timesForQ4 = $randomNumForQ4a * $randomNumForQ4b
30
+ $divideForQ5 = ($randomNumForQ5a.to_f/ $randomNumForQ5b.to_f).round(2)
31
+ end
32
+ def validate
33
+ def myMethod data
34
+ if data.is_malformed?
35
+ raise ArgumentError
36
+ end
37
+ end
38
+ begin
39
+ rescue NameError
40
+ puts "Method does not exist or constant does not exist"
41
+ end
42
+ $resultlist.clear #clear resultlist before quiz starts
43
+ @score = 0 #user points
44
+ $final_score = ""
45
+ #Question 1
46
+ @inputFromUserQ1 = params[:userAnswerQ1].to_i
47
+ @correctAnswerQ1 = Checkpercentage.find_amount($randomNumForQ1a, $randomNumForQ1b)
48
+ if(@inputFromUserQ1 == @correctAnswerQ1)
49
+ $resultlist.push("Q1: Your answer #{@inputFromUserQ1} is correct! ")
50
+ @score = @score+2
51
+ else
52
+ $resultlist.push("Q1: Your answer #{@inputFromUserQ1} is incorrect. The correct answer is #{@correctAnswerQ1}\n
53
+ To solve this math do the following: \n
54
+ multiply #{$randomNumForQ1a} with #{$randomNumForQ1b} and then devide it by 100.\n
55
+ #{$randomNumForQ1a} x #{$randomNumForQ1b} = #{$timesForQ1}\n
56
+ then divide by 100, #{$timesForQ1}/100 = #{@correctAnswerQ1}\n")
57
+ end
58
+ #Question 2
59
+ @inputFromUserQ2 = params[:userAnswerQ2].to_f.ceil
60
+ @correctAnswerQ2 = Checkpercentage.find_percent($randomNumForQ2a, $randomNumForQ2b)
61
+ if(@inputFromUserQ2 == @correctAnswerQ2)
62
+ $resultlist.push("Q2: Your answer #{@inputFromUserQ2} is correct! ")
63
+ @score = @score +2
64
+ else
65
+ $resultlist.push("Q2: Your answer #{@inputFromUserQ2} is Incorrect. The correct answer is #{@correctAnswerQ2}. \n
66
+ To solve this math do the following: \n
67
+ Divide #{$randomNumForQ2a} with #{$randomNumForQ2b} = #{$divideForQ2}. \n
68
+ Then multipy it by 100 = #{$divideForQ2} * 100 = #{@correctAnswerQ2}% \n")
69
+ end
70
+ #Question 3
71
+ @inputFromUserQ3 = params[:userAnswerQ2].to_f.ceil
72
+ @correctAnswerQ3 = Checkpercentage.find_percent($randomNumForQ3a, $randomNumForQ3b )
73
+ if(@inputFromUserQ3 == @correctAnswerQ3)
74
+ $resultlist.push("Q3: Your answer #{@inputFromUserQ3} is correct!")
75
+ @score = @score+2
76
+ else
77
+ $resultlist.push("Q3: Your answer #{@inputFromUserQ3} is Incorrect. The correct answer is #{@correctAnswerQ3}. \n
78
+ To solve this math do the following: \n
79
+ Divide #{$randomNumForQ3a} with #{$randomNumForQ3b} = #{$divideForQ3}. \n
80
+ Then multipy it by 100 = #{$divideForQ3} * 100 = #{@correctAnswerQ3}% \n")
81
+ end
82
+ #Question 4
83
+ @inputFromUserQ4 = params[:userAnswerQ4].to_i
84
+ @correctAnswerQ4 = Checkpercentage.find_amount($randomNumForQ4a, $randomNumForQ4b)
85
+ if(@inputFromUserQ4 == @correctAnswerQ4)
86
+ $resultlist.push("Q4: Your answer #{@inputFromUserQ4} is correct! ")
87
+ @score = @score+2
88
+ else
89
+ $resultlist.push("Q4: Your answer #{@inputFromUserQ4} is incorrect. The correct answer is #{@correctAnswerQ4}\n
90
+ To solve this math do the following: \n
91
+ multiply #{$randomNumForQ4a} with #{$randomNumForQ4b} and then devide it by 100.\n
92
+ #{$randomNumForQ4a} x #{$randomNumForQ4b} = #{$timesForQ4}\n
93
+ then divide by 100, #{$timesForQ4}/100 = #{@correctAnswerQ4}\n")
94
+ end
95
+ #Question 5
96
+ @inputFromUserQ5 = params[:userAnswerQ5].to_i
97
+ @correctAnswerQ5 = Power.value_power($randomNumForQ5a, $randomNumForQ5b)
98
+ if(@inputFromUserQ5 == @correctAnswerQ5)
99
+ $resultlist.push("Q5: Your answer #{@inputFromUserQ5} is correct! ")
100
+ @score = @score +2
101
+ else
102
+ $resultlist.push("Q5: WRONG! ")
103
+ end
104
+ #simple_format(resultlist)
105
+ $final_score = Gradescore.runcheck(@score)
106
+ respond_to do |format|
107
+ format.html { render :summary }
108
+ end
109
+ end # END of def
110
+ def summary
111
+ end
112
+ end
113
+
@@ -0,0 +1,3 @@
1
+ module Kevinques
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kevinques
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kevin Gleeson
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2015-03-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.9'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.9'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '10.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '10.0'
46
+ description: Gem that manages questions in my 4th year cloud project.
47
+ email:
48
+ - kevingleeson115@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - .travis.yml
55
+ - Gemfile
56
+ - README.md
57
+ - Rakefile
58
+ - bin/console
59
+ - bin/setup
60
+ - kevinques.gemspec
61
+ - lib/kevinques.rb
62
+ - lib/kevinques/version.rb
63
+ homepage: http://rubygems.org/gems/kevinques
64
+ licenses: []
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.23
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Gem that manages questions in my 4th year cloud project.
87
+ test_files: []