Skip to content

Commit f39e82f

Browse files
author
Jon Janelle
committed
added ratio problems
1 parent 3856387 commit f39e82f

14 files changed

Lines changed: 193 additions & 0 deletions

app/Like.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Like extends Model
8+
{
9+
//
10+
}

app/User.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ public function problems() {
4141

4242

4343

44+
4445
}

database/migrations/2017_04_19_201953_create_user_problem_table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class CreateUserProblemTable extends Migration
1212
*/
1313
public function up()
1414
{
15+
//list table names in alphabetical order.
1516
Schema::create('problem_user', function (Blueprint $table) {
1617
$table->increments('id');
1718

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateLikesTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('likes', function (Blueprint $table) {
17+
$table->increments('id');
18+
$table->integer('rating')->default(0); //1 = like, -1 = dislike
19+
$table->timestamps();
20+
});
21+
}
22+
23+
/**
24+
* Reverse the migrations.
25+
*
26+
* @return void
27+
*/
28+
public function down()
29+
{
30+
Schema::drop('likes');
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class ConnectCommentsAndLikes extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('likes', function (Blueprint $table) {
17+
$table->integer('comment_id')->unsigned();
18+
$table->foreign('comment_id')->references('id')->on('comments');
19+
});
20+
}
21+
22+
/**
23+
* Reverse the migrations.
24+
*
25+
* @return void
26+
*/
27+
public function down()
28+
{
29+
$table->dropForeign('likes_comment_id_foreign');
30+
$table->dropColumn('comment_id');
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class ConnectUsersAndLikes extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('likes', function (Blueprint $table) {
17+
$table->integer('user_id')->unsigned();
18+
$table->foreign('user_id')->references('id')->on('users');
19+
});
20+
}
21+
22+
/**
23+
* Reverse the migrations.
24+
*
25+
* @return void
26+
*/
27+
public function down()
28+
{
29+
$table->dropForeign('likes_user_id_foreign');
30+
$table->dropColumn('user_id');
31+
}
32+
}

database/seeds/ProblemsTableSeeder.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,89 @@ public function geomSeed() {
232232
'answer'=> 20,
233233
'xp'=>250
234234
]);
235+
Problem::insert([
236+
'created_at' => Carbon\Carbon::now()->toDateTimeString(),
237+
'updated_at' => Carbon\Carbon::now()->toDateTimeString(),
238+
'category'=>'Geometry',
239+
'name'=> 'Problem 8',
240+
'difficulty'=>8,
241+
'image'=>'/images/geometry/geometryP9.PNG',
242+
'answer'=> 12,
243+
'xp'=>400
244+
]);
245+
}
246+
247+
public function ratioSeed() {
248+
Problem::insert([
249+
'created_at' => Carbon\Carbon::now()->toDateTimeString(),
250+
'updated_at' => Carbon\Carbon::now()->toDateTimeString(),
251+
'category'=>'Ratios',
252+
'name'=> 'Problem 1',
253+
'difficulty'=>1,
254+
'image'=>'/images/ratio/ratioP1.PNG',
255+
'answer'=> 20,
256+
'xp'=>50
257+
]);
258+
259+
Problem::insert([
260+
'created_at' => Carbon\Carbon::now()->toDateTimeString(),
261+
'updated_at' => Carbon\Carbon::now()->toDateTimeString(),
262+
'category'=>'Ratios',
263+
'name'=> 'Problem 2',
264+
'difficulty'=>2,
265+
'image'=>'/images/ratio/ratioP2.PNG',
266+
'answer'=> 20,
267+
'xp'=>100
268+
]);
269+
270+
Problem::insert([
271+
'created_at' => Carbon\Carbon::now()->toDateTimeString(),
272+
'updated_at' => Carbon\Carbon::now()->toDateTimeString(),
273+
'category'=>'Ratios',
274+
'name'=> 'Problem 3',
275+
'difficulty'=>3,
276+
'image'=>'/images/ratio/ratioP3.PNG',
277+
'answer'=> 20,
278+
'xp'=>100
279+
]);
280+
281+
Problem::insert([
282+
'created_at' => Carbon\Carbon::now()->toDateTimeString(),
283+
'updated_at' => Carbon\Carbon::now()->toDateTimeString(),
284+
'category'=>'Ratios',
285+
'name'=> 'Problem 4',
286+
'difficulty'=>3,
287+
'image'=>'/images/ratio/ratioP4.PNG',
288+
'answer'=> 94,
289+
'xp'=>150
290+
]);
291+
292+
Problem::insert([
293+
'created_at' => Carbon\Carbon::now()->toDateTimeString(),
294+
'updated_at' => Carbon\Carbon::now()->toDateTimeString(),
295+
'category'=>'Ratios',
296+
'name'=> 'Problem 5',
297+
'difficulty'=>8,
298+
'image'=>'/images/ratio/ratioP5.PNG',
299+
'answer'=> 105,
300+
'xp'=>400
301+
]);
302+
303+
Problem::insert([
304+
'created_at' => Carbon\Carbon::now()->toDateTimeString(),
305+
'updated_at' => Carbon\Carbon::now()->toDateTimeString(),
306+
'category'=>'Ratios',
307+
'name'=> 'Problem 6',
308+
'difficulty'=>4,
309+
'image'=>'/images/ratio/ratioP6.PNG',
310+
'answer'=> 1.6,
311+
'xp'=>200
312+
]);
313+
314+
}
315+
316+
public function seqenceSeed() {
317+
235318
}
236319

237320
/**
@@ -243,5 +326,7 @@ public function run()
243326
{
244327
$this->algebraSeed();
245328
$this->geomSeed();
329+
$this->ratioSeed();
330+
$this->sequenceSeed();
246331
}
247332
}
26.4 KB
Loading

public/images/ratio/ratioP1.PNG

12.6 KB
Loading

public/images/ratio/ratioP2.PNG

10.5 KB
Loading

0 commit comments

Comments
 (0)