Skip to content
Snippets Groups Projects
Select Git revision
  • 346f51b92bfa9ca1a518e796c42a7b8173df61f9
  • master default
  • fix-remote-url_v4.9.1
  • fix-remote-url_v4.8.3
  • fix-remote-url_v4.8.x
  • fix-remote-url_v4.7.x
  • fix-remote-url_v4.6.0
  • fix-remote-urls
8 results

questiontestrun.php

Blame
    • Chris Sangwin's avatar
      346f51b9
      Prototype support for Moodle 4.0. · 346f51b9
      Chris Sangwin authored
      Squashed commit of the following:
      
      commit ca5c2a34c95b63df46bca81cb4875e42425ddbe5
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 21:11:35 2022 +0100
      
          Support bulk tester in Moodle 4 and earlier.
      
      commit 9da5f96575acc6c378dd469b7390df1dae78bf0a
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 18:55:47 2022 +0100
      
          Make sure the testing page always tests the last question version.
          This allows the question author to reload the question testing page after a question has been saved.
      
      commit 3c3fcf09d38a5fc981850f037ba8221b21400c24
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 18:14:23 2022 +0100
      
          WIP commit for testing on both Moodle 4.0 and earlier.
      
      commit d00a6f11400fd6af29fb5a646cc83fbb6670ea20
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 17:51:40 2022 +0100
      
          Support on both Moodle 4 and earlier versions (WIP for testing).
      
      commit 07402d5c8249e6d320404973451b819b78a661ca
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 16:46:17 2022 +0100
      
          Support both Moodle 4.0 and previous versions (WIP for testing).
      
      commit 1dccc92e1b0805305505afc3b8a7174792b6dfd2
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 16:07:46 2022 +0100
      
          Add coverage information to unit tests.
      
      commit c8d16b1f829b62f1c8dd8ee7f99e725c178debe2
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 08:36:17 2022 +0100
      
          Add coverage information for auto-generated ast tests.
      
      commit 6ae39e5063fa5d2d4c0a78a10ad56343c78c8fa2
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 08:16:20 2022 +0100
      
          Fix broken unit tests.
      
      commit 38daee7cf0b54dbacf4016bc3fa15dba6adc4b27
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jun 14 20:02:36 2022 +0100
      
          Fix broken test case.
      
      commit ad2f8b04f6e4227c9f525e2650f03e891d69e0ad
      Author: Chris Sangwin <csangwin@coulomb.maths.ed.ac.uk>
      Date:   Tue Jun 14 18:22:16 2022 +0100
      
          Fix bug with test case & seed copying between versions.
      
      commit b4ce5ee24a6f12e724f7c74f9dd53207a426906c
      Merge: 9b325b9a 0e20187b
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Sun Jun 12 19:20:03 2022 +0100
      
          Merge remote-tracking branch 'origin/dev' into moodle4
      
      commit 9b325b9aa2b5e01dd5fbd399931e62423262ee3f
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Sun Jun 12 11:34:44 2022 +0100
      
          Update question basic useage report for Moodle 4.
      
      commit f57cffeba5dd643b107f7dbf3b478b4a48fc2af0
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Sat Jun 11 18:26:09 2022 +0100
      
          Fix failing unit test (artefact of test case construction) + code tidy.
      
      commit e85d6508a3e9f6efcef666cab7cf59fd36c38c24
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Sat Jun 11 17:01:01 2022 +0100
      
          Seeds copy over to a new version.
      
      commit 9bb4aec386b478468f8af04c515d598c029da932
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Sat Jun 11 16:46:16 2022 +0100
      
          Fix to issue #805.
      
      commit 52828b431bcd01f59ea1401915962f8e039aba79
      Merge: e311ad72 cb8d8a74
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Fri Jun 10 14:41:54 2022 +0100
      
          Merge remote-tracking branch 'origin/dev' into moodle4
      
      commit e311ad72f63bc7d7605e0ec68bf2b9faa752bf78
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Fri Jun 10 11:44:39 2022 +0100
      
          WIP enable bulk tester to run with moodle 4 (unblocks question testing).
      
      commit 4145bb1064a5755c1fb2cb8a2b013ba34adf9d2f
      Merge: fc6a81cb 49f70d7f
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Thu Jun 9 15:46:28 2022 +0100
      
          Merge branch 'moodle4' of https://github.com/maths/moodle-qtype_stack into moodle4
      
      commit fc6a81cb011d9b74d8d4b1a5b63bc87abbe38b28
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Thu Jun 9 15:46:17 2022 +0100
      
          Update todo and developer docs.
      
      commit 49f70d7f9c71e887fe7a6266d40aea9a44a14769
      Author: Matti Harjula <aharjula@konsta.hut.fi>
      Date:   Tue Jun 7 09:19:22 2022 +0300
      
          Codestyle *castext*.
      
      commit d52180b635f2e6f2f18279b1f36ee28d2d509802
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Thu Jun 2 09:58:55 2022 +0100
      
          Audit very stack-specific issues when running on Moodle 4.0.
      346f51b9
      History
      Prototype support for Moodle 4.0.
      Chris Sangwin authored
      Squashed commit of the following:
      
      commit ca5c2a34c95b63df46bca81cb4875e42425ddbe5
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 21:11:35 2022 +0100
      
          Support bulk tester in Moodle 4 and earlier.
      
      commit 9da5f96575acc6c378dd469b7390df1dae78bf0a
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 18:55:47 2022 +0100
      
          Make sure the testing page always tests the last question version.
          This allows the question author to reload the question testing page after a question has been saved.
      
      commit 3c3fcf09d38a5fc981850f037ba8221b21400c24
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 18:14:23 2022 +0100
      
          WIP commit for testing on both Moodle 4.0 and earlier.
      
      commit d00a6f11400fd6af29fb5a646cc83fbb6670ea20
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 17:51:40 2022 +0100
      
          Support on both Moodle 4 and earlier versions (WIP for testing).
      
      commit 07402d5c8249e6d320404973451b819b78a661ca
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 16:46:17 2022 +0100
      
          Support both Moodle 4.0 and previous versions (WIP for testing).
      
      commit 1dccc92e1b0805305505afc3b8a7174792b6dfd2
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 16:07:46 2022 +0100
      
          Add coverage information to unit tests.
      
      commit c8d16b1f829b62f1c8dd8ee7f99e725c178debe2
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 08:36:17 2022 +0100
      
          Add coverage information for auto-generated ast tests.
      
      commit 6ae39e5063fa5d2d4c0a78a10ad56343c78c8fa2
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jul 5 08:16:20 2022 +0100
      
          Fix broken unit tests.
      
      commit 38daee7cf0b54dbacf4016bc3fa15dba6adc4b27
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Tue Jun 14 20:02:36 2022 +0100
      
          Fix broken test case.
      
      commit ad2f8b04f6e4227c9f525e2650f03e891d69e0ad
      Author: Chris Sangwin <csangwin@coulomb.maths.ed.ac.uk>
      Date:   Tue Jun 14 18:22:16 2022 +0100
      
          Fix bug with test case & seed copying between versions.
      
      commit b4ce5ee24a6f12e724f7c74f9dd53207a426906c
      Merge: 9b325b9a 0e20187b
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Sun Jun 12 19:20:03 2022 +0100
      
          Merge remote-tracking branch 'origin/dev' into moodle4
      
      commit 9b325b9aa2b5e01dd5fbd399931e62423262ee3f
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Sun Jun 12 11:34:44 2022 +0100
      
          Update question basic useage report for Moodle 4.
      
      commit f57cffeba5dd643b107f7dbf3b478b4a48fc2af0
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Sat Jun 11 18:26:09 2022 +0100
      
          Fix failing unit test (artefact of test case construction) + code tidy.
      
      commit e85d6508a3e9f6efcef666cab7cf59fd36c38c24
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Sat Jun 11 17:01:01 2022 +0100
      
          Seeds copy over to a new version.
      
      commit 9bb4aec386b478468f8af04c515d598c029da932
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Sat Jun 11 16:46:16 2022 +0100
      
          Fix to issue #805.
      
      commit 52828b431bcd01f59ea1401915962f8e039aba79
      Merge: e311ad72 cb8d8a74
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Fri Jun 10 14:41:54 2022 +0100
      
          Merge remote-tracking branch 'origin/dev' into moodle4
      
      commit e311ad72f63bc7d7605e0ec68bf2b9faa752bf78
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Fri Jun 10 11:44:39 2022 +0100
      
          WIP enable bulk tester to run with moodle 4 (unblocks question testing).
      
      commit 4145bb1064a5755c1fb2cb8a2b013ba34adf9d2f
      Merge: fc6a81cb 49f70d7f
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Thu Jun 9 15:46:28 2022 +0100
      
          Merge branch 'moodle4' of https://github.com/maths/moodle-qtype_stack into moodle4
      
      commit fc6a81cb011d9b74d8d4b1a5b63bc87abbe38b28
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Thu Jun 9 15:46:17 2022 +0100
      
          Update todo and developer docs.
      
      commit 49f70d7f9c71e887fe7a6266d40aea9a44a14769
      Author: Matti Harjula <aharjula@konsta.hut.fi>
      Date:   Tue Jun 7 09:19:22 2022 +0300
      
          Codestyle *castext*.
      
      commit d52180b635f2e6f2f18279b1f36ee28d2d509802
      Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
      Date:   Thu Jun 2 09:58:55 2022 +0100
      
          Audit very stack-specific issues when running on Moodle 4.0.
    grade.php 5.01 KiB
    <?php
    // This file is part of Moodle - http://moodle.org/
    //
    // Moodle is free software: you can redistribute it and/or modify
    // it under the terms of the GNU General Public License as published by
    // the Free Software Foundation, either version 3 of the License, or
    // (at your option) any later version.
    //
    // Moodle is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
    //
    // You should have received a copy of the GNU General Public License
    // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
    /**
     * View all results for H5P Content
     *
     * @package    mod_hvp
     * @copyright  2016 Joubel AS <contact@joubel.com>
     * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
     */
    
    require_once(dirname(__FILE__) . '/../../config.php');
    require_once("locallib.php");
    
    global $DB, $PAGE, $USER, $COURSE;
    
    $id = required_param('id', PARAM_INT);
    $userid = optional_param('userid', 0, PARAM_INT);
    
    if (! $cm = get_coursemodule_from_id('hvp', $id)) {
        print_error('invalidcoursemodule');
    }
    if (! $course = $DB->get_record('course', array('id' => $cm->course))) {
        print_error('coursemisconf');
    }
    require_course_login($course, false, $cm);
    
    // Check permission.
    $context = \context_module::instance($cm->id);
    
    // Load H5P Content.
    $hvp = $DB->get_record_sql(
            "SELECT h.id,
                    h.name AS title,
                    hl.machine_name,
                    hl.major_version,
                    hl.minor_version
               FROM {hvp} h
               JOIN {hvp_libraries} hl ON hl.id = h.main_library_id
              WHERE h.id = ?",
            array($cm->instance));
    
    if ($hvp === false) {
        print_error('invalidhvp', 'mod_hvp');
    }
    
    // Redirect to report if a specific user is chosen.
    if ($userid) {
        redirect(new moodle_url('/mod/hvp/review.php',
            array(
                'id'     => $hvp->id,
                'course' => $course->id,
                'user'   => $userid
            ))
        );
    }
    hvp_require_view_results_permission((int)$USER->id, $context, $cm->id);
    
    // Log content result view.
    new \mod_hvp\event(
            'results', 'content',
            $hvp->id, $hvp->title,
            $hvp->machine_name, "{$hvp->major_version}.{$hvp->minor_version}"
    );
    
    // Set page properties.
    $pageurl = new moodle_url('/mod/hvp/grade.php', array('id' => $hvp->id));
    $PAGE->set_url($pageurl);
    $title = get_string('gradeheading', 'hvp', $hvp->title);
    $PAGE->set_title($title);
    $PAGE->set_heading($course->fullname);
    
    // List all results for specific content.
    $dataviewid = 'h5p-results';
    
    // Add required assets for data views.
    $root = \mod_hvp\view_assets::getsiteroot();
    $PAGE->requires->js(new moodle_url($root . '/mod/hvp/library/js/jquery.js'), true);
    $PAGE->requires->js(new moodle_url($root . '/mod/hvp/library/js/h5p-utils.js'), true);
    $PAGE->requires->js(new moodle_url($root . '/mod/hvp/library/js/h5p-data-view.js'), true);
    $PAGE->requires->js(new moodle_url($root . '/mod/hvp/dataviews.js'), true);
    $PAGE->requires->css(new moodle_url($root . '/mod/hvp/styles.css'));
    
    // Add JavaScript settings to data views.
    $settings = array(
        'dataViews' => array(
            "{$dataviewid}" => array(
                'source' => "{$root}/mod/hvp/ajax.php?action=results&content_id={$hvp->id}",
                'headers' => array(
                    (object) array(
                        'text' => get_string('user', 'hvp'),
                        'sortable' => true
                    ),
                    (object) array(
                        'text' => get_string('score', 'hvp'),
                        'sortable' => true
                    ),
                    (object) array(
                        'text' => get_string('maxscore', 'hvp'),
                        'sortable' => true
                    ),
                    (object) array(
                        'text' => get_string('finished', 'hvp'),
                        'sortable' => true
                    ),
                    (object) array(
                        'text' => get_string('dataviewreportlabel', 'hvp')
                    )
                ),
                'filters' => array(true),
                'order' => (object) array(
                    'by' => 3,
                    'dir' => 0
                ),
                'l10n' => array(
                    'loading' => get_string('loadingdata', 'hvp'),
                    'ajaxFailed' => get_string('ajaxfailed', 'hvp'),
                    'noData' => get_string('nodata', 'hvp'),
                    'currentPage' => get_string('currentpage', 'hvp'),
                    'nextPage' => get_string('nextpage', 'hvp'),
                    'previousPage' => get_string('previouspage', 'hvp'),
                    'search' => get_string('search', 'hvp'),
                    'empty' => get_string('empty', 'hvp')
                )
            )
        )
    );
    $PAGE->requires->data_for_js('H5PIntegration', $settings, true);
    
    // Print page HTML.
    echo $OUTPUT->header();
    echo '<div class="clearer"></div>';
    
    // Print H5P Content.
    echo "<h2>{$title}</h2>";
    echo '<div id="h5p-results">' . get_string('javascriptloading', 'hvp') . '</div>';
    
    echo $OUTPUT->footer();