Skip to content

Commit

Permalink
updated seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelja committed Feb 15, 2016
1 parent 7976b30 commit b27f629
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/models/exercise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Exercise < ActiveRecord::Base
belongs_to :user
belongs_to :execution_environment
has_many :descriptions
validates :descriptions, presence: true
#validates :descriptions, presence: true

accepts_nested_attributes_for :descriptions, allow_destroy: true

Expand Down
2 changes: 1 addition & 1 deletion app/views/home/_exercises.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div class="panel-body">

<div class="col-md-10">
<%= exercise.descriptions.first.text %>
<% unless exercise.descriptions.empty? %><%= exercise.descriptions.first.text %><% end %>
</div>

<div class="btn-group-vertical pull-right" role="group" aria-label="...">
Expand Down
8 changes: 4 additions & 4 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
test_framework = TestingFramework.create(name: 'JUnit 4')
test_framework2 = TestingFramework.create(name: 'Pytest')

exercise1 = Exercise.create(title: "Hello World", description: "Schreibe ein Java Programm, das 'Hello World' am Bildschirm ausgibt.", maxrating: '10', public: true, user_id:user1.id)
exercise1 = Exercise.create(title: "Hello World", maxrating: '10', public: true, user_id:user1.id)
ExerciseFile.create(main: true, content: "public class HelloWorld{ public static void main String[] args) { } }", path: '', solution: false, filetype: 'java', exercise: exercise1)
Test.create(content: "public class HelloWorld{ public static void main String[] args) {System.out.println('Hello World.'); } }", rating: 5, feedback_message: "Es wird noch nicht 'Hello World' am Bildschrim ausgegeben!", exercise: exercise1, testing_framework: test_framework)

Expand All @@ -52,7 +52,7 @@



exercise2 = Exercise.create(title: "Java Einstieg ", description: "In diesem Programm sind zwei Fehler versteckt. Versuche diese zu finden und zu beheben. Anschließend soll das Programm ""Hallo Welt"" ausgeben.\nFinde die beiden Fehler, die wir in das Programm eingebaut haben.", maxrating: '10', public: true, user_id:user2.id)
exercise2 = Exercise.create(title: "Java Einstieg ", maxrating: '10', public: true, user_id:user2.id)
ExerciseFile.create(main: true, content: "public class HalloWelt {\n // Hier haben sich zwei Fehler eingeschlichen\n public static void main (String [] args){\n System.out.println(Hallo Welt)\n }\n}", path: '', solution: false, filetype: 'java', exercise: exercise2)
Test.create(content: "import static org.junit.Assert.*;\nimport java.io.ByteArrayOutputStream;\nimport java.io.PrintStream;\nimport org.junit.AfterClass;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\npublic class HalloWeltTest1 {\n \n private final static ByteArrayOutputStream outContent = new ByteArrayOutputStream();\n private static PrintStream old;\n @BeforeClass\n public static void setUpStreams() {\n old = System.out;\n System.setOut(new PrintStream(outContent));\n }\n @AfterClass\n public static void cleanUpStreams() {\n System.setOut(old);\n }\n \n @Before\n public void resetOut(){\n outContent.reset();\n }\n \n @Test\n public void testIfErrorFree(){\n try{\n HalloWelt.main(new String[] {});\n }catch (Error e){\n fail();\n }\n }\n @Test\n public void testSomething(){\n assert(true);\n }\n}", rating: 5, feedback_message: "Es existieren noch Fehler im Programm. Daher kann dieses noch nicht ausgeführt werden", exercise: exercise2, testing_framework: test_framework)
Test.create(content: "import static org.junit.Assert.*;\nimport java.io.ByteArrayOutputStream;\nimport java.io.PrintStream;\nimport org.junit.AfterClass;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\npublic class HalloWeltTest2 {\n \n private final static ByteArrayOutputStream outContent = new ByteArrayOutputStream();\n private static PrintStream old;\n @BeforeClass\n public static void setUpStreams() {\n old = System.out;\n System.setOut(new PrintStream(outContent));\n }\n @AfterClass\n public static void cleanUpStreams() {\n System.setOut(old);\n }\n \n @Before\n public void resetOut(){\n outContent.reset();\n }\n \n @Test\n public void checkForCorrectOutput(){\n HalloWelt.main(new String[] {});\n String separator = System.getProperty(""line.separator"");\n assertEquals(""Hallo Welt""+separator, outContent.toString());\n }\n @Test\n public void testSomething(){\n assert(true);\n }\n}", rating: 1, feedback_message: "Es wird ein falscher String ausgegeben, erwartet ist die Ausgabe\nHallo Welt", exercise: exercise2, testing_framework: test_framework)
Expand All @@ -71,7 +71,7 @@
exercise2.labels << l3


exercise3 = Exercise.create(title: "Asterisk Pattern", description: "Schreibe ein Java Programm, das das Asterisk Pattern ausgibt. Das Pattern sieht folgendermaßen aus: ***** ***** ***** ***** *****", maxrating: '10', public: true, user_id:user3.id)
exercise3 = Exercise.create(title: "Asterisk Pattern", maxrating: '10', public: true, user_id:user3.id)
ExerciseFile.create(main: true, content: "public class AsteriksPattern{ public static void main String[] args) { } }", path: '', solution: false, filetype: 'java', exercise: exercise3)


Expand Down Expand Up @@ -104,7 +104,7 @@
exercise3.labels << l3


exercise4 = Exercise.create(title: "factorial of given numbers", description: "Write a program which can compute the factorial of a given numbers. The results should be printed in a comma-separated sequence on a single line.", maxrating: '10', public: true, user_id:user4.id)
exercise4 = Exercise.create(title: "factorial of given numbers", maxrating: '10', public: true, user_id:user4.id)
ExerciseFile.create(main: true, content: "def fact(x): return", path: '', solution: false, filetype: 'python', exercise: exercise4)


Expand Down

0 comments on commit b27f629

Please sign in to comment.