Skip to main content

Overview

The routes/web.php file defines all HTTP routes for the Wecode application. Routes are organized by resource and functionality, with most routes requiring authentication.

Root & Home

MethodURINameController@MethodDescription
GET/-ClosureRedirects to home route
GET/home/homehome_controller@indexUser dashboard/home page
Example:
Route::get('/', function () {
    return redirect(route('home'));
});

Route::get('/home/', [home_controller::class, 'index'])->name('home');

Authentication Routes

See Authentication Routes for detailed authentication documentation.
Auth::routes();
This registers:
  • Login (GET/POST /login)
  • Logout (POST /logout)
  • Register (GET/POST /register)
  • Password Reset (GET/POST /password/reset, /password/email)

HTML Editor

MethodURINameController@MethodMiddleware
GET/htmleditorhtmleditorhtml_editor_controller@indexauth
POST/htmleditor/autosavehtmleditor.autosavehtml_editor_controller@autosaveauth

MOSS (Plagiarism Detection)

MethodURINameController@MethodAccess
GET/moss/{id?}moss.indexmoss_controller@indexadmin, head_instructor
POST/moss/{id}moss.updatemoss_controller@updateadmin, head_instructor
POST/moss/detect/{id}moss.detectmoss_controller@detectadmin, head_instructor
id
integer
Assignment ID for MOSS analysis

Classes (Lops)

MethodURINameController@Method
GET/lopslops.indexlop_controller@index
GET/lops/createlops.createlop_controller@create
POST/lopslops.storelop_controller@store
GET/lops/{lop}lops.showlop_controller@show
GET/lops/{lop}/editlops.editlop_controller@edit
PUT/PATCH/lops/{lop}lops.updatelop_controller@update
DELETE/lops/{lop}lops.destroylop_controller@destroy
POST/lops/{lop}/enrol/{in}lops.enrollop_controller@enrol
GET/lop/scoreboard/{lop}lop.scoreboardlop_controller@scoreboard
lop
integer
Class (lop) ID
in
integer
Enrollment action parameter

Settings

MethodURINameController@MethodAccess
GET/settingssettings.indexsetting_controller@indexadmin
POST/settingssettings.updatesetting_controller@updateadmin

Users

Custom User Routes

MethodURINameController@MethodAccess
GET/users/add_multiple-UserController@add_multipleadmin, head_instructor
POST/users/addsusers.addUserController@addadmin, head_instructor
POST/users/delete_submissions/{user}users.delete_submissionsUserController@delete_submissionsadmin
DELETE/users/{id}users.destroyUserController@destroyadmin
GET/users/rankingusers.rankUserController@rankall authenticated
GET/users/set_trialusers.set_trialView onlyauth
POST/users/set_trialusers.set_trial_postUserController@set_trialauth

Resource Routes

MethodURINameController@Method
GET/usersusers.indexUserController@index
GET/users/createusers.createUserController@create
POST/usersusers.storeUserController@store
GET/users/{user}users.showUserController@show
GET/users/{user}/editusers.editUserController@edit
PUT/PATCH/users/{user}users.updateUserController@update
user
integer
User ID

Problems

Custom Problem Routes

MethodURINameController@MethodAccess
GET/problems/downloadtestsdesc/{id}problems.downloadtestsdescproblem_controller@downloadtestsdescauth
GET/problems/downloadtestcases/{problem}/{assignment}/{type}problems.download_testcasesproblem_controller@download_testcasesauth
GET/problems/exportproblems.exportproblem_controller@exportauth
POST/problems/importproblems.importproblem_controller@importadmin, head_instructor
POST/problems/edit_description/{problem}problems.edit_descriptionproblem_controller@edit_descriptionadmin, head_instructor, instructor
POST/problems/toggle_practice/{query?}problems.toggle_practiceproblem_controller@toggle_practiceowner
POST/problems/edit_tags/{problem?}problems.edit_tagsproblem_controller@edit_tagsowner
problem
integer
Problem ID
assignment
integer
Assignment ID (for permission check)
type
string
Download type: “in” or “out”
query
string
Format: “practice.” or “sharable.

Resource Routes

MethodURINameController@Method
GET/problemsproblems.indexproblem_controller@index
GET/problems/createproblems.createproblem_controller@create
POST/problemsproblems.storeproblem_controller@store
GET/problems/{problem}problems.showproblem_controller@show
GET/problems/{problem}/editproblems.editproblem_controller@edit
PUT/PATCH/problems/{problem}problems.updateproblem_controller@update
DELETE/problems/{problem}problems.destroyproblem_controller@destroy
Note: problems.show always aborts with 404. Problems must be viewed through assignments or practice.

Submissions

