Commit 41e0ca19 authored by Astor Bizard's avatar Astor Bizard
Browse files

Cleaning code style.

parent 3b2d52bb
......@@ -440,7 +440,7 @@ class file_group_process {
* return the directory file
* @return string
*/
public function get_dir() {
public function get_dir() {
return $this->dir;
}
}
......
......@@ -40,7 +40,7 @@ class mod_vpl_grade_form extends moodleform {
$options = array ();
$options [- 1] = get_string( 'nograde' );
if ($scaleid > 0) {
for ($i = 0; $i <= $scaleid; $i ++) {
for ($i = 0; $i <= $scaleid; $i ++) {
$options [$i] = $i . ' / ' . $scaleid;
}
} else if ($scaleid < 0) {
......@@ -53,7 +53,7 @@ class mod_vpl_grade_form extends moodleform {
}
return $options;
}
public function __construct($page, & $vpl,& $submission) {
public function __construct($page, & $vpl, & $submission) {
$this->vpl = & $vpl;
$this->submission = & $submission;
parent::__construct( $page );
......@@ -93,12 +93,12 @@ class mod_vpl_grade_form extends moodleform {
}
$gridscore = $gradinginstance->get_controller()->get_min_max_score()['maxscore'];
$mform->addElement('header','hAdvancedGrading', get_string( 'gradingmanagement','grading') );
$mform->addElement('header', 'hAdvancedGrading', get_string( 'gradingmanagement', 'grading') );
$mform->addElement('grading',
'advancedgrading',
'',
array('gradinginstance' => $gradinginstance));
$mform->addElement('hidden','advancedgradinginstanceid', $gradinginstance->get_id());
$mform->addElement('hidden', 'advancedgradinginstanceid', $gradinginstance->get_id());
$mform->setType('advancedgradinginstanceid', PARAM_INT);
// Numeric grade.
if ($grade > 0) {
......@@ -106,14 +106,14 @@ class mod_vpl_grade_form extends moodleform {
$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 );
$mform->addElement('button','btnmerge', get_string( 'merge', VPL ),'onclick="' . $jscript . '"' );
$mform->addElement('button', 'btnmerge', get_string( 'merge', VPL ), 'onclick="' . $jscript . '"' );
//$mform->registerNoSubmitButton('btnmerge');
}
}
$mform->addElement('header','hGrade', get_string( 'grade') );
$mform->addElement('header', 'hGrade', get_string( 'grade') );
//$mform->addElement('html','<div id="vpl_grade_form">');
$buttonarray=array();
$buttonarray = array();
if ($grade != 0) {
if ($grade > 0) {
$buttonarray[] =& $mform->createElement('text', 'grade', '', 'size="6"' );
......@@ -123,7 +123,7 @@ class mod_vpl_grade_form extends moodleform {
}
}
$buttonarray[] =& $mform->createElement('submit', 'save', get_string( 'grade' ) );
if ($inpopup) {
if ($inpopup) {
$buttonarray[] =& $mform->createElement('submit', 'savenext', get_string( 'gradeandnext', VPL ) );
}
$buttonarray[] =& $mform->createElement('submit', 'removegrade', get_string( 'removegrade', VPL ) );
......@@ -147,7 +147,7 @@ class mod_vpl_grade_form extends moodleform {
}
$mform->addGroup($buttonarray, 'buttonar', get_string('grades'), array(' '), false);
//$mform->addElement('html', '</div>' );
$textarray=array();
$textarray = array();
if ($grade != 0) {
//$mform->addElement('html','</br><b>'.s( get_string( 'comments', VPL )).'</b></br>' );
//$textarray[] =& $mform->createElement('textarea', 'comments', get_string( 'comments', VPL ), 'rows="18" cols="70"' );
......
......@@ -96,7 +96,7 @@ if ($subinstance->dategraded == 0 || $subinstance->grader == $USER->id || $subin
} else {
$href = 'gradesubmission.php';
}
$gradeform = new mod_vpl_grade_form( $href, $vpl,$submission );
$gradeform = new mod_vpl_grade_form( $href, $vpl, $submission );
if ($gradeform->is_cancelled()) { // Grading canceled.
vpl_inmediate_redirect( $link );
} else if ($fromform = $gradeform->get_data()) { // Grade (new or update).
......@@ -127,15 +127,14 @@ if ($subinstance->dategraded == 0 || $subinstance->grader == $USER->id || $subin
vpl_redirect( $link, get_string( 'badinput' ), 'error' );
}
if ($submission->is_graded()) {
if ($submission->is_graded()) {
$action = 'update grade';
} else {
$action = 'grade';
}
$gradinginstance = $submission->get_grading_instance();
if ($gradinginstance) {
$advancedgrading = $gradinginstance->submit_and_get_grade($fromform->advancedgrading,
$submissionid);
$advancedgrading = $gradinginstance->submit_and_get_grade($fromform->advancedgrading, $submissionid);
}
if (! $submission->set_grade( $fromform )) {
vpl_redirect( $link, get_string( 'gradenotsaved', VPL ), 'error' );
......
......@@ -133,7 +133,7 @@ class mod_vpl_submission_form extends moodleform {
$PAGE->requires->js_call_amd('mod_vpl/submissionform', 'setup');
}
public function set_data($data) {
for($i=0; $i < $this->vpl->get_instance()->maxfiles; $i++) {
for ($i = 0; $i < $this->vpl->get_instance()->maxfiles; $i++) {
$data->{'file'.$i.'action'} = 'keep';
$data->{'archiveaction'} = 'replacedelete';
}
......
......@@ -12,7 +12,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/>.
/**
* JavaScript functions to help grade form
* @package mod_vpl
......@@ -20,9 +20,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Juan Carlos Rodríguez-del-Pino <jcrodriguez@dis.ulpgc.es>
*/
/* globals VPL: true */
(function() {
if (typeof VPL != 'object') {
VPL = {};
......@@ -38,7 +38,7 @@
};
// Resize comments view div to greatest visible size.
VPL.resizeSView = function() {
var grade_view = window.document.getElementById('vpl_grade_view');
var grade_view = window.document.getElementById('vpl_grade_view');
var comments_view = window.document.getElementById('vpl_grade_comments');
var textarea = window.document.getElementsByTagName('textarea')[0];
var form_view = window.document.getElementById('vpl_grade_form');
......@@ -61,9 +61,9 @@
submission_view.style.height = newHeight + 'px';
}
};
/* Set the resize controler */
VPL.resizeSView();
setInterval(VPL.resizeSView, 1000);
/**
......@@ -78,7 +78,7 @@
var match;
while ((match = regDiscount.exec(text)) !== null) {
var rest = parseFloat(match[1]);
if (rest < 0) {
if (rest < 0) {
grade += rest;
}
}
......@@ -90,8 +90,8 @@
grade = Math.round(100 * grade) / 100;
form1.grade.value = grade;
};
/**
/**
* Merge numeric grade from the proposed grade and advancedgrading
* end of lines. valid grade format: "- text (-grade)"
*/
......@@ -118,7 +118,7 @@
}else{
text = text.replace(/#Grid grade.*/,gridcomment);
}
fieldcomments.value = text;
/* Max two decimal points */
grade = Math.round(100 * grade) / 100;
......
......@@ -65,10 +65,10 @@ class vpl_diff {
// Due to PHP arrays architecture, the calculatediff function consumes a lot of memory.
// To reduce that memory consumption, we put information on the "prev" on the 29th and 30th bits of integers.
static private $PREVX = 2**29;
static private $PREVY = 2**30;
static private function trueValue($value) {
return $value & ~(self::$PREVX + self::$PREVY);
static private $prevx = 2 ** 29;
static private $prevy = 2 ** 30;
static private function truevalue($value) {
return $value & ~(self::$prevx + self::$prevy);
}
/**
......@@ -87,11 +87,11 @@ class vpl_diff {
$matrix[$i][$j] = 0;
}
// Set prev for first column.
$matrix[$i][0] = self::$PREVY;
$matrix[$i][0] = self::$prevy;
}
// Set prev for first row.
for ($j = 0; $j <= $nl2; $j ++) {
$matrix[0][$j] = self::$PREVX;
$matrix[0][$j] = self::$prevx;
}
}
......@@ -137,20 +137,20 @@ class vpl_diff {
for ($i = 1; $i <= $nl1; $i ++) {
$line = $lines1 [$i - 1];
for ($j = 1; $j <= $nl2; $j ++) {
if (self::trueValue($matrix[$i][$j - 1]) > self::trueValue($matrix[$i - 1][$j])) {
$max = self::trueValue($matrix[$i][$j - 1]);
$best = self::$PREVY;
if (self::truevalue($matrix[$i][$j - 1]) > self::truevalue($matrix[$i - 1][$j])) {
$max = self::truevalue($matrix[$i][$j - 1]);
$best = self::$prevy;
} else {
$max = self::trueValue($matrix[$i - 1][$j]);
$best = self::$PREVX;
$max = self::truevalue($matrix[$i - 1][$j]);
$best = self::$prevx;
}
if ($detaileddiff) {
$prize = self::diffline( $line, $lines2 [$j - 1] );
} else {
$prize = $line === $lines2 [$j - 1] ? 1 : 0;
}
if (self::trueValue($matrix[$i - 1][$j - 1]) + $prize >= $max) {
$max = self::trueValue($matrix[$i - 1][$j - 1]) + $prize;
if (self::truevalue($matrix[$i - 1][$j - 1]) + $prize >= $max) {
$max = self::truevalue($matrix[$i - 1][$j - 1]) + $prize;
$best = 0;
}
$matrix [$i] [$j] = $max + $best;
......@@ -167,9 +167,9 @@ class vpl_diff {
$pair->i = $pi;
$pair->j = $pj;
$pairs [] = $pair;
if (($matrix[$pi][$pj] & self::$PREVY) > 0) {
if (($matrix[$pi][$pj] & self::$prevy) > 0) {
$pj --;
} else if (($matrix[$pi][$pj] & self::$PREVX) > 0) {
} else if (($matrix[$pi][$pj] & self::$prevx) > 0) {
$pi --;
} else {
$pi --;
......
......@@ -34,7 +34,7 @@ class vpl_filetype {
'js' => 'c', // JavaScript as C.
'cc' => 'cpp',
'C' => 'cpp',
'mod' => 'c', //Opl as C
'mod' => 'c', // Opl as C.
'cpp' => 'cpp',
'cs' => 'cpp', // C# as C++.
'ads' => 'ada',
......
......@@ -722,7 +722,8 @@ class mod_vpl_submission {
$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 );
$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,
......@@ -743,7 +744,7 @@ class mod_vpl_submission {
}
}
if ($return) {
return $ret;
return $ret;
} else {
if ($ret) {
echo $OUTPUT->box( $ret );
......@@ -915,7 +916,7 @@ class mod_vpl_submission {
* @return string text with links
*/
public function add_filelink($text) {
// Format filename:linenumber.
// Format filename:linenumber.
$ret = '';
$list = $this->get_submitted_fgm()->getFileList();
usort( $list, 'vpl_compare_filenamebylengh' );
......@@ -956,7 +957,7 @@ class mod_vpl_submission {
$html .= '</b><br>';
$html .= $comment;
} else {
$div = new vpl_hide_show_div( false );
$div = new vpl_hide_show_div( false );
$html .= $div->generate( true );
$html .= '<b>';
$html .= s( $title );
......@@ -997,7 +998,7 @@ class mod_vpl_submission {
}
// Is title line.
if (strlen( $line ) > 1 && $line [0] == '-') { // Title.
$html .= $this->get_last_comment( $title, $comment, $dropdown );
$html .= $this->get_last_comment( $title, $comment, $dropdown );
$line = trim( substr( $line, 1 ) );
if ($line [strlen( $line ) - 1] == ')') { // Has grade?
$posopen = strrpos( $line, '(' );
......@@ -1038,10 +1039,9 @@ class mod_vpl_submission {
$comment .= '</a>';
}
$comment .= '<br>';
} else if (strlen( $line ) > 1 && $line [0] == '#') { // Teacher comment
$html .= $this->get_last_comment( $title, $comment, $dropdown );
}else{ // Regular text.
} 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>';
}
}
......@@ -1074,7 +1074,7 @@ class mod_vpl_submission {
* @return array of mensajes
*/
public function filter_feedback(&$list) {
$text = $this->get_grade_comments();
$text = $this->get_grade_comments();
$nl = vpl_detect_newline( $text );
$lines = explode( $nl, $text );
foreach ($lines as $line) {
......@@ -1159,7 +1159,7 @@ class mod_vpl_submission {
$ret ['executed'] = 1;
$ret ['execution'] = file_get_contents( $execfn );
} else {
$ret ['executed'] = 0;
$ret ['executed'] = 0;
}
$ret ['nevaluations'] = $this->instance->nevaluations;
$vplinstance = $this->vpl->get_instance();
......@@ -1277,7 +1277,7 @@ class mod_vpl_submission {
if (strlen( $compilation )) {
$params .= vpl_param_tag( 'compilation', $compilation );
}
if (strlen( $execution )) {
if (strlen( $execution )) {
$params .= vpl_param_tag( 'evaluation', $execution );
}
if (strlen( $grade )) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment