/**
  * Get compilation, execution and proposed grade from array
  * @param $response array response from server
  * @param $compilation
  * @param $execution
  * @param $grade
  * @return void
  */
 function get_CE_HTML($response, &$compilation, &$execution, &$grade, $dropdown, $returnrawexecution = false)
 {
     $compilation = '';
     $execution = '';
     $grade = '';
     if ($response['compilation']) {
         $compilation = $this->result_to_HTML($response['compilation'], $dropdown);
         if (strlen($compilation)) {
             $compilation = '<b>' . get_string('compilation', VPL) . '</b><br />' . $compilation;
         }
     }
     if ($response['executed'] > 0) {
         $raw_execution = $response['execution'];
         $proposed_comments = $this->proposedComment($raw_execution);
         $proposed_grade = $this->proposedGrade($raw_execution);
         $execution = $this->result_to_HTML($proposed_comments, $dropdown);
         if (strlen($execution)) {
             $execution = '<b>' . get_string('comments', VPL) . "</b><br />\n" . $execution;
         }
         if (strlen($proposed_grade)) {
             $sgrade = $this->print_grade_core($proposed_grade);
             $grade = get_string('proposedgrade', VPL, $sgrade);
         }
         //Show raw ejecution if no grade or comments
         if (strlen($raw_execution) > 0 && strlen($execution) + strlen($proposed_grade) == 0) {
             $execution .= "<br />\n";
             $execution .= '<b>' . get_string('execution', VPL) . "</b><br />\n";
             $execution .= '<pre>' . s($raw_execution) . '</pre>';
         } elseif ($returnrawexecution && strlen($raw_execution) > 0 && $this->vpl->has_capability(VPL_MANAGE_CAPABILITY)) {
             $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($raw_execution) . '</pre>';
             $execution .= $div->end_div(true);
         }
     }
 }
Esempio n. 2
0
 /**
  * Print variations in vpl instance
  **/
 function print_variations()
 {
     global $OUTPUT;
     global $DB;
     require_once dirname(__FILE__) . '/views/show_hide_div.class.php';
     $variations = $DB->get_records(VPL_VARIATIONS, array('vpl' => $this->instance->id));
     if (count($variations) > 0) {
         $div = new vpl_hide_show_div();
         echo '<br /><b>' . get_string('variations', VPL) . $div->generate(true) . '</b><br />';
         $div->begin_div();
         if (!$this->instance->usevariations) {
             echo '<b>' . get_string('variations_unused', VPL) . '</b><br />';
         }
         if ($this->instance->variationtitle) {
             echo '<b>' . get_string('variationtitle', VPL) . ': ' . s($this->instance->variationtitle) . '</b><br />';
         }
         $number = 1;
         foreach ($variations as $variation) {
             echo '<b>' . get_string('variation', VPL, $number) . '</b><br />';
             echo $OUTPUT->box($variation->description);
             $number++;
         }
         $div->end_div();
     }
 }