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 1 commit
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
2 changes: 1 addition & 1 deletion app/Http/Controllers/ResourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class ResourceController extends Controller
{

public $types = ['Audio','Video', 'Imagen', 'Documento','Link'];
public $types = ['Audio','Video', 'Imagen', 'Documento','Link', 'Geogebra'];
/**
* Display a listing of the resource.
*
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', 'geogebra_id'];
Copy link
Owner

Choose a reason for hiding this comment

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

Lo que no veo es la migracion que agrega esa columna. Deberiamos, como te comente en otro comentario, agregar ademas una geogebra_app_type para que se pueda guardar el ID del recurso con el tipo de app para mostrarlo bien.

}
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,
'geogebra' => $faker->GGBApplet
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 funciona, porque no existe en Faker, que genere un id de Geogebra. Lo que se puede hacer aca es poner o un ID fijo de un recurso de geogebra que conozcas. Porque esto nos esta rompiendo los tests.

];
});
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'=>'geogebra', 'type'=>'app geogebra']);

}
}
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 () {
});

/***/ })
/******/ ]);
/******/ ]);
20 changes: 16 additions & 4 deletions resources/assets/js/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@ $(document).ready(function() {
if (value == 'Link') {
$('.link').show();
$('.file').hide();
$('.ggb-element').hide();
}
else{
$('.link').hide();
$('.file').show();
}
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 Down
8 changes: 8 additions & 0 deletions resources/views/Resource/create.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>
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 +43,13 @@
</div>
</div>

<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="GGBApplet" class="form-control" name="ggb.element" >
</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 Down
28 changes: 19 additions & 9 deletions resources/views/Resource/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,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": "graphing", "width": 800, "height": 600, "showToolBar": true, "showAlgebraInput": true, "showMenuBar": true, "material_id":"{$resource->geogebra_id)}" }, true);
Copy link
Owner

Choose a reason for hiding this comment

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

Aca en appName, vamos a tener que poder modificarlo. Si miras en la ayuda https://wiki.geogebra.org/es/Referencia:Incrustaci%C3%B3n_de_Aplicaciones_GeoGebra dependiendo el recurso que uses, si es uno 3d o uno de graficos o uno de geometria, hay que configurar la app bien. Entonces, deberiamos modificar el recurso para que cuando se selecciona Geogebra, le podamos seleccionar el tipo de app que queremos: graphing a geometry o 3d

window.addEventListener("load", function() {
ggbApp.inject('ggb-element');
});
</script>
@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