2222 </div >
2323 <div class =" directory-tree" v-if =" showDirectoryTree" >
2424 <div
25- v-for =" dir in directories "
25+ v-for =" dir in visibleDirectories "
2626 :key =" dir.path"
2727 class =" directory-item"
2828 :class =" {
@@ -137,6 +137,12 @@ export default {
137137 if (! this .fileName ) return ' ' ;
138138 const lastDot = this .fileName .lastIndexOf (' .' );
139139 return lastDot > 0 ? this .fileName .substring (lastDot) : ' ' ;
140+ },
141+ visibleDirectories () {
142+ return this .directories .filter (dir => {
143+ // Apply student visibility filtering
144+ return this .isDirectoryVisibleToStudent (dir .path );
145+ });
140146 }
141147 },
142148 components: {
@@ -160,11 +166,11 @@ export default {
160166 if (! this .currentUser || this .currentUser .role !== ' student' ) {
161167 return true ; // Show all directories to professors and when not logged in
162168 }
163-
164- const userPath = ` Local/${ this . currentUser . username } ` ;
165-
166- // Show only the student's own Local/{username}/ directory and its subdirectories
167- return path === ' / ' || path . startsWith (userPath) ;
169+
170+ // For students, since they have their own isolated project ( Local/username),
171+ // all directories within their project should be visible to them.
172+ // The project-level filtering already ensures they only see their own project.
173+ return true ;
168174 },
169175
170176 loadDirectoryStructure () {
@@ -173,10 +179,12 @@ export default {
173179 // Build directory tree from all projects
174180 this .directories = [];
175181 this .ideInfo .multiRootData .children .forEach (project => {
176- // For students, only show the Local project (where they can create files )
182+ // For students, only show projects that start with "Local" (student's own directory )
177183 if (this .currentUser && this .currentUser .role === ' student' ) {
178- if (project .label !== ' Local' ) {
179- return ; // Skip non-Local projects for students
184+ // For students, the project is named "Local/username" not just "Local"
185+ const expectedProjectPrefix = ` Local/${ this .currentUser .username } ` ;
186+ if (! project .label .startsWith (' Local/' ) || project .label !== expectedProjectPrefix) {
187+ return ; // Skip projects that aren't the student's own Local directory
180188 }
181189 }
182190
@@ -188,10 +196,11 @@ export default {
188196 // Fallback to single project mode
189197 const projectLabel = this .ideInfo .currProj .data .label || this .ideInfo .currProj .data .name ;
190198
191- // For students, only process if it's the Local project
199+ // For students, only process if it's their own Local project
192200 if (this .currentUser && this .currentUser .role === ' student' ) {
193- if (projectLabel !== ' Local' ) {
194- this .directories = []; // Don't show any directories for non-Local projects
201+ const expectedProjectName = ` Local/${ this .currentUser .username } ` ;
202+ if (projectLabel !== expectedProjectName) {
203+ this .directories = []; // Don't show any directories for non-student projects
195204 return ;
196205 }
197206 }
@@ -201,8 +210,8 @@ export default {
201210
202211 // For students, always force default to Local project and their Local directory
203212 if (this .currentUser && this .currentUser .role === ' student' ) {
204- // Always default students to the Local project
205- this .currentProject = ' Local' ;
213+ // Always default students to the Local project (which is named Local/{username})
214+ this .currentProject = ` Local/ ${ this . currentUser . username } ` ;
206215
207216 // Always default to their user directory, regardless of current selection
208217 const userPath = ` Local/${ this .currentUser .username } ` ;
@@ -211,8 +220,18 @@ export default {
211220 if (userDir) {
212221 this .currentPath = userPath;
213222 } else {
214- // Fallback to Local root if user directory not found
215- this .currentPath = ' /' ;
223+ // For students, since their "Local" project maps to their personal directory,
224+ // default to the root of the Local project, which should display as "Local/{username}"
225+ // We need to find the first available directory or use the project root
226+ if (this .directories .length > 0 ) {
227+ // Use the first directory that's not a root-level project
228+ const expectedProjectName = ` Local/${ this .currentUser .username } ` ;
229+ const firstDir = this .directories .find (dir => ! dir .isRoot && dir .projectName === expectedProjectName);
230+ this .currentPath = firstDir ? firstDir .path : ' /' ;
231+ } else {
232+ // If no directories are found, use root which will display as the project name
233+ this .currentPath = ' /' ;
234+ }
216235 }
217236 } else {
218237 // For professors, set current path to selected node if it's a directory
@@ -296,6 +315,10 @@ export default {
296315
297316 if (this .currentProject ) {
298317 if (path === ' /' ) {
318+ // Special case for students: when they're in Local project root, show their username
319+ if (this .currentUser && this .currentUser .role === ' student' && this .currentProject === ' Local' ) {
320+ return ` Local/${ this .currentUser .username } ` ;
321+ }
299322 return this .currentProject ;
300323 }
301324 // Only add project name if path doesn't already contain it
@@ -429,10 +452,27 @@ export default {
429452 },
430453 async onCreate () {
431454 if (! this .fileName || this .fileNameError ) return ;
432-
455+
433456 const fileName = this .fileName ;
434- const parentPath = this .currentPath ;
435- const projectName = this .currentProject || this .ideInfo .currProj ? .data ? .name || this .ideInfo .currProj ? .config ? .name ;
457+ let parentPath = this .currentPath ;
458+ let projectName = this .currentProject || this .ideInfo .currProj ? .data ? .name || this .ideInfo .currProj ? .config ? .name ;
459+
460+ // Special handling for students: translate Local project paths to actual student directory
461+ if (this .currentUser && this .currentUser .role === ' student' && projectName === ' Local' ) {
462+ // For students, when they're in the "Local" project, we need to send the actual student path
463+ if (parentPath === ' /' || parentPath === ` Local/${ this .currentUser .username } ` ) {
464+ // Student is at their root directory, send the actual path
465+ parentPath = ` Local/${ this .currentUser .username } ` ;
466+ projectName = ' ' ; // Clear project name since we're sending the full path
467+ } else if (parentPath .startsWith (` Local/${ this .currentUser .username } /` )) {
468+ // Student is in a subdirectory, path is already correct
469+ projectName = ' ' ; // Clear project name since we're sending the full path
470+ } else {
471+ // Fallback: ensure student path is correct
472+ parentPath = ` Local/${ this .currentUser .username }${ parentPath === ' /' ? ' ' : parentPath} ` ;
473+ projectName = ' ' ; // Clear project name since we're sending the full path
474+ }
475+ }
436476
437477 // Check if file already exists
438478 const existingFile = this .checkFileExists (fileName, parentPath, projectName);
0 commit comments