/**
  * Print core grade
  * @parm optional grade to show
  * @return string
  */
 function print_grade_core($grade = null)
 {
     $ret = '';
     $inst = $this->instance;
     if ($inst->dategraded > 0 || $grade != null) {
         $vplinstance = $this->vpl->get_instance();
         $scaleid = $this->vpl->get_grade();
         $options = array();
         if ($scaleid == 0) {
             $ret = get_string('nograde');
         }
         if ($scaleid > 0) {
             if ($grade == null) {
                 //remove trailing zeros if needed
                 $grade = vpl_rtzeros($inst->grade);
             }
             $ret = $grade . ' / ' . $scaleid;
         } elseif ($scaleid < 0) {
             $scaleid = -$scaleid;
             if ($grade === null) {
                 $grade = trim($inst->grade);
             }
             $grade = (int) $grade;
             if ($scale = $this->vpl->get_scale()) {
                 $options = array();
                 $options[-1] = get_string('nograde');
                 $options = $options + make_menu_from_list($scale->scale);
                 if (isset($options[$grade])) {
                     $ret = $options[$grade];
                 }
             }
         }
     }
     return $ret;
 }
 /**
  * Show vpl submission restriction
  **/
 function print_submission_restriction()
 {
     global $CFG, $USER;
     //TODO print_submission_restriction
     $filegroup = $this->get_required_fgm();
     $files = $filegroup->getFileList();
     if (count($files)) {
         $text = '';
         $need_comma = false;
         foreach ($files as $file) {
             if ($need_comma) {
                 $text .= ', ';
             }
             $text .= s($file);
             $need_comma = true;
         }
         $link = ' (<a href="';
         $link .= vpl_mod_href('views/downloadrequiredfiles.php', 'id', $this->get_course_module()->id);
         $link .= '">';
         $link .= get_string('download', VPL);
         $link .= '</a>)';
         $this->print_restriction('requestedfiles', $text . $link);
     }
     if (count($files) != $this->instance->maxfiles) {
         $this->print_restriction('maxfiles');
     }
     if ($this->instance->maxfilesize) {
         $mfs = $this->get_maxfilesize();
         $this->print_restriction('maxfilesize', vpl_conv_size_to_string($mfs));
     }
     $worktype = $this->instance->worktype;
     $values = array(0 => get_string('individualwork', VPL), 1 => get_string('groupwork', VPL));
     if ($worktype) {
         $this->print_restriction('worktype', $values[$worktype] . ' ' . $this->fullname($USER));
     } else {
         $this->print_restriction('worktype', $values[$worktype]);
     }
     if ($this->has_capability(VPL_GRADE_CAPABILITY)) {
         $str_yes = get_string('yes');
         $str_no = get_string('no');
         require_once $CFG->libdir . '/gradelib.php';
         if ($gie = $this->get_grade_info()) {
             if ($gie->scaleid == 0) {
                 $info = get_string('grademax', 'core_grades') . ': ' . vpl_rtzeros($gie->grademax);
                 $info .= $gie->hidden ? ' <b>' . get_string('hidden', 'core_grades') . '</b>' : '';
                 $info .= $gie->locked ? ' <b>' . get_string('locked', 'core_grades') . '</b>' : '';
             } else {
                 $info = get_string('typescale', 'core_grades');
             }
             $this->print_restriction(get_String('gradessettings', 'core_grades'), $info, true);
         } else {
             $this->print_restriction(get_String('gradessettings', 'core_grades'), get_string('nograde'), true);
         }
         if (trim($this->instance->password) > '') {
             $this->print_restriction(get_string('password'), $str_yes, true);
         }
         if (trim($this->instance->requirednet) > '') {
             $this->print_restriction('requirednet', s($this->instance->requirednet));
         }
         if ($this->instance->restrictededitor) {
             $this->print_restriction('restrictededitor', $str_yes);
         }
         if ($this->instance->example) {
             $this->print_restriction('isexample', $str_yes);
         }
         if (!$this->get_course_module()->visible) {
             $this->print_restriction(get_string('visible'), $str_no, true);
         }
         if ($this->instance->basedon) {
             $basedon = new mod_vpl(null, $this->instance->basedon);
             $link = '<a href="';
             $link .= vpl_mod_href('view.php', 'id', $basedon->cm->id);
             $link .= '">';
             $link .= $basedon->get_printable_name();
             $link .= '</a>';
             $this->print_restriction('basedon', $link);
         }
         $noyes = array($str_no, $str_yes);
         $this->print_restriction('run', $noyes[$this->instance->run], false, false);
         if ($this->instance->debug) {
             $this->print_restriction('debug', $noyes[1], false, false);
         }
         $this->print_restriction('evaluate', $noyes[$this->instance->evaluate], false, !($this->instance->evaluate && $this->instance->evaluateonsubmission));
         if ($this->instance->evaluate && $this->instance->evaluateonsubmission) {
             $this->print_restriction('evaluateonsubmission', $noyes[1]);
         }
         if ($this->instance->automaticgrading) {
             $this->print_restriction('automaticgrading', $noyes[1], false, false);
         }
         if ($this->instance->maxexetime) {
             $this->print_restriction('maxexetime', $this->instance->maxexetime . ' s', false, false);
         }
         if ($this->instance->maxexememory) {
             $this->print_restriction('maxexememory', vpl_conv_size_to_string($this->instance->maxexememory), false, false);
         }
         if ($this->instance->maxexefilesize) {
             $this->print_restriction('maxexefilesize', vpl_conv_size_to_string($this->instance->maxexefilesize), false, false);
         }
         if ($this->instance->maxexeprocesses) {
             $this->print_restriction('maxexeprocesses', null, false, false);
         }
     }
 }