Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Resource Geogebra #131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/Http/Controllers/ResourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
class ResourceController extends Controller
{

public $types = ['Audio','Video', 'Imagen', 'Documento','Link'];
public $types = ['Audio','Video', 'Imagen', 'Documento','Link', 'Geogebra'];
public $geotypes = ['graphing', 'geometry', '3d'];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Muy bien esto!

/**
* Display a listing of the resource.
*
Expand All @@ -28,7 +29,7 @@ public function index()
*/
public function create()
{
return view('Resource.create',['types' => $this->types]);
return view('Resource.create',['types' => $this->types], ['geotypes' => $this->geotypes]);
}

/**
Expand Down Expand Up @@ -66,7 +67,7 @@ public function show(Resource $resource)
*/
public function edit(Resource $resource)
{
return view('Resource.update',['resource'=> $resource, 'types' => $this->types]);
return view('Resource.update',['resource'=> $resource, 'types' => $this->types], ['geotypes' => $this->geotypes]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

class Resource extends Model
{
protected $fillable = ['name','type', 'path', 'link'];
protected $fillable = ['name','type', 'path', 'link', 'geotype'];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ponele en lugar de geotype, geogebra_type. Para ponerlo en el modelo tenes que crear una migracion. Que va a modificar la tabla Resource y agergar 2 campos.
geogebra_type (este es el que ya tenes)
geogebra_code (est ees el codigo que tiene que poner el docente para que se vea)

en esta linea que esta el comentario tenes que agregar tambien geogebra_code

}
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
}
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
Expand Down
3 changes: 2 additions & 1 deletion database/factories/ResourceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
return [
'name' => $faker->word,
'type' => $faker->text,
'link' => $faker->url
'link' => $faker->url,
'geotype' => 'ZT6xkDYM'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cambiar por geogebra_type. Aca ese codigo esta mal, lo que es el tipo es 3d, graphing, geometry. osea podes poner cualquiera de esos.
despues pones otro geogebra_code con ese valor.

Justo para ese codigotenes que poner graphing

];
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function up()
$table->string('type');
$table->string('path')->nullable();
$table->string('link')->nullable();
$table->string('geotype')->nullable();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

esto no lo tenes que hacer aca a pelo, tenes que hacer una migracion nueva
php artisan make:migration add_geogebra_to_resources_table
y adento de esa creas las columnas (hay un ejemplo en el codigo add_record....

Una vez que completaste el up y down de esa migracion ejecutas las migraciones
php artisan migrate

$table->timestamps();
});
}
Expand Down
1 change: 1 addition & 0 deletions database/seeds/ResourcesTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function run()
factory(App\Resource::class, 1)->create(['name'=>'presentación', 'type'=>'presentación de diapositivas']);
factory(App\Resource::class, 1)->create(['name'=>'hipervínculo', 'type'=>'hipervínculo']);
factory(App\Resource::class, 1)->create(['name'=>'imagen', 'type'=>'imagen']);
factory(App\Resource::class, 1)->create(['name'=>'ggb-element', 'type'=>'app geogebra']);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name puede ser cualqueir cosa
Type deberia ser Geogebra que es el Type que le ponemos.


}
}
24 changes: 19 additions & 5 deletions public/js/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -31857,14 +31857,28 @@ module.exports = __webpack_require__(44);

