示例#1
0
 public static function get_submitted_files($vpl, $userid, &$CE)
 {
     $CE = false;
     $lastsub = $vpl->last_user_submission($userid);
     if ($lastsub) {
         $submission = new mod_vpl_submission($vpl, $lastsub);
         $fgp = $submission->get_submitted_fgm();
         $filelist = $fgp->getFileList();
         $nf = count($filelist);
         for ($i = 0; $i < $nf; $i++) {
             $filename = $filelist[$i];
             $filedata = $fgp->getFileData($filelist[$i]);
             $files[$filename] = $filedata;
         }
         $CE = $submission->get_CE_for_editor();
     } else {
         $files = self::get_requested_files($vpl);
     }
     return $files;
 }
$vpl->print_view_tabs(basename(__FILE__));
$table = new html_table();
$table->head = array('#', $strdatesubmitted, $strdescription);
$table->align = array('right', 'left', 'right');
$table->nowrap = array(true, true, true);
$submissionslist = $vpl->user_submissions($userid);
$submissions = array();
$nsub = count($submissionslist);
foreach ($submissionslist as $submission) {
    if ($detailed) {
        $link = '#f' . $nsub;
    } else {
        $link = vpl_mod_href('forms/submissionview.php', 'id', $id, 'userid', $userid, 'submissionid', $submission->id);
    }
    $date = '<a href="' . $link . '">' . userdate($submission->datesubmitted) . '</a>';
    $sub = new mod_vpl_submission($vpl, $submission);
    $submissions[] = $sub;
    $table->data[] = array($nsub--, $date, s($sub->get_detail()));
}
echo '<div class="clearer"> </div>';
echo '<div style="text-align: center">';
echo '<img src="' . vpl_rel_url('submissionsgraph.php', 'id', $id, 'userid', $userid) . '" alt="files size evolution" />';
echo '</div>';
echo '<div class="clearer"> </div>';
echo '<div class="clearer"> </div>';
echo '<div style="text-align: center">';
echo '<img src="' . vpl_rel_url('workinggraph.php', 'id', $id, 'userid', $userid) . '" alt="workingperiods" />';
echo '</div>';
echo '<div class="clearer"> </div>';
echo html_writer::table($table);
echo '<div style="text-align:center">';
示例#3
0
function vpl_user_complete($course, $user, $mod, $vpl)
{
    require_once 'vpl_submission.class.php';
    //TODO Print a detailed report of what a user has done with a given particular instance
    //Search submisions for $user $instance
    $vpl = new mod_vpl(null, $vpl->id);
    $sub = $vpl->last_user_submission($user->id);
    if (!$sub) {
        $return = null;
    } else {
        $submission = new mod_vpl_submission($vpl, $sub);
        $submission->print_info(true);
        $submission->print_grade(true);
    }
    return true;
}
        $grader = FALSE;
        if ($submissionid && $vpl->has_capability(VPL_GRADE_CAPABILITY)) {
            $subinstance = $DB->get_record('vpl_submissions', array('id' => $submissionid));
        } else {
            $subinstance = $vpl->last_user_submission($userid);
        }
        $vpl->password_check();
    }
    //Check consistence
    if (!$subinstance) {
        throw new Exception(get_string('nosubmission', VPL));
    }
    if ($subinstance->vpl != $vpl->get_instance()->id) {
        throw new Exception(get_string('invalidcourseid'));
    }
    $submissionid = $subinstance->id;
    if ($vpl->is_inconsistent_user($subinstance->userid, $userid)) {
        throw new Exception('vpl submission user inconsistence');
    }
    if ($vpl->get_instance()->id != $subinstance->vpl) {
        throw new Exception('vpl submission vpl inconsistence');
    }
    $submission = new mod_vpl_submission($vpl, $subinstance);
    $fgm = $submission->get_submitted_fgm();
    $fgm->download_files($vpl->get_printable_name());
} catch (Exception $e) {
    $vpl->prepare_page('views/downloadsubmission.php', array('id' => $id));
    $vpl->print_header(get_string('download', VPL));
    echo $OUTPUT->box($e->getMessage());
    $vpl->print_footer();
}
示例#5
0
    //Print header
    $PAGE->requires->css(new moodle_url('/mod/vpl/css/sh.css'));
    $PAGE->requires->css(new moodle_url('/mod/vpl/editor/VPLIDE.css'));
    $vpl->print_header(get_string('submissionview', VPL));
    $vpl->print_view_tabs(basename(__FILE__));
    //Display submission
    //Check consistence
    if (!$subinstance) {
        notice(get_string('nosubmission', VPL), vpl_mod_href('view.php', 'id', $id, 'userid', $userid));
    }
    $submissionid = $subinstance->id;
    if ($vpl->is_inconsistent_user($subinstance->userid, $userid)) {
        print_error('vpl submission user inconsistence');
    }
    if ($vpl->get_instance()->id != $subinstance->vpl) {
        print_error('vpl submission vpl inconsistence');
    }
    $submission = new mod_vpl_submission($vpl, $subinstance);
    if ($vpl->get_visiblegrade() || $vpl->has_capability(VPL_GRADE_CAPABILITY)) {
        if ($submission->is_graded()) {
            echo '<h2>' . get_string('grade') . '</h2>';
            $submission->print_grade(true);
        }
    }
    $vpl->print_variation($subinstance->userid);
    $submission->print_submission();
    $vpl->print_footer();
    \mod_vpl\event\submission_viewed::log($submission);
} catch (Exception $e) {
    print_r($e);
}
示例#6
0
//Get files
$files = array();
$req_fgm = $vpl->get_required_fgm();
$options['resetfiles'] = $req_fgm->is_populated() && !$instance->example;
$options['maxfiles'] = $instance->maxfiles;
$req_filelist = $req_fgm->getFileList();
$min = count($req_filelist);
$options['minfiles'] = $min;
$nf = count($req_filelist);
for ($i = 0; $i < $nf; $i++) {
    $filename = $req_filelist[$i];
    $filedata = $req_fgm->getFileData($req_filelist[$i]);
    $files[$filename] = $filedata;
}
if ($lastsub) {
    $submission = new mod_vpl_submission($vpl, $lastsub);
    $fgp = $submission->get_submitted_fgm();
    $filelist = $fgp->getFileList();
    $nf = count($filelist);
    for ($i = 0; $i < $nf; $i++) {
        $filename = $filelist[$i];
        $filedata = $fgp->getFileData($filelist[$i]);
        $files[$filename] = $filedata;
    }
    $CE = $submission->get_CE_for_editor();
    \mod_vpl\event\submission_edited::log($submission);
}
session_write_close();
if ($copy && $grader) {
    $userid = $USER->id;
}
示例#7
0
 /**
  * Delete overflow submissions.
  * If three submissions within the period central is delete
  * @param $userid
  * @return void
  **/
 function delete_overflow_submissions($userid)
 {
     global $CFG, $DB;
     $plugincfg = get_config('mod_vpl');
     if (!isset($plugincfg->discard_submission_period)) {
         return;
     }
     if ($plugincfg->discard_submission_period == 0) {
         //Keep all submissions
         return;
     }
     if ($plugincfg->discard_submission_period > 0) {
         $select = "(userid = ?) AND (vpl = ?)";
         $params = array($userid, $this->instance->id);
         $res = $DB->get_records_select(VPL_SUBMISSIONS, $select, $params, 'id DESC', '*', 0, 3);
         if (count($res) == 3) {
             $i = 0;
             foreach ($res as $sub) {
                 switch ($i) {
                     case 0:
                         $last = $sub;
                         break;
                     case 1:
                         $second = $sub;
                         break;
                     case 2:
                         $first = $sub;
                         break;
                 }
                 $i++;
             }
             //Check time consistence
             if (!($last->datesubmitted > $second->datesubmitted && $second->datesubmitted > $first->datesubmitted)) {
                 return;
             }
             if ($last->datesubmitted - $first->datesubmitted < $plugincfg->discard_submission_period) {
                 //Remove second submission
                 $submission = new mod_vpl_submission($this, $second);
                 $submission->delete();
             }
         }
     }
 }
