diff --git a/forms/edit.php b/forms/edit.php
index 35b957826dc625a7884192a59061043509893f99..ac239a9805cc4324ad3e3ed25864a527bfccdc60 100644
--- a/forms/edit.php
+++ b/forms/edit.php
@@ -33,6 +33,7 @@ $id = required_param('id', PARAM_INT);
 $userid = optional_param('userid', false, PARAM_INT);
 $copy = optional_param('privatecopy', false, PARAM_INT);
 $subid = optional_param( 'submissionid', false, PARAM_INT );
+global $USER, $DB, $OUTPUT;
 $vpl = new mod_vpl($id);
 $pageparms = array('id' => $id);
 if ($userid && ! $copy) {
@@ -86,8 +87,8 @@ $options ['evaluate'] = ($instance->evaluate || $manager);
 $options ['example'] = true && $instance->example;
 $options ['comments'] = ! $options ['example'];
 $options ['description'] = $vpl->get_fulldescription_with_basedon();
-$options ['username'] = $vpl->fullname($DB->get_record( 'user', array ( 'id' => $userid ) ), false);
 $linkuserid = $copy ? $USER->id : $userid;
+$options ['username'] = $vpl->fullname($DB->get_record( 'user', array ( 'id' => $linkuserid ) ), false);
 $ajaxurl = "edit.json.php?id={$id}&userid={$linkuserid}";
 if ( $subid && $lastsub ) {
     $ajaxurl .= "&subid={$lastsub->id}";
@@ -112,8 +113,8 @@ if ( $subid ) {
 
 $reqfgm = $vpl->get_fgm('required');
 $options ['resetfiles'] = ($reqfgm->is_populated() && ! $instance->example);
-$corfgm = $vpl->get_fgm('corrected'); 
-$options ['correctedfiles'] = ($corfgm->is_populated() && ! $instance->example && $manager && user_has_role_assignment($USER->id,3)); 
+$corfgm = $vpl->get_fgm('corrected');
+$options ['correctedfiles'] = ($corfgm->is_populated() && ! $instance->example && $manager && user_has_role_assignment($USER->id,3));
 $options ['maxfiles'] = intval($instance->maxfiles);
 $reqfilelist = $reqfgm->getFileList();
 $options ['minfiles'] = count( $reqfilelist );