MethodURINameController@MethodAccess
GET/submissions/assignment/{assignment_id}/user/{user_id}/problem/{problem_id}/view/{choose}submissions.indexsubmission_controller@indexauth
GET/submissions/create/assignment/{assignment}/problem/{problem}/{oldsub?}submissions.createsubmission_controller@createauth
POST/submissions/store/submissions.storesubmission_controller@storeauth
POST/submissions/get_template/submissions.get_templatesubmission_controller@get_templateauth
POST/submissions/rejudge/submissions.rejudgesubmission_controller@rejudgenot student
POST/submissions/view_code/submissions.view_codesubmission_controller@view_codeauth
POST/submissions/view_status/submissions.view_statussubmission_controller@view_statusauth
POST/submissions/select/submissions.selectsubmission_controller@select_finalauth
GET/rejudge/{assignment}submissions.rejudge_viewsubmission_controller@rejudge_viewadmin, head_instructor
POST/submissions/rejudge_all_problems_assignment/submissions.rejudge_all_problems_assignmentsubmission_controller@rejudge_all_problems_assignmentadmin, head_instructor, instructor
assignment_id
integer
Assignment ID (use 0 for practice)
user_id
integer|string
User ID or “all” for all users
problem_id
integer|string
Problem ID or “all” for all problems
choose
string
Filter: “all” or “final”
oldsub
integer
Optional previous submission ID to load

Queue

MethodURINameController@MethodAccess
GET/queuequeue.indexqueue_controller@indexadmin, head_instructor
POST/queuequeue.workqueue_controller@workadmin, head_instructor
POST/queue/{item}/unlockqueue.unlockqueue_controller@unlockadmin, head_instructor
POST/queue/emptyqueue.emptyqueue_controller@emptyadmin, head_instructor
item
integer
Queue item ID

Practice

MethodURINameController@MethodMiddleware
GET/practicepracticepractice_controller@indexauth
GET/practice/show/{problem}practices.showpractice_controller@showauth
GET/practice/show/{problem}/pdfpractices.show_pdfpractice_controller@show_pdfauth
problem
integer
Problem ID to view in practice mode

Scoreboard

MethodURINameController@MethodMiddleware
GET/scoreboard/full/{id}scoreboards.indexscoreboard_controller@indexauth
GET/scoreboard/simplify/{id}scoreboards.simplifyscoreboard_controller@simplifyauth
GET/scoreboard/plain/{id}scoreboards.plainscoreboard_controller@plainauth
id
integer
Assignment ID

Assignments

Custom Assignment Routes

MethodURINameController@MethodAccess
GET/assignment/{assignment}/{problem_id}/assignments.showassignment_controller@showauth
GET/assignment/{assignment}/{problem}/pdfassignments.show_pdfassignment_controller@show_pdfauth
GET/assignment/download_submissions/{type}/{assignment_id}/assignments.download_submissionsassignment_controller@download_submissionsadmin, head_instructor, instructor
GET/assignment/download_all_submissions/{assignment_id}/assignments.download_all_submissionsassignment_controller@download_all_submissionsadmin, head_instructor, instructor
GET/assignment/reload_scoreboard/{assignment_id}/assignments.reload_scoreboardassignment_controller@reload_scoreboardadmin, head_instructor, instructor
GET/assignment/scores/accepted/assignments.score_acceptedassignment_controller@score_acceptedadmin, head_instructor, instructor
GET/assignment/scores/sum/assignments.score_sumassignment_controller@score_sumadmin, head_instructor, instructor
POST/assignment/check_open/assignments.check_openassignment_controller@check_openowner
GET/assignment/duplicate/{assignment}assignments.duplicateassignment_controller@duplicateowner
assignment
integer
Assignment ID
problem_id
integer
Problem ID within assignment
type
string
Download organization: “by_user” or “by_problem”
Route Constraints:
Route::get('/assignment/{assignment}/{problem_id}/', ...)
    ->where(['assignment'=>'[0-9]+','problem_id'=>'[0-9]+']);

Resource Routes

MethodURINameController@Method
GET/assignmentsassignments.indexassignment_controller@index
GET/assignments/createassignments.createassignment_controller@create
POST/assignmentsassignments.storeassignment_controller@store
GET/assignments/{assignment}/editassignments.editassignment_controller@edit
PUT/PATCH/assignments/{assignment}assignments.updateassignment_controller@update
DELETE/assignments/{assignment}assignments.destroyassignment_controller@destroy
Note: assignments.show is excluded from resource routes in favor of custom show route.
Route::resource('assignments', App\Http\Controllers\assignment_controller::class)
    ->except(['show']);

Notifications