示例#8
0
 static function vpl_get_similfile($f, $vpl, &$HTMLheader, &$filename, &$data)
 {
     global $DB;
     $HTMLheader = '';
     $filename = '';
     $data = '';
     $type = required_param('type' . $f, PARAM_INT);
     if ($type == 1) {
         $subid = required_param('subid' . $f, PARAM_INT);
         $filename = required_param('filename' . $f, PARAM_TEXT);
         $subinstance = $DB->get_record('vpl_submissions', array('id' => $subid));
         if ($subinstance !== false) {
             $vpl = new mod_vpl(false, $subinstance->vpl);
             $vpl->require_capability(VPL_SIMILARITY_CAPABILITY);
             $submission = new mod_vpl_submission($vpl, $subinstance);
             $user = $DB->get_record('user', array('id' => $subinstance->userid));
             if ($user) {
                 $HTMLheader .= '<a href="' . vpl_mod_href('/forms/submissionview.php', 'id', $vpl->get_course_module()->id, 'userid', $subinstance->userid) . '">';
             }
             $HTMLheader .= s($filename) . ' ';
             if ($user) {
                 $HTMLheader .= '</a>';
                 $HTMLheader .= $vpl->user_fullname_picture($user);
             }
             $fg = $submission->get_submitted_fgm();
             $data = $fg->getFileData($filename);
             \mod_vpl\event\vpl_diff_viewed::log($submission);
         }
     } elseif ($type == 2) {
         //FIXME adapt to moodle 2.x
         /*
         global $CFG;
         $dirname = required_param('dirname'.$f,PARAM_RAW);
         $filename = required_param('filename'.$f,PARAM_RAW);
         $base=$CFG->dataroot.'/'.$vpl->get_course()->id.'/';
         $data = file_get_contents($base.$dirname.'/'.$filename);
         $HTMLheader .= $filename.' '.optional_param('username'.$f,'',PARAM_TEXT);
         */
     } elseif ($type == 3) {
         global $CFG;
         $data = '';
         $zipname = required_param('zipfile' . $f, PARAM_RAW);
         $filename = required_param('filename' . $f, PARAM_RAW);
         $HTMLheader .= $filename . ' ' . optional_param('username' . $f, '', PARAM_TEXT);
         $ext = strtoupper(pathinfo($zipfile, PATHINFO_EXTENSION));
         if ($ext != 'ZIP') {
             print_error('nozipfile');
         }
         $zip = new ZipArchive();
         $zipfilename = self::get_zip_filepath($zipname);
         if ($zip->open($zipfilename)) {
             $data = $zip->getFromName($filename);
             $zip->close();
         }
     } else {
         print_error('type error');
     }
 }
