<commit_before><?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/>.

/**
 * Prints a particular instance of workshop
 *
 * You can have a rather longer description of the file as well,
 * if you like, and it can span multiple lines.
 *
 * @package   mod-workshop
 * @copyright 2009 <NAME> <<EMAIL>>
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/locallib.php');

$id     = optional_param('id', 0, PARAM_INT); // course_module ID, or
$w      = optional_param('w', 0, PARAM_INT);  // workshop instance ID
$edit   = optional_param('edit', null, PARAM_BOOL);

if ($id) {
    $cm         = get_coursemodule_from_id('workshop', $id, 0, false, MUST_EXIST);
    $course     = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
    $workshop   = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
} else {
    $workshop   = $DB->get_record('workshop', array('id' => $w), '*', MUST_EXIST);
    $course     = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST);
    $cm         = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST);
}

require_login($course, true, $cm);
require_capability('mod/workshop:view', $PAGE->context);
add_to_log($course->id, 'workshop', 'view', 'view.php?id=' . $cm->id, $workshop->name, $cm->id);

$workshop = new workshop($workshop, $cm, $course);

if (!is_null($edit) && $PAGE->user_allowed_editing()) {
    $USER->editing = $edit;
}

$PAGE->set_url($workshop->view_url());
$PAGE->set_title($workshop->name);
$PAGE->set_heading($course->fullname);

// todo 
$buttons = array();
if ($PAGE->user_allowed_editing()) {
    $editblocks                 = new html_form();
    $editblocks->method         = 'get';
    $editblocks->button->text   = get_string($PAGE->user_is_editing() ? 'blockseditoff' : 'blocksediton');
    $editblocks->url            = new moodle_url($PAGE->url, array('edit' => $PAGE->user_is_editing() ? 'off' : 'on'));
    $buttons[] = $OUTPUT->button($editblocks);
}
$buttons[] = $OUTPUT->update_module_button($cm->id, 'workshop');
$PAGE->set_button(implode('', $buttons));

$wsoutput = $PAGE->theme->get_renderer('mod_workshop', $PAGE);

/// Output starts here

echo $OUTPUT->header();
include(dirname(__FILE__) . '/tabs.php');
echo $OUTPUT->heading(format_string($workshop->name), 2);
echo $wsoutput->user_plan($workshop->prepare_user_plan($USER->id, $PAGE->context));

switch ($workshop->phase) {
case workshop::PHASE_SETUP:
    if (trim(strip_tags($workshop->intro))) {
        echo $OUTPUT->box(format_module_intro('workshop', $workshop, $workshop->cm->id), 'generalbox', 'intro');
    }
    break;
case workshop::PHASE_SUBMISSION:
    if (trim(strip_tags($workshop->instructauthors))) {
        $instructions = file_rewrite_pluginfile_urls($workshop->instructauthors, 'pluginfile.php', $PAGE->context->id,
            'workshop_instructauthors', 0, workshop::instruction_editors_options($PAGE->context));
        echo $OUTPUT->box(format_text($instructions, $workshop->instructauthorsformat), array('generalbox', 'instructions'));
    }
    if (has_capability('mod/workshop:submit', $PAGE->context)) {
        if ($submission = $workshop->get_submission_by_author($USER->id)) {
            echo $OUTPUT->box_start('generalbox mysubmission');
            echo $wsoutput->submission_summary($submission, true);
            if ($workshop->submitting_allowed()) {
                $editbutton                 = new html_form();
                $editbutton->method         = 'get';
                $editbutton->button->text   = get_string('editsubmission', 'workshop');
                $editbutton->url            = new moodle_url($workshop->submission_url(), array('edit' => 'on', 'id' => $submission->id));
                echo $OUTPUT->button($editbutton);
            }
            echo $OUTPUT->box_end();
        }
    }
    if (has_capability('mod/workshop:viewallsubmissions', $PAGE->context)) {
        $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context);
        echo $OUTPUT->box_start('generalbox allsubmissions');
        if (! $submissions = $workshop->get_submissions('all')) {
            echo $OUTPUT->container(get_string('nosubmissions', 'workshop'), 'nosubmissions');
        }
        foreach ($submissions as $submission) {
            echo $wsoutput->submission_summary($submission, $shownames);
        }
        echo $OUTPUT->box_end();
    }
    break;
case workshop::PHASE_ASSESSMENT:
    if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
        $page       = optional_param('page', 0, PARAM_INT);
        $sortby     = optional_param('sortby', 'lastname', PARAM_ALPHA);
        $sorthow    = optional_param('sorthow', 'ASC', PARAM_ALPHA);
        $perpage    = 10;           // todo let the user modify this
        $groups     = '';           // todo let the user choose the group
        $PAGE->set_url(new moodle_url($PAGE->url, compact('sortby', 'sorthow', 'page')));
        $data = $workshop->prepare_grading_report($USER->id, $groups, $page, $perpage, $sortby, $sorthow);
        if ($data) {
            $showauthornames    = has_capability('mod/workshop:viewauthornames', $workshop->context);
            $showreviewernames  = has_capability('mod/workshop:viewreviewernames', $workshop->context);

            // prepare paging bar
            $pagingbar              = new moodle_paging_bar();
            $pagingbar->totalcount  = $data->totalcount;
            $pagingbar->page        = $page;
            $pagingbar->perpage     = $perpage;
            $pagingbar->baseurl     = $PAGE->url;
            $pagingbar->pagevar     = 'page';

            // grading report display options
            $reportopts                         = new stdClass();
            $reportopts->showauthornames        = $showauthornames;
            $reportopts->showreviewernames      = $showreviewernames;
            $reportopts->sortby                 = $sortby;
            $reportopts->sorthow                = $sorthow;
            $reportopts->showsubmissiongrade    = false;
            $reportopts->showgradinggrade       = false;
            $reportopts->showtotalgrade         = false;

            echo $OUTPUT->paging_bar($pagingbar);
            echo $wsoutput->grading_report($data, $reportopts);
            echo $OUTPUT->paging_bar($pagingbar);
        }
    }
    if (trim(strip_tags($workshop->instructreviewers))) {
        $instructions = file_rewrite_pluginfile_urls($workshop->instructreviewers, 'pluginfile.php', $PAGE->context->id,
            'workshop_instructreviewers', 0, workshop::instruction_editors_options($PAGE->context));
        echo $OUTPUT->box(format_text($instructions, $workshop->instructreviewersformat), array('generalbox', 'instructions'));
    }
    if (! $assessments = $workshop->get_assessments_by_reviewer($USER->id)) {
        echo $OUTPUT->heading(get_string('assignedassessmentsnone', 'workshop'), 3);
    } else {
        echo $OUTPUT->heading(get_string('assignedassessments', 'workshop'), 3);
        $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context);
        foreach ($assessments as $assessment) {
            $submission                     = new stdClass();
            $submission->id                 = $assessment->submissionid;
            $submission->title              = $assessment->submissiontitle;
            $submission->timecreated        = $assessment->submissioncreated;
            $submission->timemodified       = $assessment->submissionmodified;
            $submission->authorid           = $assessment->authorid;
            $submission->authorfirstname    = $assessment->authorfirstname;
            $submission->authorlastname     = $assessment->authorlastname;
            $submission->authorpicture      = $assessment->authorpicture;
            $submission->authorimagealt     = $assessment->authorimagealt;

            if (is_null($assessment->grade)) {
                $class      = ' notgraded';
                $status     = get_string('nogradeyet', 'workshop');
                $buttontext = get_string('assess', 'workshop');
            } else {
                $class      = ' graded';
                $status     = get_string('alreadygraded', 'workshop');
                $buttontext = get_string('reassess', 'workshop');
            }
            echo $OUTPUT->box_start('generalbox assessment-summary' . $class);
            echo $wsoutput->submission_summary($submission, $shownames);
            echo get_string('givengradestatus', 'workshop', $status);
            $button = new html_form();
            $button->method         = 'get';
            $button->button->text   = $buttontext;
            $button->url            = $workshop->assess_url($assessment->id);
            echo $OUTPUT->button($button);
            echo $OUTPUT->box_end();
        }
    }
    break;
case workshop::PHASE_EVALUATION:
    if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
        $page       = optional_param('page', 0, PARAM_INT);
        $sortby     = optional_param('sortby', 'lastname', PARAM_ALPHA);
        $sorthow    = optional_param('sorthow', 'ASC', PARAM_ALPHA);
        $perpage    = 10;           // todo let the user modify this
        $groups     = '';           // todo let the user choose the group
        $PAGE->set_url(new moodle_url($PAGE->url, compact('sortby', 'sorthow', 'page')));
        $data = $workshop->prepare_grading_report($USER->id, $groups, $page, $perpage, $sortby, $sorthow);
        if ($data) {
            $showauthornames    = has_capability('mod/workshop:viewauthornames', $workshop->context);
            $showreviewernames  = has_capability('mod/workshop:viewreviewernames', $workshop->context);

            if (has_capability('mod/workshop:overridegrades', $PAGE->context)) {
                // load the grading evaluator
                $evaluator = $workshop->grading_evaluation_instance();
                $form = $evaluator->get_settings_form(new moodle_url($workshop->aggregate_url(),
                        compact('sortby', 'sorthow', 'page')));
                $form->display();
            }

            // prepare paging bar
            $pagingbar              = new moodle_paging_bar();
            $pagingbar->totalcount  = $data->totalcount;
            $pagingbar->page        = $page;
            $pagingbar->perpage     = $perpage;
            $pagingbar->baseurl     = $PAGE->url;
            $pagingbar->pagevar     = 'page';

            // grading report display options
            $reportopts                         = new stdClass();
            $reportopts->showauthornames        = $showauthornames;
            $reportopts->showreviewernames      = $showreviewernames;
            $reportopts->sortby                 = $sortby;
            $reportopts->sorthow                = $sorthow;
            $reportopts->showsubmissiongrade    = true;
            $reportopts->showgradinggrade       = true;
            $reportopts->showtotalgrade         = true;

            echo $OUTPUT->paging_bar($pagingbar);
            echo $wsoutput->grading_report($data, $reportopts);
            echo $OUTPUT->paging_bar($pagingbar);
        }
    }
    break;
case workshop::PHASE_CLOSED:
    $page       = optional_param('page', 0, PARAM_INT);
    $sortby     = optional_param('sortby', 'totalgrade', PARAM_ALPHA);
    $sorthow    = optional_param('sorthow', 'DESC', PARAM_ALPHA);
    $perpage    = 10;           // todo let the user modify this
    $groups     = '';           // todo let the user choose the group
    $PAGE->set_url(new moodle_url($PAGE->url, compact('sortby', 'sorthow', 'page')));
    $data = $workshop->prepare_grading_report($USER->id, $groups, $page, $perpage, $sortby, $sorthow);
    if ($data) {
        $showauthornames    = has_capability('mod/workshop:viewauthornames', $workshop->context);
        $showreviewernames  = has_capability('mod/workshop:viewreviewernames', $workshop->context);

        // prepare paging bar
        $pagingbar              = new moodle_paging_bar();
        $pagingbar->totalcount  = $data->totalcount;
        $pagingbar->page        = $page;
        $pagingbar->perpage     = $perpage;
        $pagingbar->baseurl     = $PAGE->url;
        $pagingbar->pagevar     = 'page';

        echo $OUTPUT->paging_bar($pagingbar);
        echo $wsoutput->grading_report($data, $showauthornames, $showreviewernames, $sortby, $sorthow);
        echo $OUTPUT->paging_bar($pagingbar);
    }
    break;
default:
}

echo $OUTPUT->footer();
<commit_msg>Renamed a param to handle block editing mode<commit_after><?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/>.

/**
 * Prints a particular instance of workshop
 *
 * You can have a rather longer description of the file as well,
 * if you like, and it can span multiple lines.
 *
 * @package   mod-workshop
 * @copyright 2009 <NAME> <<EMAIL>>
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/locallib.php');

$id         = optional_param('id', 0, PARAM_INT); // course_module ID, or
$w          = optional_param('w', 0, PARAM_INT);  // workshop instance ID
$editmode   = optional_param('editmode', null, PARAM_BOOL);

if ($id) {
    $cm         = get_coursemodule_from_id('workshop', $id, 0, false, MUST_EXIST);
    $course     = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
    $workshop   = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
} else {
    $workshop   = $DB->get_record('workshop', array('id' => $w), '*', MUST_EXIST);
    $course     = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST);
    $cm         = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST);
}

require_login($course, true, $cm);
require_capability('mod/workshop:view', $PAGE->context);
add_to_log($course->id, 'workshop', 'view', 'view.php?id=' . $cm->id, $workshop->name, $cm->id);

$workshop = new workshop($workshop, $cm, $course);

if (!is_null($editmode) && $PAGE->user_allowed_editing()) {
    $USER->editing = $editmode;
}

$PAGE->set_url($workshop->view_url());
$PAGE->set_title($workshop->name);
$PAGE->set_heading($course->fullname);

// todo 
$buttons = array();
if ($PAGE->user_allowed_editing()) {
    $editblocks                 = new html_form();
    $editblocks->method         = 'get';
    $editblocks->button->text   = get_string($PAGE->user_is_editing() ? 'blockseditoff' : 'blocksediton');
    $editblocks->url            = new moodle_url($PAGE->url, array('editmode' => $PAGE->user_is_editing() ? 'off' : 'on'));
    $buttons[] = $OUTPUT->button($editblocks);
}
$buttons[] = $OUTPUT->update_module_button($cm->id, 'workshop');
$PAGE->set_button(implode('', $buttons));

$wsoutput = $PAGE->theme->get_renderer('mod_workshop', $PAGE);

/// Output starts here

echo $OUTPUT->header();
include(dirname(__FILE__) . '/tabs.php');
echo $OUTPUT->heading(format_string($workshop->name), 2);
echo $wsoutput->user_plan($workshop->prepare_user_plan($USER->id, $PAGE->context));

switch ($workshop->phase) {
case workshop::PHASE_SETUP:
    if (trim(strip_tags($workshop->intro))) {
        echo $OUTPUT->box(format_module_intro('workshop', $workshop, $workshop->cm->id), 'generalbox', 'intro');
    }
    break;
case workshop::PHASE_SUBMISSION:
    if (trim(strip_tags($workshop->instructauthors))) {
        $instructions = file_rewrite_pluginfile_urls($workshop->instructauthors, 'pluginfile.php', $PAGE->context->id,
            'workshop_instructauthors', 0, workshop::instruction_editors_options($PAGE->context));
        echo $OUTPUT->box(format_text($instructions, $workshop->instructauthorsformat), array('generalbox', 'instructions'));
    }
    if (has_capability('mod/workshop:submit', $PAGE->context)) {
        if ($submission = $workshop->get_submission_by_author($USER->id)) {
            echo $OUTPUT->box_start('generalbox mysubmission');
            echo $wsoutput->submission_summary($submission, true);
            if ($workshop->submitting_allowed()) {
                $editbutton                 = new html_form();
                $editbutton->method         = 'get';
                $editbutton->button->text   = get_string('editsubmission', 'workshop');
                $editbutton->url            = new moodle_url($workshop->submission_url(), array('edit' => 'on', 'id' => $submission->id));
                echo $OUTPUT->button($editbutton);
            }
            echo $OUTPUT->box_end();
        }
    }
    if (has_capability('mod/workshop:viewallsubmissions', $PAGE->context)) {
        $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context);
        echo $OUTPUT->box_start('generalbox allsubmissions');
        if (! $submissions = $workshop->get_submissions('all')) {
            echo $OUTPUT->container(get_string('nosubmissions', 'workshop'), 'nosubmissions');
        }
        foreach ($submissions as $submission) {
            echo $wsoutput->submission_summary($submission, $shownames);
        }
        echo $OUTPUT->box_end();
    }
    break;
case workshop::PHASE_ASSESSMENT:
    if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
        $page       = optional_param('page', 0, PARAM_INT);
        $sortby     = optional_param('sortby', 'lastname', PARAM_ALPHA);
        $sorthow    = optional_param('sorthow', 'ASC', PARAM_ALPHA);
        $perpage    = 10;           // todo let the user modify this
        $groups     = '';           // todo let the user choose the group
        $PAGE->set_url(new moodle_url($PAGE->url, compact('sortby', 'sorthow', 'page')));
        $data = $workshop->prepare_grading_report($USER->id, $groups, $page, $perpage, $sortby, $sorthow);
        if ($data) {
            $showauthornames    = has_capability('mod/workshop:viewauthornames', $workshop->context);
            $showreviewernames  = has_capability('mod/workshop:viewreviewernames', $workshop->context);

            // prepare paging bar
            $pagingbar              = new moodle_paging_bar();
            $pagingbar->totalcount  = $data->totalcount;
            $pagingbar->page        = $page;
            $pagingbar->perpage     = $perpage;
            $pagingbar->baseurl     = $PAGE->url;
            $pagingbar->pagevar     = 'page';

            // grading report display options
            $reportopts                         = new stdClass();
            $reportopts->showauthornames        = $showauthornames;
            $reportopts->showreviewernames      = $showreviewernames;
            $reportopts->sortby                 = $sortby;
            $reportopts->sorthow                = $sorthow;
            $reportopts->showsubmissiongrade    = false;
            $reportopts->showgradinggrade       = false;
            $reportopts->showtotalgrade         = false;

            echo $OUTPUT->paging_bar($pagingbar);
            echo $wsoutput->grading_report($data, $reportopts);
            echo $OUTPUT->paging_bar($pagingbar);
        }
    }
    if (trim(strip_tags($workshop->instructreviewers))) {
        $instructions = file_rewrite_pluginfile_urls($workshop->instructreviewers, 'pluginfile.php', $PAGE->context->id,
            'workshop_instructreviewers', 0, workshop::instruction_editors_options($PAGE->context));
        echo $OUTPUT->box(format_text($instructions, $workshop->instructreviewersformat), array('generalbox', 'instructions'));
    }
    if (! $assessments = $workshop->get_assessments_by_reviewer($USER->id)) {
        echo $OUTPUT->heading(get_string('assignedassessmentsnone', 'workshop'), 3);
    } else {
        echo $OUTPUT->heading(get_string('assignedassessments', 'workshop'), 3);
        $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context);
        foreach ($assessments as $assessment) {
            $submission                     = new stdClass();
            $submission->id                 = $assessment->submissionid;
            $submission->title              = $assessment->submissiontitle;
            $submission->timecreated        = $assessment->submissioncreated;
            $submission->timemodified       = $assessment->submissionmodified;
            $submission->authorid           = $assessment->authorid;
            $submission->authorfirstname    = $assessment->authorfirstname;
            $submission->authorlastname     = $assessment->authorlastname;
            $submission->authorpicture      = $assessment->authorpicture;
            $submission->authorimagealt     = $assessment->authorimagealt;

            if (is_null($assessment->grade)) {
                $class      = ' notgraded';
                $status     = get_string('nogradeyet', 'workshop');
                $buttontext = get_string('assess', 'workshop');
            } else {
                $class      = ' graded';
                $status     = get_string('alreadygraded', 'workshop');
                $buttontext = get_string('reassess', 'workshop');
            }
            echo $OUTPUT->box_start('generalbox assessment-summary' . $class);
            echo $wsoutput->submission_summary($submission, $shownames);
            echo get_string('givengradestatus', 'workshop', $status);
            $button = new html_form();
            $button->method         = 'get';
            $button->button->text   = $buttontext;
            $button->url            = $workshop->assess_url($assessment->id);
            echo $OUTPUT->button($button);
            echo $OUTPUT->box_end();
        }
    }
    break;
case workshop::PHASE_EVALUATION:
    if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
        $page       = optional_param('page', 0, PARAM_INT);
        $sortby     = optional_param('sortby', 'lastname', PARAM_ALPHA);
        $sorthow    = optional_param('sorthow', 'ASC', PARAM_ALPHA);
        $perpage    = 10;           // todo let the user modify this
        $groups     = '';           // todo let the user choose the group
        $PAGE->set_url(new moodle_url($PAGE->url, compact('sortby', 'sorthow', 'page')));
        $data = $workshop->prepare_grading_report($USER->id, $groups, $page, $perpage, $sortby, $sorthow);
        if ($data) {
            $showauthornames    = has_capability('mod/workshop:viewauthornames', $workshop->context);
            $showreviewernames  = has_capability('mod/workshop:viewreviewernames', $workshop->context);

            if (has_capability('mod/workshop:overridegrades', $PAGE->context)) {
                // load the grading evaluator
                $evaluator = $workshop->grading_evaluation_instance();
                $form = $evaluator->get_settings_form(new moodle_url($workshop->aggregate_url(),
                        compact('sortby', 'sorthow', 'page')));
                $form->display();
            }

            // prepare paging bar
            $pagingbar              = new moodle_paging_bar();
            $pagingbar->totalcount  = $data->totalcount;
            $pagingbar->page        = $page;
            $pagingbar->perpage     = $perpage;
            $pagingbar->baseurl     = $PAGE->url;
            $pagingbar->pagevar     = 'page';

            // grading report display options
            $reportopts                         = new stdClass();
            $reportopts->showauthornames        = $showauthornames;
            $reportopts->showreviewernames      = $showreviewernames;
            $reportopts->sortby                 = $sortby;
            $reportopts->sorthow                = $sorthow;
            $reportopts->showsubmissiongrade    = true;
            $reportopts->showgradinggrade       = true;
            $reportopts->showtotalgrade         = false; // todo totalgrade to be dropped completely

            echo $OUTPUT->paging_bar($pagingbar);
            echo $wsoutput->grading_report($data, $reportopts);
            echo $OUTPUT->paging_bar($pagingbar);
        }
    }
    break;
case workshop::PHASE_CLOSED:
    $page       = optional_param('page', 0, PARAM_INT);
    $sortby     = optional_param('sortby', 'totalgrade', PARAM_ALPHA);
    $sorthow    = optional_param('sorthow', 'DESC', PARAM_ALPHA);
    $perpage    = 10;           // todo let the user modify this
    $groups     = '';           // todo let the user choose the group
    $PAGE->set_url(new moodle_url($PAGE->url, compact('sortby', 'sorthow', 'page')));
    $data = $workshop->prepare_grading_report($USER->id, $groups, $page, $perpage, $sortby, $sorthow);
    if ($data) {
        $showauthornames    = has_capability('mod/workshop:viewauthornames', $workshop->context);
        $showreviewernames  = has_capability('mod/workshop:viewreviewernames', $workshop->context);

        // prepare paging bar
        $pagingbar              = new moodle_paging_bar();
        $pagingbar->totalcount  = $data->totalcount;
        $pagingbar->page        = $page;
        $pagingbar->perpage     = $perpage;
        $pagingbar->baseurl     = $PAGE->url;
        $pagingbar->pagevar     = 'page';

        echo $OUTPUT->paging_bar($pagingbar);
        echo $wsoutput->grading_report($data, $showauthornames, $showreviewernames, $sortby, $sorthow);
        echo $OUTPUT->paging_bar($pagingbar);
    }
    break;
default:
}

echo $OUTPUT->footer();

{'fraction_non_alphanumeric': 0.14737861185582365, 'fraction_numerical': 0.0017128388442061364, 'mean_word_length': 2.6307962687576043, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 399, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '315004', 'n_tokens_mistral': 8115, 'n_tokens_neox': 7919, 'n_words': 1503}