MethodURINameController@Method
GET/notificationsnotifications.indexnotification_controller@index
GET/notifications/createnotifications.createnotification_controller@create
POST/notificationsnotifications.storenotification_controller@store
GET/notifications/{notification}notifications.shownotification_controller@show
GET/notifications/{notification}/editnotifications.editnotification_controller@edit
PUT/PATCH/notifications/{notification}notifications.updatenotification_controller@update
DELETE/notifications/{notification}notifications.destroynotification_controller@destroy

Languages

MethodURINameController@Method
GET/languageslanguages.indexlanguage_controller@index
GET/languages/createlanguages.createlanguage_controller@create
POST/languageslanguages.storelanguage_controller@store
GET/languages/{language}languages.showlanguage_controller@show
GET/languages/{language}/editlanguages.editlanguage_controller@edit
PUT/PATCH/languages/{language}languages.updatelanguage_controller@update
DELETE/languages/{language}languages.destroylanguage_controller@destroy

Tags

MethodURINameController@Method
GET/tagstags.indextag_controller@index
GET/tags/createtags.createtag_controller@create
POST/tagstags.storetag_controller@store
GET/tags/{tag}tags.showtag_controller@show
GET/tags/{tag}/edittags.edittag_controller@edit
PUT/PATCH/tags/{tag}tags.updatetag_controller@update
DELETE/tags/{tag}tags.destroytag_controller@destroy

Utility Routes

Server Time

MethodURIDescription
GET/server_timeReturns current server time in ISO 8601 format
Route::get('/server_time', function(){
    echo date(DATE_ISO8601);
});

Route Ordering Notes

From the source code comments:
//Resource route phải được ghi cuối cùng, nếu không các route sau dính tới /users sẽ ăn shit
Translation: Resource routes must be written last, otherwise subsequent routes related to /users will fail. Explanation: Laravel routes are matched in order. Custom routes must be defined before resource routes to avoid conflicts. For example, /users/ranking must come before the resource routes or it would be interpreted as /users/{user} with user = "ranking".

Middleware

Global Middleware

All routes in web.php receive:
  • web middleware group
  • Session handling
  • CSRF protection
  • Cookie encryption

Route-Specific Middleware

auth
  • Requires authenticated user
  • Redirects to login if unauthenticated
  • Applied to most routes
guest
  • Requires unauthenticated user
  • Applied to login/register routes
  • Redirects authenticated users to home
ip_white_listing (in controllers)
  • Checks IP against whitelist
  • Applied in controller constructors
  • Used for secure operations
read_only_archive (in controllers)
  • Prevents write operations in archive mode
  • Applied in controller constructors
  • Used for data preservation

Resource Routes Explained

Laravel’s Route::resource() generates standard CRUD routes:
Route::resource('users', App\Http\Controllers\UserController::class);
This creates:
  • GET /users → index
  • GET /users/create → create
  • POST /users → store
  • GET /users/{user} → show
  • GET /users/{user}/edit → edit
  • PUT/PATCH /users/{user} → update
  • DELETE /users/{user} → destroy
Resource routes can be modified:
  • ->except(['show']) - Exclude specific actions
  • ->only(['index', 'show']) - Include only specific actions

Named Routes

Most routes have names for easy URL generation:
// In controllers
return redirect()->route('assignments.index');
return redirect()->route('assignments.show', ['assignment' => $id, 'problem_id' => $pid]);

// In views
<a href="{{ route('problems.edit', $problem) }}">Edit</a>
<form action="{{ route('submissions.store') }}" method="POST">

Route Parameters

Model Binding

Route parameters are automatically bound to models:
Route::get('/problems/{problem}/edit', [problem_controller::class, 'edit']);

public function edit(Problem $problem) {
    // $problem is automatically loaded from database
}

Custom Constraints

Some routes use regex constraints:
Route::get('/assignment/{assignment}/{problem_id}/', ...)
    ->where(['assignment'=>'[0-9]+', 'problem_id'=>'[0-9]+']);
This ensures parameters are numeric.

Route Groups

While not explicitly shown in the file, routes can be organized into groups:
Route::middleware(['auth'])->group(function () {
    // All routes here require authentication
});

Route::prefix('admin')->group(function () {
    // All routes here have /admin prefix
});

API Routes

Note: Wecode does not define separate API routes in routes/api.php. All routes are web routes with session-based authentication. For AJAX requests, routes accept POST data and return JSON:
  • submissions.view_code
  • submissions.view_status
  • submissions.rejudge
  • problems.edit_tags

  • routes/api.php - API routes (not used in Wecode)
  • routes/console.php - Artisan commands
  • routes/channels.php - Broadcast channels
  • app/Http/Kernel.php - Middleware definitions

Build docs developers (and LLMs) love