diff --git a/amd/src/evaluationmonitor.js b/amd/src/evaluationmonitor.js index 4a5f9eca61b6bb976d2e07c1d286589e3921b97e..d1c28b4d4f61d352eb333771c469da80f2cba4bb 100644 --- a/amd/src/evaluationmonitor.js +++ b/amd/src/evaluationmonitor.js @@ -35,11 +35,11 @@ define(['mod_vpl/vplutil'],function(VPLUtil) { } var action; var executionActions = { - 'ajaxurl' : options.ajaxurl, - 'run' : showErrorMessage, - 'getLastAction' : function() { - action(); - }, + 'ajaxurl' : options.ajaxurl, + 'run' : showErrorMessage, + 'getLastAction' : function() { + action(); + }, }; action = function() { VPLUtil.requestAction('evaluate', 'evaluating', {}, options.ajaxurl) diff --git a/forms/advancedgrading.php b/forms/advancedgrading.php deleted file mode 100644 index fe8e9984c8154d40b83c0eafaf1a37703d4bbfd8..0000000000000000000000000000000000000000 --- a/forms/advancedgrading.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php -// This file is part of VPL for Moodle - http://vpl.dis.ulpgc.es/ -// -// VPL for 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. -// -// VPL for 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 VPL for Moodle. If not, see <http://www.gnu.org/licenses/>. - -/** - * Variation definitions form - * - * @package mod_vpl - * @copyright 2012 Juan Carlos RodrÃguez-del-Pino - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @author Juan Carlos RodrÃguez-del-Pino <jcrodriguez@dis.ulpgc.es> - */ - -require_once(dirname(__FILE__).'/../../../config.php'); -require_once(dirname(__FILE__).'/../locallib.php'); -require_once($CFG->libdir.'/gradelib.php'); -require_once(dirname(__FILE__).'/../vpl.class.php'); -require_once($CFG->libdir.'/formslib.php'); - - - -class mod_vpl_advancedgrading_form extends moodleform { - protected $vpl; - protected $submission; - // Parm $varid = -1 new variation. - public function __construct($page, $vplid, $submissionid) { - global $DB; - $this->vpl = new mod_vpl( $vplid); - if ($submissionid>0) { - $this->submission = new mod_vpl_submission( $this->vpl,$submissionid ); - } else { - $this->submission = $this->vpl->last_user_submission( $userid ); - } - parent::__construct( $page ); - } - protected function definition() { - - $userid = optional_param( 'userid', null, PARAM_INT ); - // Add advanced grading. - $gradeid = $this->vpl->get_grade_info()->id; - $gradinginstance = $this->submission->get_grading_instance($userid, $gradeid); - - if ($gradinginstance) { - $grade = $this->vpl->get_grade(); - $res = $this->submission->getCE(); - if ($res ['executed']) { - $graderaw = $this->submission->proposedGrade($res['execution']); - }else{ - $graderaw = 0; - } - $gridscore = $gradinginstance->get_controller()->get_min_max_score()['maxscore']; - $mform = & $this->_form; - - $mform->addElement( 'header', 'hadvancedgrading' , get_string('gradingmanagement', 'core_grading') ); - $mform->addElement( 'hidden', 'id', required_param( 'id', PARAM_INT ) ); - $mform->setType( 'id', PARAM_INT ); - $mform->addElement( 'hidden', 'userid', $userid ); - $mform->setType( 'userid', PARAM_INT ); - - $mform->addElement('grading', - 'advancedgrading', - '', - array('gradinginstance' => $gradinginstance)); - $mform->addElement('hidden','advancedgradinginstanceid', $gradinginstance->get_id()); - $mform->setType('advancedgradinginstanceid', PARAM_INT); - // Numeric grade. - if ($grade > 0) { - // Link to recalculate numeric grade from comments. - $jscript = 'VPL.mergeGrade(' . $grade . ','.$graderaw.','.$gridscore.')'; - $html = ' <a class="btn btn-default" href="javascript:void(0);" onclick="' . $jscript . '">' . s( get_string( 'merge', VPL ) ) . '</a>'; - $mform->addElement('html', $html ); - } - //$this->add_action_buttons( true, get_string( 'submit' ) ); - - } - } -} diff --git a/forms/edit.php b/forms/edit.php index f0d9a71e508de21642d55a1d23b87fd7d5156df5..f715370d3ec91a4da954ebdbfea6cb1b065904c6 100644 --- a/forms/edit.php +++ b/forms/edit.php @@ -124,9 +124,6 @@ if ($lastsub) { \mod_vpl\event\submission_edited::log( $submission ); } session_write_close(); -if ($copy && $grader) { - $userid = $USER->id; -} vpl_editor_util::generate_requires($options); $vpl->print_header( get_string( 'edit', VPL ) ); $vpl->print_view_tabs( basename( __FILE__ ) ); diff --git a/forms/executionoptions.php b/forms/executionoptions.php index 9ed103bbb735e56b3da073ddbb2331c89598702b..344f375f9a128491f922ad7fd800b5cb9cb6d1bd 100644 --- a/forms/executionoptions.php +++ b/forms/executionoptions.php @@ -70,7 +70,7 @@ class mod_vpl_executionoptions_form extends moodleform { } protected function definition() { - global $DB; + global $DB; $mform = & $this->_form; $id = $this->vpl->get_course_module()->id; $instance = $this->vpl->get_instance(); @@ -85,30 +85,30 @@ class mod_vpl_executionoptions_form extends moodleform { $basedonlist = array (); $basedonlist [0] = ''; $courseslist = array_keys(enrol_get_my_courses()); - foreach ($courseslist as $courseid){ + foreach ($courseslist as $courseid) { $listcm = get_coursemodules_in_course( VPL, $courseid ); foreach ($listcm as $aux) { if ($aux->instance != $vplid) { - $vpl = new mod_vpl( $aux->id ); - if ($vpl->is_use_as_base()){ - $basedonlist[$aux->instance] = $vpl->get_printable_name(); - } - } - } - } - $vpls_basedon_and_shared = $DB->get_records_sql("SELECT course_modules.id, course_modules.instance - FROM course_modules - JOIN vpl ON vpl.id = course_modules.instance - JOIN local_metadata ON course_modules.id = local_metadata.instanceid - WHERE vpl.usableasbase = 1 AND local_metadata.fieldid = 28 AND local_metadata.data = 1 AND course_modules.module = 23"); - foreach ($vpls_basedon_and_shared as $mod_vpl) { - if ($mod_vpl->instance != $vplid) { - $vpl = new mod_vpl( $mod_vpl->id ); - $basedonlist[$mod_vpl->instance] = $vpl->get_printable_name(); - } - } - asort( $basedonlist ); - $basedonlist [0] = get_string( 'select' ); + $vpl = new mod_vpl( $aux->id ); + if ($vpl->is_use_as_base()) { + $basedonlist[$aux->instance] = $vpl->get_printable_name(); + } + } + } + } + $vpls_basedon_and_shared = $DB->get_records_sql("SELECT course_modules.id, course_modules.instance + FROM course_modules + JOIN vpl ON vpl.id = course_modules.instance + JOIN local_metadata ON course_modules.id = local_metadata.instanceid + WHERE vpl.usableasbase = 1 AND local_metadata.fieldid = 28 AND local_metadata.data = 1 AND course_modules.module = 23"); + foreach ($vpls_basedon_and_shared as $mod_vpl) { + if ($mod_vpl->instance != $vplid) { + $vpl = new mod_vpl( $mod_vpl->id ); + $basedonlist[$mod_vpl->instance] = $vpl->get_printable_name(); + } + } + asort( $basedonlist ); + $basedonlist [0] = get_string( 'select' ); $mform->addElement( 'select', 'basedon', $strbasedon, $basedonlist ); $mform->setDefault( 'basedon', $instance->basedon ); @@ -147,14 +147,11 @@ require_login(); $id = required_param( 'id', PARAM_INT ); $vpl = new mod_vpl( $id ); $vpl->prepare_page( 'forms/executionoptions.php', array ( 'id' => $id ) ); -vpl_include_jsfile( 'hideshow.js' ); $vpl->require_capability( VPL_MANAGE_CAPABILITY ); // Display page. -$vpl->print_header( get_string( 'execution', VPL ) ); +$vpl->print_header( get_string( 'executionoptions', VPL ) ); $vpl->print_heading_with_help( 'executionoptions' ); -$course = $vpl->get_course(); -$fgp = $vpl->get_fgm('execution'); $mform = new mod_vpl_executionoptions_form( 'executionoptions.php', $vpl ); if ($fromform = $mform->get_data()) { if (isset( $fromform->saveoptions )) { diff --git a/jscript/grade.js b/jscript/grade.js index 04fb19bbde0d66566c8199c0cbd0a8f3add2e7a3..cbd168023aafe2a591bf4eee7d5c1a1cd1b54cbb 100644 --- a/jscript/grade.js +++ b/jscript/grade.js @@ -74,7 +74,7 @@ * end of lines. valid grade format: "- text (-grade)" */ VPL.calculateGrade = function(maxgrade) { - var form1 = window.document.getElementById('form1'); + var form1 = window.document.getElementById('mform1'); var text = form1.comments.value; var grade = parseFloat(maxgrade); var regDiscount = /^-.+\(([0-9\.\-]+)\) *$/gm; diff --git a/jscript/hide_footer.js b/jscript/hide_footer.js deleted file mode 100644 index ebc56986df7eb22ce1eab8fc82832b7f5bc915d3..0000000000000000000000000000000000000000 --- a/jscript/hide_footer.js +++ /dev/null @@ -1,33 +0,0 @@ -// This file is part of VPL for Moodle - http://vpl.dis.ulpgc.es/ -// -// VPL for 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. -// -// VPL for 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 VPL for Moodle. If not, see <http://www.gnu.org/licenses/>. - -/** - * JavaScript action to hide page footer - * @package mod_vpl - * @copyright 2012 Juan Carlos RodrÃguez-del-Pino - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @author Juan Carlos RodrÃguez-del-Pino <jcrodriguez@dis.ulpgc.es> - */ - -(function() { - var footer = document.getElementById('page-footer'); - if (footer !== null) { - footer.style.display = 'none'; - } - footer = document.getElementById('footer'); - if (footer !== null) { - footer.style.display = 'none'; - } -})(); diff --git a/jscript/hideshow.js b/jscript/hideshow.js index 702679d39383cf5e46fecce7791a6fca71a1962b..f6c799f4707c9dd5f3844793eefa2d7625c4ae07 100644 --- a/jscript/hideshow.js +++ b/jscript/hideshow.js @@ -41,12 +41,4 @@ } } }; - VPL.hide_later = function (){ - var div = window.document.getElementById('vpl.hide'); - if(div){ - div.style.transition = 'display 2s'; - div.style.display = 'none'; - } - }; - setTimeout(VPL.hide_later, 5000); })(); diff --git a/nbproject/project.properties b/nbproject/project.properties deleted file mode 100644 index 911a7b8bd89070c84f0fbc63f56156221eaae924..0000000000000000000000000000000000000000 --- a/nbproject/project.properties +++ /dev/null @@ -1,7 +0,0 @@ -include.path=${php.global.include.path} -php.version=PHP_70 -source.encoding=UTF-8 -src.dir=. -tags.asp=false -tags.short=false -web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml deleted file mode 100644 index 0d72c52d38a5347066d0bb25f28e7fa355cec81c..0000000000000000000000000000000000000000 --- a/nbproject/project.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.php.project</type> - <configuration> - <data xmlns="http://www.netbeans.org/ns/php-project/1"> - <name>moodle-mod_vpl</name> - </data> - </configuration> -</project> diff --git a/similarity/similarity_sources.class.php b/similarity/similarity_sources.class.php index f87da36b806121dd784bc09c880717b7203d4c64..43dc4a01b73b0f76d63a9fcec2c466f334b3cab5 100644 --- a/similarity/similarity_sources.class.php +++ b/similarity/similarity_sources.class.php @@ -184,7 +184,7 @@ class vpl_file_from_activity extends vpl_file_from_base { $user = false; } if ($user) { - $ret .= '<a href="' . vpl_mod_href( '/forms/submissionview.php', 'id', $cmid, 'userid', $user->id ) . '">'; + $ret .= '<a href="' . vpl_mod_href( 'forms/submissionview.php', 'id', $cmid, 'userid', $user->id ) . '">'; } $ret .= s( $this->filename ); if ($user) { @@ -192,7 +192,7 @@ class vpl_file_from_activity extends vpl_file_from_base { $sub = new mod_vpl_submission( $vpl, $this->subid ); $ret .= $sub->get_grade_core() . '<br />'; $ret .= $vpl->user_fullname_picture( $user ); - $link = vpl_mod_href( '/similarity/user_similarity.php', 'id', $vpl->get_course()->id, 'userid', $user->id ); + $link = vpl_mod_href( 'similarity/user_similarity.php', 'id', $vpl->get_course()->id, 'userid', $user->id ); $ret .= ' (<a href="' . $link . '">'; $ret .= '*</a>)'; } @@ -307,7 +307,7 @@ class vpl_similarity_preprocess { } $submissions = $vpl->all_last_user_submission(); // Get initial content files. - $reqf = $vpl->get_fgm('required'); + $reqf = $vpl->get_fgm('required'); $toremove = self::proccess_files( $reqf, $filesselected, $allfiles, $joinedfiles ); $spb->set_max( count( $list ) ); diff --git a/views/show_hide_div.class.php b/views/show_hide_div.class.php index 5b5e2aec38283937e84e1b62503d7d68a0ab64fb..f72e7643ca17db5808f4f6de540d0325f28c85b8 100644 --- a/views/show_hide_div.class.php +++ b/views/show_hide_div.class.php @@ -78,6 +78,10 @@ class vpl_hide_show_div { } } + public function create_div($content) { + return self::begin_div(true) . $content . self::end_div(true); + } + public function get_div_id() { return 'shd' . $this->id; } diff --git a/vpl_submission.class.php b/vpl_submission.class.php index d0f5ba0fd0865820af2bc7d9bf517e56673c1026..65add2f13460c93e366c9b6940d70c4582d7e4d7 100644 --- a/vpl_submission.class.php +++ b/vpl_submission.class.php @@ -13,7 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with VPL for Moodle. If not, see <http://www.gnu.org/licenses/>. - + /** * Submission class definition * @@ -22,7 +22,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Juan Carlos RodrÃguez-del-Pino <jcrodriguez@dis.ulpgc.es> */ - + /** * Module instance files * path= vpl_data//vpl_instance# @@ -38,7 +38,7 @@ require_once(dirname(__FILE__).'/vpl.class.php'); require_once(dirname(__FILE__).'/views/sh_factory.class.php'); require_once(dirname(__FILE__).'/views/show_hide_div.class.php'); require_once($CFG->dirroot . '/grade/grading/lib.php'); - + // Non static due to usort error. function vpl_compare_filenamebylengh($f1, $f2) { return strlen( $f2 ) - strlen( $f1 ); @@ -46,14 +46,14 @@ function vpl_compare_filenamebylengh($f1, $f2) { class mod_vpl_submission { protected $vpl; protected $instance; - + /** * Internal var object to submitted file group manager * * @var object of file group manager */ protected $submittedfgm; - + /** * Constructor * @@ -79,8 +79,8 @@ class mod_vpl_submission { } $this->submittedfgm = null; } - - /** + + /** * get submission instance * * @return object submission instance @@ -88,7 +88,7 @@ class mod_vpl_submission { public function get_instance() { return $this->instance; } - + /** * get vpl object related * @@ -120,8 +120,8 @@ class mod_vpl_submission { */ public function get_data_directory() { return $this->vpl->get_users_data_directory() . '/' . $this->instance->userid . '/' . $this->instance->id . '/'; - } - + } + /** * get path to files submission directory * @@ -130,7 +130,7 @@ class mod_vpl_submission { public function get_submission_directory() { return $this->get_data_directory() . 'submittedfiles/'; } - + /** * get absolute path to name of file with list of submitted files * @@ -139,7 +139,7 @@ class mod_vpl_submission { public function get_submissionfilelistname() { return $this->get_data_directory() . 'submittedfiles.lst'; } - + /** * * @return object file group manager for submitted files @@ -150,7 +150,7 @@ class mod_vpl_submission { } return $this->submittedfgm; } - + /** * get absolute path to the grade comments file name * @@ -159,7 +159,7 @@ class mod_vpl_submission { public function get_gradecommentsfilename() { return $this->get_data_directory() . 'grade_comments.txt'; } - + /** * get submitted files * @@ -204,7 +204,7 @@ class mod_vpl_submission { } return true; } - + /** * Delete submitted files and own record * @@ -219,7 +219,7 @@ class mod_vpl_submission { 'id' => $this->instance->id ) ); } - + /** * Return if submission has been graded * @@ -228,7 +228,7 @@ class mod_vpl_submission { public function is_graded() { return $this->instance->dategraded > 0; } - + /** * Remove grade * @@ -241,7 +241,7 @@ class mod_vpl_submission { ignore_user_abort( true ); if ($this->vpl->is_group_activity()) { $usersid = array (); - foreach ($this->vpl->get_group_members( $this->instance->groupid ) as $user) { + foreach ($this->vpl->get_group_members( $this->instance->groupid ) as $user) { $usersid [] = $user->id; } } else { @@ -296,7 +296,7 @@ class mod_vpl_submission { } return true; } - + /** * get current grade reduction * @@ -323,7 +323,7 @@ class mod_vpl_submission { $reduction = $vplinstance->reductionbyevaluation * $mul; } } - /** + /** * String with the reduction policy * * @param $grade @@ -352,7 +352,7 @@ class mod_vpl_submission { $html .= $OUTPUT->help_icon('finalreduction', VPL); return $html; } - + /** * Reduce grade based en number of evaluations * @@ -360,7 +360,7 @@ class mod_vpl_submission { * grade value * @return new grade */ - public function reduce_grade($grade) { + public function reduce_grade($grade) { $this->grade_reduction($reduction, $percent); if ($reduction > 0) { if ($percent) { @@ -371,7 +371,7 @@ class mod_vpl_submission { } return $grade; } - + /** * Set/update grade * @@ -402,7 +402,7 @@ class mod_vpl_submission { $usersid [] = $user->id; } } else { - $usersid = array ( + $usersid = array ( $this->instance->userid ); } @@ -442,7 +442,7 @@ class mod_vpl_submission { $gradeinfo ['feedback'] = $this->result_to_html( $comments, false ); $gradeinfo ['feedbackformat'] = FORMAT_HTML; } - if ($this->instance->grader > 0) { // Don't add grader if automatic. + if ($this->instance->grader > 0) { // Don't add grader if automatic. $gradeinfo ['usermodified'] = $this->instance->grader; } else { // This avoid to use an unexisting userid (0) in the gradebook. $gradeinfo ['usermodified'] = $USER->id; @@ -502,7 +502,7 @@ class mod_vpl_submission { } return true; } - + /** * Get grade comments * @@ -520,7 +520,7 @@ class mod_vpl_submission { } return $ret; } - + /** * is visible this submission instance * @@ -541,7 +541,7 @@ class mod_vpl_submission { $ret = $ret || $this->vpl->has_capability( VPL_GRADE_CAPABILITY ); return $ret; } - + /** * is possible to grade/update this submission instance * @@ -564,13 +564,13 @@ class mod_vpl_submission { } return $ret; } - + /** * * @var array of users(graders) objects */ protected static $graders = array (); - + /** * Return user from DB with cache (automatic grader info for $id===0) * @@ -605,19 +605,19 @@ class mod_vpl_submission { } return $graderuser; } - - /** + + /** * Get an instance of a grading form if advanced grading is enabled. * This is specific to the assignment, marker and student. * * @return mixed gradingform_instance|null $gradinginstance */ - public function get_grading_instance() { + public function get_grading_instance() { global $CFG, $USER; - + $grademenu = make_grades_menu($this->get_instance()->grade); $allowgradedecimals = $this->get_instance()->grade > 0; - + $advancedgradingwarning = false; $gradingmanager = get_grading_manager($this->vpl->get_context(), 'mod_vpl', 'submissions'); $gradinginstance = null; @@ -637,13 +637,13 @@ class mod_vpl_submission { } return $gradinginstance; } - + /** * Get core grade @parm optional grade to show * * @return string */ - public function get_grade_core($grade = null) { + public function get_grade_core($grade = null) { global $CFG; $ret = ''; $inst = $this->instance; @@ -695,7 +695,7 @@ class mod_vpl_submission { } return $ret; } - + /** * Print sudmission grade * @@ -706,7 +706,7 @@ class mod_vpl_submission { * @return mix string/void */ public function print_grade($detailed = false, $return = false) { - global $CFG, $OUTPUT,$PAGE,$USER; + global $CFG, $OUTPUT, $PAGE, $USER; $ret = ''; $inst = $this->instance; if ($inst->dategraded > 0) { @@ -716,7 +716,7 @@ class mod_vpl_submission { $a->gradername = fullname( $grader ); $ret .= get_string( 'gradedonby', VPL, $a ) . '<br />'; if ($this->vpl->get_grade() != 0) { - $ret .= $this->vpl->str_restriction('grade', $this->get_grade_core(), true) . '<br>'; + $ret .= $this->vpl->str_restriction(get_string('grade'), $this->get_grade_core(), true) . '<br>'; if ($detailed) { $ret .= $this->reduce_grade_string() . '<br>'; $feedback = $this->get_grade_comments(); @@ -724,19 +724,19 @@ class mod_vpl_submission { $div = new vpl_hide_show_div( true ); $tagid = 'gradercomments' . $this->get_instance()->id; $ret .= '<b>' . get_string( 'gradercomments', VPL ) . $div->generate( true ) . '</b><br />'; - $ret .= $div->begin_div( true ) . s($feedback) . $div->end_div( true ); - $ret .= "<script>VPL_Util.addResults('{$div->get_div_id()}', false, true);</script>"; + $ret .= $div->create_div(s($feedback)); + $PAGE->requires->js_call_amd('mod_vpl/vplutil', 'addResults', array($div->get_div_id(), false, true)); } } } - $cangrade = has_capability(VPL_GRADE_CAPABILITY, $this->vpl->get_context()); - // Only show the grade if it is not hidden in gradebook. - $userid = (has_capability( VPL_GRADE_CAPABILITY, $this->vpl->get_context() ) || has_capability( - VPL_MANAGE_CAPABILITY, $this->vpl->get_context() )) ? null : $USER->id; + require_once($CFG->libdir . '/gradelib.php'); - $gradeinfo = grade_get_grades( $this->vpl->get_course()->id, 'mod', 'vpl', $this->vpl->get_instance()->id, $userid ); $gradinginstance = $this->get_grading_instance(); if ($gradinginstance) { + $cangrade = has_capability(VPL_GRADE_CAPABILITY, $this->vpl->get_context()); + // Only show the grade if it is not hidden in gradebook. + $userid = ($cangrade || has_capability( VPL_MANAGE_CAPABILITY, $this->vpl->get_context() )) ? null : $USER->id; + $gradeinfo = grade_get_grades( $this->vpl->get_course()->id, 'mod', 'vpl', $this->vpl->get_instance()->id, $userid ); $ret .= $gradinginstance->get_controller()->render_grade($PAGE, $this->instance->id, $gradeinfo, @@ -744,10 +744,6 @@ class mod_vpl_submission { $cangrade); } if (! empty( $CFG->enableoutcomes )) { - // Bypass unknow gradelib not load. - if (! function_exists( 'grade_get_grades' )) { - require_once($CFG->libdir . '/gradelib.php'); - } $gradinginfo = grade_get_grades( $this->vpl->get_course()->id, 'mod' , 'vpl', $this->vpl->get_instance()->id , $this->instance->userid ); @@ -765,11 +761,11 @@ class mod_vpl_submission { } else { if ($ret) { echo $OUTPUT->box( $ret ); - + } } } - + /** * Print sudmission info */ @@ -827,14 +823,14 @@ class mod_vpl_submission { echo $OUTPUT->box( nl2br( s( $commmets ) ) ); } } - + /** * Print compilation and execution * * @return void */ public function print_ce() { - global $OUTPUT; + global $OUTPUT, $PAGE; $ce = $this->getce(); if ($ce ['compilation'] === 0) { return; @@ -853,23 +849,23 @@ class mod_vpl_submission { if (strlen( $compilation ) > 0) { $div = new vpl_hide_show_div( true ); echo '<b>' . get_string( 'compilation', VPL ) . $div->generate( true ) . '</b><br />'; - echo $div->begin_div( true ) . s($compilation) . $div->end_div( true ); - echo "<script>VPL_Util.addResults('{$div->get_div_id()}', false, true);</script>"; + echo $div->create_div(s($compilation)); + $PAGE->requires->js_call_amd('mod_vpl/vplutil', 'addResults', array($div->get_div_id(), false, true)); } if (strlen( $execution ) > 0) { $proposedcomments = $this->proposedcomment( $ce ['execution'] ); if (strlen( $execution )) { $div = new vpl_hide_show_div( true ); echo '<b>' . get_string( 'comments', VPL ) . $div->generate( true ) . "</b><br />"; - echo $div->begin_div( true ) . s($proposedcomments) . $div->end_div( true ); - echo "<script>VPL_Util.addResults('{$div->get_div_id()}', false, true);</script>"; + echo $div->create_div(s($proposedcomments)); + $PAGE->requires->js_call_amd('mod_vpl/vplutil', 'addResults', array($div->get_div_id(), false, true)); } } echo $OUTPUT->box_end(); $div->end_div(); } } - + /** * Print sudmission */ @@ -920,7 +916,7 @@ class mod_vpl_submission { } return $ret; } - + /** * Add link to file line format filename:linenumber: * @@ -974,7 +970,7 @@ class mod_vpl_submission { $html .= '<b>'; $html .= s( $title ); $html .= '</b><br />'; - $html .= $div->begin_div( true ) . $comment . $div->end_div( true ); + $html .= $div->create_div($comment); } } else if ($comment > '') { // No title comment. $html .= $comment; @@ -1053,7 +1049,7 @@ class mod_vpl_submission { $comment .= '<br />'; } else if (strlen( $line ) > 1 && $line [0] == '#') { // Teacher comment $html .= $this->get_last_comment( $title, $comment, $dropdown ); - + }else{ // Regular text. $comment .= $this->add_filelink( s( $line ) ) . '<br />'; } @@ -1134,7 +1130,7 @@ class mod_vpl_submission { $result['executed'] = 1; $result['execution'] = ''; } - + $compfn = $this->get_data_directory() . '/' . self::COMPILATIONFN; if (file_exists( $compfn )) { unlink( $compfn ); @@ -1152,7 +1148,7 @@ class mod_vpl_submission { $DB->update_record(VPL_SUBMISSIONS, $this->instance); } } - + /** * Get Compilation Execution information from files * @@ -1179,7 +1175,7 @@ class mod_vpl_submission { $ret ['reductionbyevaluation'] = $vplinstance->reductionbyevaluation; return $ret; } - + /** * Get compilation, execution and proposed grade from array * @@ -1226,9 +1222,7 @@ class mod_vpl_submission { $div = new vpl_hide_show_div(); $execution .= "<br />\n"; $execution .= '<b>' . get_string( 'execution', VPL ) . $div->generate( true ) . "</b><br />\n"; - $execution .= $div->begin_div( true ); - $execution .= '<pre>' . s( $rawexecution ) . '</pre>'; - $execution .= $div->end_div( true ); + $execution .= $div->create_div('<pre>' . s($rawexecution) . '</pre>'); } } } @@ -1242,7 +1236,7 @@ class mod_vpl_submission { $vplinstance = $this->vpl->get_instance(); $ce->freeevaluations = $vplinstance->freeevaluations; $ce->reductionbyevaluation = $vplinstance->reductionbyevaluation; - + if ($response == null) { $response = $this->getce(); } @@ -1298,4 +1292,3 @@ class mod_vpl_submission { return $params; } } - \ No newline at end of file