__webpack_require__(9);
$(document).ready(function () {
function toggleControls(value) {

function toggleControls(value){
if (value == 'Link') {
$('.link').show();
$('.file').hide();
} else {
$('.link').hide();
$('.file').show();
$('.ggb-element').hide();
}
else if (value == 'Documento'){
$('.link').hide();
$('.file').show();
$('.ggb-element').hide();
}
else if (value == 'Geogebra'){
$('.link').hide();
$('.file').hide();
$('.ggb-element').show();
}
else {
$('.link').hide();
$('.file').show();
$('.ggb-element').hide();
}
}

toggleControls($('#type')[0].value);
Expand All @@ -31875,4 +31889,4 @@ $(document).ready(function () {
});

/***/ })
/******/ ]);
/******/ ]);
15 changes: 11 additions & 4 deletions resources/assets/js/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ $(document).ready(function() {
if (value == 'Link') {
$('.link').show();
$('.file').hide();
$('.ggb-element').hide();
}
else{
$('.link').hide();
$('.file').show();
}
else if (value == 'Geogebra'){
$('.link').hide();
$('.file').hide();
$('.ggb-element').show();
}
else {
$('.link').hide();
$('.file').show();
$('.ggb-element').hide();
}
}

toggleControls($('#type')[0].value);
Expand Down
14 changes: 14 additions & 0 deletions resources/views/Resource/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

@section('pagespecificscripts')
<script src="{{ asset('js/resources.js') }}"></script>
<script src="https://www.geogebra.org/apps/deployggb.js"></script>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aca no lo necesitamos a esto.


@stop

@section('content')
Expand Down Expand Up @@ -42,6 +44,17 @@
</div>
</div>

<div class="form-group ggb-element">
<label for="geotype" class="col-md-2 control-label"><p>Seleccione tipo de elemento Geogebra</p></label>
<div class="col-md-6">
<select class="form-control" name="geotype" id= "geotype">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aca el name y id van a ser geogebra_type

@foreach ($geotypes as $geotype)
<option value="{{$geotype}}">{{$geotype}}</option>
@endforeach
</select>
</div>
</div>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tenes que agregar ademas un input para el otro campo que creaste geogebra_code. Es un input de tipo text


<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Expand All @@ -52,4 +65,5 @@
</form>
</div>
</div>

@endsection
29 changes: 20 additions & 9 deletions resources/views/Resource/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

@section('pagespecificscripts')
<script src="{{ asset('js/resources.js') }}"></script>
<script src="https://www.geogebra.org/apps/deployggb.js"></script>
@stop

@section('content')
Expand All @@ -22,16 +23,26 @@
<p>{!!$resource->type!!} </p>
</div>

@if(isset($resource->path))
<div class="container">
<h4>Archivo</h4>
<a href="{{asset('/storage/'.$resource->path)}}" download="{{$resource->name}}">Bajar archivo actual</a>
</div>
@if ($resource->type == "Geogebra")
<div id="ggb-element"></div>
<script>
var ggbApp = new GGBApplet({"appName": "{$resource->geotype}", "width": 800, "height": 600, "showToolBar": true, "showAlgebraInput": true, "showMenuBar": true, "material_id":"{$resource->name)}" }, true);
window.addEventListener("load", function() {
ggbApp.inject('ggb-element');
});
</script>
Comment on lines +28 to +33
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo esto lo tenes que pasar a la seccion de arriba donde estan los scripts. (linea 5)
Vas a tener que agregar el if de @if ($resource->type == "Geogebra") ahi tambien para que se complete bien todos los datos.
En la parte de appName tenes que poner "{{$resource->geogebra_type}}" (lleva dobe llave, no una sola como tenes ahi) y en la de material_id, el otro campo que create con el codigo

@else
<div class="container">
<h4>Link</h4>
<a href="{{asset($resource->link)}}" target="popup" onclick="window.open('', 'popup', 'width = 800, height = 600')">{{$resource->link}}</a>
</div>
@if(isset($resource->path))
<div class="container">
<h4>Archivo</h4>
<a href="{{asset('/storage/'.$resource->path)}}" download="{{$resource->name}}">Bajar archivo actual</a>
</div>
@else
<div class="container">
<h4>Link</h4>
<a href="{{asset($resource->link)}}" target="popup" onclick="window.open('', 'popup', 'width = 800, height = 600')">{{$resource->link}}</a>
</div>
@endif
@endif

</form>
Expand Down
7 changes: 7 additions & 0 deletions resources/views/Resource/update.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
</div>
@endif

<div class="form-group ggb-element">
<label for="ggb-element" class="col-md-2 control-label"><p>Geogebra</p></label>
<div class="col-md-6">
<input id="ggb-element" type="text" class="form-control" value="{{$resource->geogebra_id}}" name="ggb-element" autofocus>
</div>
</div>

Comment on lines +58 to +64
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esto te tiene que quedar igual a lo que pusiste en el tempate de show, la diferencia es que tenes que agregar en el select, que se seleccione el geogebra_type que esta grabado en la base y en el geogebra_code, se complete el valor de la base tambien.

<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Expand Down