transferred Code Ocean from original repository to GitHub
This commit is contained in:
BIN
db/seeds/audio_video/chai.ogg
Normal file
BIN
db/seeds/audio_video/chai.ogg
Normal file
Binary file not shown.
BIN
db/seeds/audio_video/devstories.mp4
Normal file
BIN
db/seeds/audio_video/devstories.mp4
Normal file
Binary file not shown.
BIN
db/seeds/audio_video/devstories.webm
Normal file
BIN
db/seeds/audio_video/devstories.webm
Normal file
Binary file not shown.
10
db/seeds/audio_video/index.html
Normal file
10
db/seeds/audio_video/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||
<script src="index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>HTML5 Audio & Video</h1>
|
||||
</body>
|
||||
</html>
|
27
db/seeds/audio_video/index.html_spec.rb
Normal file
27
db/seeds/audio_video/index.html_spec.rb
Normal file
@ -0,0 +1,27 @@
|
||||
require 'rack/file'
|
||||
require 'capybara/rspec'
|
||||
|
||||
AUDIO_FILENAME = 'chai.ogg'
|
||||
VIDEO_FILENAME = 'devstories.mp4'
|
||||
|
||||
Capybara.app = Rack::File.new(File.dirname(__FILE__))
|
||||
|
||||
describe 'index.html', type: :feature do
|
||||
before(:each) { visit('index.html') }
|
||||
|
||||
it 'contains an audio element' do
|
||||
expect(page).to have_css('audio')
|
||||
end
|
||||
|
||||
it 'plays the correct audio file' do
|
||||
expect(page).to have_css("audio[src='#{AUDIO_FILENAME}']")
|
||||
end
|
||||
|
||||
it 'contains a video element' do
|
||||
expect(page).to have_css('video')
|
||||
end
|
||||
|
||||
it 'plays the correct video file' do
|
||||
expect(page).to have_css("video[src='#{VIDEO_FILENAME}']")
|
||||
end
|
||||
end
|
3
db/seeds/audio_video/index.js
Normal file
3
db/seeds/audio_video/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
$(function() {
|
||||
//
|
||||
});
|
BIN
db/seeds/audio_video/poster.png
Normal file
BIN
db/seeds/audio_video/poster.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 140 KiB |
24
db/seeds/development.rb
Normal file
24
db/seeds/development.rb
Normal file
@ -0,0 +1,24 @@
|
||||
# consumers
|
||||
FactoryGirl.create(:consumer)
|
||||
FactoryGirl.create(:consumer, name: 'openSAP')
|
||||
|
||||
# users
|
||||
%w[admin external_user teacher].each { |factory_name| FactoryGirl.create(factory_name) }
|
||||
|
||||
# execution environments
|
||||
ExecutionEnvironment.create_factories
|
||||
|
||||
# errors
|
||||
Error.create_factories
|
||||
|
||||
# exercises
|
||||
@exercises = find_factories_by_class(Exercise).map(&:name).map { |factory_name| [factory_name, FactoryGirl.create(factory_name)] }.to_h
|
||||
|
||||
# file types
|
||||
FileType.create_factories
|
||||
|
||||
# hints
|
||||
Hint.create_factories
|
||||
|
||||
# submissions
|
||||
FactoryGirl.create(:submission, exercise: @exercises[:fibonacci])
|
5
db/seeds/even_odd/exercise.py
Normal file
5
db/seeds/even_odd/exercise.py
Normal file
@ -0,0 +1,5 @@
|
||||
def even(x):
|
||||
pass
|
||||
|
||||
def odd(x):
|
||||
pass
|
15
db/seeds/even_odd/exercise_tests.py
Normal file
15
db/seeds/even_odd/exercise_tests.py
Normal file
@ -0,0 +1,15 @@
|
||||
from exercise import *
|
||||
import unittest
|
||||
|
||||
class ExerciseTests(unittest.TestCase):
|
||||
def test_even(self):
|
||||
for x in [1, 3, 5, 7, 9]:
|
||||
self.assertFalse(even(x))
|
||||
for x in [2, 4, 6, 8, 10]:
|
||||
self.assertTrue(even(x))
|
||||
|
||||
def test_odd(self):
|
||||
for x in [1, 3, 5, 7, 9]:
|
||||
self.assertTrue(odd(x))
|
||||
for x in [2, 4, 6, 8, 10]:
|
||||
self.assertFalse(odd(x))
|
5
db/seeds/even_odd/reference.py
Normal file
5
db/seeds/even_odd/reference.py
Normal file
@ -0,0 +1,5 @@
|
||||
def even(x):
|
||||
return x % 2 == 0
|
||||
|
||||
def odd(x):
|
||||
return not even(x)
|
2
db/seeds/fibonacci/exercise.rb
Normal file
2
db/seeds/fibonacci/exercise.rb
Normal file
@ -0,0 +1,2 @@
|
||||
def fibonacci(n)
|
||||
end
|
15
db/seeds/fibonacci/exercise_spec_1.rb
Normal file
15
db/seeds/fibonacci/exercise_spec_1.rb
Normal file
@ -0,0 +1,15 @@
|
||||
require './exercise'
|
||||
|
||||
describe '#fibonacci' do
|
||||
it 'is defined' do
|
||||
expect { method(:fibonacci) }.not_to raise_error
|
||||
end
|
||||
|
||||
it 'has the correct arity' do
|
||||
expect(method(:fibonacci).arity).to eq(1)
|
||||
end
|
||||
|
||||
it 'returns a number' do
|
||||
expect(fibonacci(1)).to be_an(Integer)
|
||||
end
|
||||
end
|
9
db/seeds/fibonacci/exercise_spec_2.rb
Normal file
9
db/seeds/fibonacci/exercise_spec_2.rb
Normal file
@ -0,0 +1,9 @@
|
||||
require './exercise'
|
||||
|
||||
describe '#fibonacci' do
|
||||
it 'works recursively' do
|
||||
@n = 16
|
||||
expect(self).to receive(:fibonacci).and_call_original.at_least(@n ** 2).times
|
||||
fibonacci(@n)
|
||||
end
|
||||
end
|
16
db/seeds/fibonacci/exercise_spec_3.rb
Normal file
16
db/seeds/fibonacci/exercise_spec_3.rb
Normal file
@ -0,0 +1,16 @@
|
||||
require './exercise'
|
||||
require './reference'
|
||||
|
||||
describe '#fibonacci' do
|
||||
SAMPLE_COUNT = 32
|
||||
|
||||
let(:reference) { Class.new.extend(Reference) }
|
||||
|
||||
SAMPLE_COUNT.times do |i|
|
||||
instance_eval do
|
||||
it "obtains the correct result for input #{i}" do
|
||||
expect(fibonacci(i)).to eq(reference.fibonacci(i))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
5
db/seeds/fibonacci/reference.rb
Normal file
5
db/seeds/fibonacci/reference.rb
Normal file
@ -0,0 +1,5 @@
|
||||
module Reference
|
||||
def fibonacci(n)
|
||||
n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2)
|
||||
end
|
||||
end
|
2
db/seeds/files/data.txt
Normal file
2
db/seeds/files/data.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Foo
|
||||
Bar
|
6
db/seeds/files/exercise.rb
Normal file
6
db/seeds/files/exercise.rb
Normal file
@ -0,0 +1,6 @@
|
||||
SOURCE_FILENAME = 'data.txt'
|
||||
TARGET_FILENAME = 'copy.txt'
|
||||
|
||||
def copy_file
|
||||
# Implement this method.
|
||||
end
|
21
db/seeds/files/exercise_spec.rb
Normal file
21
db/seeds/files/exercise_spec.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require './exercise'
|
||||
|
||||
describe '#write_to_file' do
|
||||
before(:each) do
|
||||
@file_content = File.new(SOURCE_FILENAME, 'r').read
|
||||
write_to_file
|
||||
end
|
||||
|
||||
it 'preserves the source file' do
|
||||
expect(File.exist?(SOURCE_FILENAME)).to be true
|
||||
expect(File.new(SOURCE_FILENAME, 'r').read).to eq(@file_content)
|
||||
end
|
||||
|
||||
it 'creates the target file' do
|
||||
expect(File.exist?(TARGET_FILENAME)).to be true
|
||||
end
|
||||
|
||||
it 'copies the file content' do
|
||||
expect(File.new(TARGET_FILENAME, 'r').read).to eq(@file_content)
|
||||
end
|
||||
end
|
11
db/seeds/geolocation/index.html
Normal file
11
db/seeds/geolocation/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||
<script src="index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>HTML5 Geolocation</h1>
|
||||
<button id="locate">Locate me</button>
|
||||
</body>
|
||||
</html>
|
3
db/seeds/geolocation/index.js
Normal file
3
db/seeds/geolocation/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
$(function() {
|
||||
var button = $('#locate');
|
||||
});
|
0
db/seeds/hello_world/exercise.rb
Normal file
0
db/seeds/hello_world/exercise.rb
Normal file
6
db/seeds/hello_world/exercise_spec.rb
Normal file
6
db/seeds/hello_world/exercise_spec.rb
Normal file
@ -0,0 +1,6 @@
|
||||
describe 'Exercise' do
|
||||
it "outputs 'Hello World" do
|
||||
expect(STDOUT).to receive(:puts).with('Hello World')
|
||||
require './exercise'
|
||||
end
|
||||
end
|
7
db/seeds/math/Makefile
Normal file
7
db/seeds/math/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
run:
|
||||
javac org/example/RecursiveMath.java
|
||||
java org/example/RecursiveMath
|
||||
|
||||
test:
|
||||
javac -cp .:/usr/java/lib/hamcrest-core-1.3.jar:/usr/java/lib/junit-4.11.jar org/example/${FILENAME}
|
||||
java -cp .:/usr/java/lib/hamcrest-core-1.3.jar:/usr/java/lib/junit-4.11.jar org.junit.runner.JUnitCore org.example.${CLASS_NAME}
|
12
db/seeds/math/org/example/RecursiveMath.java
Normal file
12
db/seeds/math/org/example/RecursiveMath.java
Normal file
@ -0,0 +1,12 @@
|
||||
package org.example;
|
||||
|
||||
public class RecursiveMath {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//
|
||||
}
|
||||
|
||||
public static double power(int base, int exponent) {
|
||||
return 42;
|
||||
}
|
||||
}
|
26
db/seeds/math/org/example/RecursiveMathTest1.java
Normal file
26
db/seeds/math/org/example/RecursiveMathTest1.java
Normal file
@ -0,0 +1,26 @@
|
||||
package org.example;
|
||||
|
||||
import java.lang.Math.*;
|
||||
import org.example.RecursiveMath;
|
||||
import org.junit.*;
|
||||
|
||||
public class RecursiveMathTest1 {
|
||||
|
||||
@Test
|
||||
public void methodIsDefined() {
|
||||
boolean methodIsDefined = false;
|
||||
try {
|
||||
RecursiveMath.power(1, 1);
|
||||
methodIsDefined = true;
|
||||
} catch (NoSuchMethodError error) {
|
||||
//
|
||||
}
|
||||
org.junit.Assert.assertTrue("RecursiveMath does not define 'power'.", methodIsDefined);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodReturnsDouble() {
|
||||
Object result = RecursiveMath.power(1, 1);
|
||||
org.junit.Assert.assertTrue("Your method has the wrong return type.", result instanceof Double);
|
||||
}
|
||||
}
|
23
db/seeds/math/org/example/RecursiveMathTest2.java
Normal file
23
db/seeds/math/org/example/RecursiveMathTest2.java
Normal file
@ -0,0 +1,23 @@
|
||||
package org.example;
|
||||
|
||||
import java.lang.Math.*;
|
||||
import org.example.RecursiveMath;
|
||||
import org.junit.*;
|
||||
|
||||
public class RecursiveMathTest2 {
|
||||
|
||||
@Test
|
||||
public void exponentZero() {
|
||||
org.junit.Assert.assertEquals("Incorrect result for exponent 0.", 1, RecursiveMath.power(42, 0), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void negativeExponent() {
|
||||
org.junit.Assert.assertEquals("Incorrect result for exponent -1.", Math.pow(2, -1), RecursiveMath.power(2, -1), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void positiveExponent() {
|
||||
org.junit.Assert.assertEquals("Incorrect result for exponent 4.", Math.pow(2, 4), RecursiveMath.power(2, 4), 0);
|
||||
}
|
||||
}
|
9
db/seeds/primes/exercise.js
Normal file
9
db/seeds/primes/exercise.js
Normal file
@ -0,0 +1,9 @@
|
||||
var isPrime = function(number) {
|
||||
return true;
|
||||
};
|
||||
|
||||
var printPrimes = function(count) {
|
||||
|
||||
};
|
||||
|
||||
printPrimes();
|
37
db/seeds/production.rb
Normal file
37
db/seeds/production.rb
Normal file
@ -0,0 +1,37 @@
|
||||
require 'highline/import'
|
||||
|
||||
# consumers
|
||||
FactoryGirl.create(:consumer)
|
||||
|
||||
# users
|
||||
email = ask('Enter admin email: ')
|
||||
|
||||
passwords = ['password', 'password confirmation'].map do |attribute|
|
||||
ask("Enter admin #{attribute}: ") { |question| question.echo = false }
|
||||
end
|
||||
|
||||
if passwords.uniq.length == 1
|
||||
FactoryGirl.create(:admin, email: email, name: 'Administrator', password: passwords.first)
|
||||
else
|
||||
abort('Passwords do not match!')
|
||||
end
|
||||
|
||||
# execution environments
|
||||
ExecutionEnvironment.create_factories
|
||||
|
||||
# exercises
|
||||
Exercise.create_factories
|
||||
|
||||
# file types
|
||||
FileType.create_factories
|
||||
|
||||
# hints
|
||||
Hint.create_factories
|
||||
|
||||
# change all resources' author
|
||||
[ExecutionEnvironment, Exercise, FileType].each do |model|
|
||||
model.update_all(user_id: InternalUser.first.id)
|
||||
end
|
||||
|
||||
# delete temporary users
|
||||
InternalUser.where.not(id: InternalUser.first.id).delete_all
|
12
db/seeds/sql_select/comparator.rb
Normal file
12
db/seeds/sql_select/comparator.rb
Normal file
@ -0,0 +1,12 @@
|
||||
require 'sqlite3'
|
||||
|
||||
REFERENCE_QUERY = File.new('reference.sql', 'r').read
|
||||
STUDENT_QUERY = File.new('exercise.sql', 'r').read
|
||||
|
||||
database = SQLite3::Database.new('/database.db')
|
||||
|
||||
missing_tuples = database.execute(REFERENCE_QUERY) - database.execute(STUDENT_QUERY)
|
||||
unexpected_tuples = database.execute(STUDENT_QUERY) - database.execute(REFERENCE_QUERY)
|
||||
|
||||
puts("Missing tuples: #{missing_tuples}")
|
||||
puts("Unexpected tuples: #{unexpected_tuples}")
|
0
db/seeds/sql_select/exercise.sql
Normal file
0
db/seeds/sql_select/exercise.sql
Normal file
1
db/seeds/sql_select/reference.sql
Normal file
1
db/seeds/sql_select/reference.sql
Normal file
@ -0,0 +1 @@
|
||||
SELECT * FROM people WHERE name LIKE '% Doe';
|
0
db/seeds/tdd/exercise.rb
Normal file
0
db/seeds/tdd/exercise.rb
Normal file
5
db/seeds/tdd/exercise_spec.rb
Normal file
5
db/seeds/tdd/exercise_spec.rb
Normal file
@ -0,0 +1,5 @@
|
||||
describe 'Exercise' do
|
||||
it 'includes a successful example' do
|
||||
expect(true).to be true
|
||||
end
|
||||
end
|
11
db/seeds/tdd/instructions.md
Normal file
11
db/seeds/tdd/instructions.md
Normal file
@ -0,0 +1,11 @@
|
||||
Write a method `palindrome?` that outputs whether a given input is a palindromic word.
|
||||
|
||||
Write tests to verify that your method works correctly for normal words, empty inputs, and malformed inputs.
|
||||
|
||||
#### Expected Behavior:
|
||||
|
||||
`palindrome?('noon') => true`
|
||||
|
||||
`palindrome?('hello') => false`
|
||||
|
||||
`palindrome?(42) => false`
|
7
db/seeds/web_app/app.rb
Normal file
7
db/seeds/web_app/app.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'sinatra'
|
||||
|
||||
set :bind, '0.0.0.0'
|
||||
|
||||
get '/' do
|
||||
'Hello, World!'
|
||||
end
|
Reference in New Issue
Block a user