Skip to content
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
25 changes: 12 additions & 13 deletions controllers/h5p.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Grading\Instance;

class H5pController extends PluginController
{

Expand Down Expand Up @@ -154,7 +156,7 @@ public function export_library_action() {
if (!$GLOBALS['perm']->have_perm("root")) {
throw new AccessDeniedException();
}
list($name, $version) = explode("-", Request::get("lib"));
[$name, $version] = explode("-", Request::get("lib"));
$version = explode(".", $version);

$lib = H5PLib::findOneBySQL("name = :name AND major_version = :major_version AND minor_version = :minor_version", [
Expand Down Expand Up @@ -184,7 +186,7 @@ public function delete_library_action()
throw new AccessDeniedException();
}
if (Request::get("lib")) {
list($name, $version) = explode("-", Request::get("lib"));
[$name, $version] = explode("-", Request::get("lib"));
$version = explode(".", $version);

$lib = H5PLib::findOneBySQL("name = :name AND major_version = :major_version AND minor_version = :minor_version", [
Expand All @@ -198,7 +200,7 @@ public function delete_library_action()
}
} elseif (count(Request::getArray("libs"))) {
foreach (Request::getArray("libs") as $libdata) {
list($name, $version) = explode("-", $libdata);
[$name, $version] = explode("-", $libdata);
$version = explode(".", $version);

$lib = H5PLib::findOneBySQL("name = :name AND major_version = :major_version AND minor_version = :minor_version", [
Expand Down Expand Up @@ -396,22 +398,19 @@ public function set_finished_action($attempt_id)
$this->attempt['successful'] = 1;
$this->attempt['customdata']['points']['score'] = Request::get("score");
$this->attempt->store();
$module_id = Request::option("contentId");
$score = Request::get("score");
$max_score = Request::get("maxScore");
$opened_time = Request::int("opened");
$finished_time = Request::int("finished");
$time = Request::get("time");

if (Context::get()->id) {

if (Context::get() && Context::get()->id) {
$course_connection = $this->attempt->modul->courseConnection(Context::get()->id);
if ($course_connection['gradebook_definition']) {
$instance = \Grading\Instance::findOneBySQL("user_id = :user_id AND definition_id = :definition_id", array(
$instance = Instance::findOneBySQL("user_id = :user_id AND definition_id = :definition_id", array(
'user_id' => $GLOBALS['user']->id,
'definition_id' => $course_connection['gradebook_definition']
));
if (!$instance) {
$instance = new \Grading\Instance();
$instance = new Instance();
$instance['user_id'] = $GLOBALS['user']->id;
$instance['definition_id'] = $course_connection['gradebook_definition'];
$instance['rawgrade'] = $max_score / $score;
Expand All @@ -436,17 +435,17 @@ public function set_userdata_action($attempt_id) {
$answer = json_decode(Request::get("data"), true);
$customdata = $this->attempt['customdata'] ? $this->attempt['customdata']->getArrayCopy() : array();
$customdata['h5pstate'] = $answer;
if ($answer['finished']) {
if (!empty($answer['finished'])) {
$this->attempt['successful'] = 1;
if (Context::get()->id) {
$course_connection = $this->attempt->modul->courseConnection(Context::get()->id);
if ($course_connection['gradebook_definition']) {
$instance = \Grading\Instance::findOneBySQL("user_id = :user_id AND definition_id = :definition_id", array(
$instance = Instance::findOneBySQL("user_id = :user_id AND definition_id = :definition_id", array(
'user_id' => $GLOBALS['user']->id,
'definition_id' => $course_connection['gradebook_definition']
));
if (!$instance) {
$instance = new \Grading\Instance();
$instance = new Instance();
$instance['user_id'] = $GLOBALS['user']->id;
$instance['definition_id'] = $course_connection['gradebook_definition'];
$instance['rawgrade'] = 1;
Expand Down
1 change: 0 additions & 1 deletion controllers/h5peditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,6 @@ public function ajax_action() {
return;
} elseif ($cmd === "files") {
//upload files ...
$_FILES['file'];
$mod = H5pLernmodul::find(Request::get("module_id"));
if (!$mod) {
throw new Exception(_("Modul existiert nicht. Kann Datei nicht hochladen."));
Expand Down
2 changes: 0 additions & 2 deletions controllers/lernmodule.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,7 @@ public function gameparticipation_action($game_id)

public function blubber_action()
{
if (Request::submitted("save") && Request::isPost()) {

}
}

public function admin_action()
Expand Down