示例#9
0
}
//Check consistence
if (!$subinstance) {
    vpl_grade_header($vpl, $inpopup);
    notice(get_string('nosubmission', VPL), vpl_mod_href('view.php', 'id', $id, 'userid', $userid));
}
$submissionid = $subinstance->id;
if ($vpl->is_inconsistent_user($subinstance->userid, $userid)) {
    vpl_grade_header($vpl, $inpopup);
    print_error('vpl submission user inconsistence');
}
if ($vpl->get_instance()->id != $subinstance->vpl) {
    vpl_grade_header($vpl, $inpopup);
    print_error('vpl submission vpl inconsistence');
}
$submission = new mod_vpl_submission($vpl, $subinstance);
if ($inpopup) {
    $link = vpl_mod_href('forms/gradesubmission.php', 'id', $id, 'userid', $userid, 'inpopup', $inpopup);
} else {
    $link = vpl_mod_href('forms/gradesubmission.php', 'id', $id, 'userid', $userid);
}
$linkrel = vpl_rel_url('forms/gradesubmission.php', 'id', $id, 'userid', $userid);
//no marked or marked by current user or automatic
if ($subinstance->dategraded == 0 || $subinstance->grader == $USER->id || $subinstance->grader == 0) {
    if ($inpopup) {
        $href = $link;
        //vpl_rel_url('gradesubmission.php','inpopup',1);
    } else {
        $href = 'gradesubmission.php';
    }
    $grade_form = new mod_vpl_grade_form($href, $vpl);
 /**
  * Constructor
  * @param $vpl object vpl instance
  * @param $instance vpl submission
  **/
 function __construct($vpl, $mix)
 {
     parent::__construct($vpl, $mix);
 }
示例#11
0
                               // echo '<a href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
                            //format_string($instance->name,true)."</a>';

                                ob_start();

                                echo "<ul>";
                                if (function_exists($user_complete)) {
                                    //$user_complete($course, $user, $mod, $instance);
                                    if($mod->modname=='vpl'){
                                        $vpl = new mod_vpl(null,$instance->id);
                                        $sub = $vpl->last_user_submission($user->id);
                                        if(!$sub) {
                                            $return = null;
                                        }
                                        else{
                                            $submission = new mod_vpl_submission($vpl,$sub);
                                            $submission->student_print_info(true);
                                            $submission->print_grade(true);
                                        }
                                    }
                                    else{
                                        $user_complete($course, $user, $mod, $instance);
                                    }
                                } else {
                                    //echo 'modname='.$mod->modname;
                                    echo report_outline_user_complete($user->id, $cmid, $mod->modname, $instance->id);
                                }
                                echo "</ul>";

                                $output = ob_get_contents();
                                ob_end_clean();
 /**
  * scan_activity load activity files into $simil array
  * @param $simil array of file processed objects
  * @param $vpl activity to process
  * @param $filesselected array if set only files selected or unselected will be processed
  * @param $SPB Box used to show load process
  * @param $selected boolean switch to get selected or no selected files (default true)
  * @return void
  */
 public static function scan_activity(&$simil, $vpl, $filesselected = array(), $SPB, $selected = true)
 {
     global $CFG;
     $vpl->require_capability(VPL_SIMILARITY_CAPABILITY);
     $list = $vpl->get_students();
     if (count($list) == 0) {
         return;
     }
     $submissions = $vpl->all_last_user_submission();
     $SPB->set_max(count($list));
     //debugging("Submissions ".count($submissions), DEBUG_DEVELOPER);
     $i = 0;
     foreach ($list as $user) {
         $i++;
         $SPB->set_value($i);
         if (isset($submissions[$user->id])) {
             $subinstance = $submissions[$user->id];
             $origin = '';
             $submission = new mod_vpl_submission($vpl, $subinstance);
             $subf = $submission->get_submitted_fgm();
             $filelist = $subf->getFileList();
             foreach ($filelist as $filename) {
                 //debugging("Filename ".$filename, DEBUG_DEVELOPER);
                 if ($selected) {
                     if (count($filesselected) > 0 && !isset($filesselected[$filename])) {
                         continue;
                     }
                 } else {
                     if (isset($filesselected[$filename])) {
                         continue;
                     }
                 }
                 //debugging("Added ".$filename, DEBUG_DEVELOPER);
                 $sim = vpl_similarity_factory::get($filename);
                 if ($sim) {
                     $data = $subf->getFileData($filename);
                     $from = new vpl_file_from_activity($filename, $vpl, $subinstance);
                     $sim->init($data, $from);
                     if ($sim->size > 10) {
                         $simil[] = $sim;
                     }
                 }
             }
         }
     }
 }
示例#13
0
                 $row[] = '-';
             } else {
                 $row[] = $info['graded'];
             }
         }
     } else {
         $row[] = '';
         $row[] = '';
     }
 }
 if ($student) {
     if (!$vpl->has_capability(VPL_GRADE_CAPABILITY) && $vpl->has_capability(VPL_SUBMIT_CAPABILITY) && $vpl->get_grade() != 0 && !$instance->example) {
         $subinstance = $vpl->last_user_submission($USER->id);
         if ($subinstance) {
             //Submitted
             $submission = new mod_vpl_submission($vpl, $subinstance);
             if ($subinstance->dategraded > 0 && $vpl->get_visiblegrade()) {
                 $text = $submission->print_grade_core();
             } else {
                 $result = $submission->getCE();
                 $text = '';
                 if ($result['executed'] !== 0) {
                     $prograde = $submission->proposedGrade($result['execution']);
                     if ($prograde > '') {
                         $text = get_string('proposedgrade', VPL, $submission->print_grade_core($prograde));
                     }
                 } else {
                     $text = get_string('nograde');
                 }
             }
         } else {
示例#14
0
if (count($ngrades)) {
    if ($CFG->fullnamedisplay == 'lastname firstname') {
        // for better view (dlnsk)
        $namehead = get_string('lastname') . ' / ' . get_string('firstname');
    } else {
        $namehead = get_string('firstname') . ' / ' . get_string('lastname');
    }
    $tablegraders = new html_table();
    $tablegraders->head = array('#', $namehead, get_string('grade'));
    $tablegraders->align = array('right', 'left', 'center');
    $tablegraders->wrap = array('nowrap', 'nowrap', 'nowrap');
    $tablegraders->data = array();
    $gradernumber = 0;
    foreach ($ngrades as $graderid => $marks) {
        $gradernumber++;
        $grader = mod_vpl_submission::get_grader($graderid);
        $picture = '';
        if ($graderid > 0) {
            //No automatic grading
            $picture = $OUTPUT->user_picture($grader, array('popup' => true));
        }
        $tablegraders->data[] = array($gradernumber, $picture . ' ' . fullname($grader), sprintf('%d/%d  (%5.2f%%)', $marks, $usernumber, (double) 100.0 * $marks / $usernumber));
    }
}
//Menu for groups
if ($groupmode) {
    groups_print_activity_menu($cm, $groups_url);
}
//Print user selection by submission state
$url_base = $CFG->wwwroot . "/mod/vpl/views/submissionslist.php?id={$id}&sort={$sort}&group={$group}&selection=";
$urlindex = vpl_select_index($url_base, array('all', 'allsubmissions', 'notgraded', 'graded', 'gradedbyuser'));
    $table = new html_table();
    $table->head  = array ('#',$strdatesubmitted, $strdescription);
    $table->align = array ('right','left', 'right');
    $table->nowrap = array (true,true,true);
    $submissionslist = $vpl->user_submissions($userid);
    $submissions = array();
    $nsub = count($submissionslist);
    foreach ($submissionslist as $submission) {
        if($detailed){
            $link = '#f'.$nsub;
        }else{
            $link =$CFG->wwwroot.'/teacher/studentsubmissionview.php?id='.$id.'&userid='.$userid.'&submissionid='.$submission->id;

        }
        $date = '<a href="'.$link.'">'.userdate($submission->datesubmitted).'</a>';
        $sub = new mod_vpl_submission($vpl,$submission);
        $submissions[] = $sub;
        $table->data[] = array ($nsub--,
            $date,
            s($sub->get_detail()));
    }

    echo '<div class="clearer"> </div>';
    echo html_writer::table($table);
    echo '<div style="text-align:center">';
    $url_base=$CFG->wwwroot.'/teacher/studentsubmissionview.php?id='.$id.'&userid='.$userid.'&detailed=';
    $urls= array($url_base.'0',$url_base.'1');
    echo '</div>';