chore: init commit

in worker.../repo/GITFOLDER.zip is the .git folder.
This commit is contained in:
2026-08-11 14:44:09 -04:00
parent 0012380fd3
commit 392781f7aa
781 changed files with 65944 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
<div class="mt-8">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Student [Username]</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Portfolio Value</th>
<% if @can_manage_students %>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Available Cash</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
<% end %>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<% @students.each do |student| %>
<tr class="group hover:bg-gray-50 transition-colors duration-150"
id="<%= dom_id(student) %>">
<td class="px-6 py-4 whitespace-nowrap" data-testid="student-username">
<% if student.username.present? %>
<% if student.portfolio %>
<%= link_to student.username, user_portfolio_path(student, student.portfolio), class: "text-black underline hover:text-[var(--sitf-secondary-chart2)] font-medium" %>
<% else %>
<span class="text-gray-400 italic"><%= student.username %></span>
<% end %>
<% else %>
<span class="text-gray-400 italic">No username set</span>
<% end %>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900 font-medium">
<%= number_to_currency(student.portfolio&.holdings_value || 0) %>
</td>
<% if @can_manage_students %>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900 font-medium">
<%= number_to_currency(student.portfolio&.cash_balance || 0) %>
</td>
<% end %>
<% if @can_manage_students %>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium" data-testid="student-actions">
<div class="flex items-center gap-2">
<%= link_to edit_classroom_student_path(@classroom, student),
class: "inline-flex items-center justify-center w-8 h-8 text-black hover:text-[var(--sitf-secondary-chart2)] hover:bg-blue-50 rounded-lg transition-all duration-150 group",
title: "Edit student",
data: { testid: "edit-student" } do %>
<i class="fa fa-pencil fa-lg group-hover:scale-110 transition-transform duration-150"></i>
<% end %>
<%= link_to reset_password_classroom_student_path(@classroom, student),
data: {
turbo_method: :patch,
turbo_confirm: "Are you sure you want to reset #{student.username}'s password?",
testid: "reset-password"
},
class: "inline-flex items-center justify-center w-8 h-8 text-amber-600 hover:text-amber-800 hover:bg-amber-50 rounded-lg transition-all duration-150 group",
title: "Reset password" do %>
<%= lucide_icon("refresh-cw") %>
<% end %>
<%= link_to classroom_student_path(@classroom, student),
data: {
turbo_method: :delete,
turbo_confirm: "Are you sure you want to delete #{student.username}?",
testid: "delete-student"
},
class: "inline-flex items-center justify-center w-8 h-8 text-red-600 hover:text-red-800 hover:bg-red-50 rounded-lg transition-all duration-150 group",
title: "Delete student" do %>
<i class="fa fa-trash fa-lg group-hover:scale-110 transition-transform duration-150"></i>
<% end %>
</div>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<% if @students.empty? %>
<div class="text-center py-8">
<p class="text-gray-500">No students in this classroom yet.</p>
<% if @can_manage_students %>
<%= link_to "Add the first student", new_classroom_student_path(@classroom),
class: "mt-2 inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700" %>
<% end %>
</div>
<% end %>
</div>

View File

@@ -0,0 +1,131 @@
<%= form_with(model: classroom, class: "contents") do |form| %>
<% if classroom.errors.any? %>
<div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-lg mt-3">
<h2>
<%= pluralize(classroom.errors.count, "error") %> prohibited this classroom from being saved:
</h2>
<ul>
<% classroom.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="my-5">
<%= form.label :name, class: 'tw-label-primary' do %>
Name<span class="required-indicator">*</span>
<% end %>
<div class="mt-2">
<%= form.text_field :name, class: "tw-input-primary", required: true %>
</div>
</div>
<div class="my-5">
<%= form.label :school_id, "School Name", class: 'tw-label-primary' %>
<div class="mt-2">
<% school_year = classroom&.school_year
selected_school_id = school_year&.school&.id %>
<%= form.select :school_id,
options_from_collection_for_select(@schools, :id, :name, selected_school_id),
{ prompt: "Select a school" },
{ class: "tw-input-primary" } %>
</div>
</div>
<div class="my-5">
<%= form.label :year_id, "Year", class: 'tw-label-primary' %>
<div class="mt-2">
<% school_year = classroom&.school_year
selected_year_id = school_year&.year&.id %>
<%= form.select :year_id,
options_from_collection_for_select(@years, :id, :name, selected_year_id),
{ prompt: "Select a year" },
{ class: "tw-input-primary" } %>
</div>
</div>
<div class="my-5">
<%= form.label :grade_ids, class: 'tw-label-primary flex items-center gap-2' do %>
Grades<span class="required-indicator">*</span>
<% end %>
<!-- Single hidden field to handle empty selections -->
<%= hidden_field_tag "classroom[grade_ids][]", "" %>
<div class="mt-3 grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 max-h-60 overflow-y-auto p-3 border border-gray-200 rounded-lg bg-gray-50">
<% Grade.where(level: Classroom::GRADE_RANGE).order(:level).each do |grade| %>
<%# Check if this grade is selected for the classroom %>
<% is_checked = classroom.persisted? ? classroom.grades.include?(grade) : false %>
<label class="flex items-center gap-3 p-3 hover:bg-white rounded-lg cursor-pointer transition-colors">
<%= check_box_tag "classroom[grade_ids][]",
grade.id,
is_checked,
class: "rounded border-gray-300 text-blue-600 focus:ring-blue-500" %>
<div class="flex-1">
<div class="font-medium text-gray-900">
<%= grade.name %>
</div>
</div>
</label>
<% end %>
</div>
<p class="text-sm text-gray-600 mt-2">
<span class="text-red-500 font-medium">* Required:</span> Select at least one grade that applies to this classroom.
</p>
</div>
<div class="my-5">
<div class="flex items-center gap-3">
<%= form.check_box :trading_enabled, class: "rounded border-gray-300 text-blue-600 focus:ring-blue-500" %>
<%= form.label :trading_enabled, "Enable Trading", class: 'tw-label-primary' %>
</div>
<p class="text-sm text-gray-600 mt-1">When enabled, students in this classroom can place buy and sell orders.</p>
</div>
<div class="my-5">
<%= label_tag :teacher_ids, "Teachers", class: 'tw-label-primary flex items-center gap-2' %>
<!-- Single hidden field to handle empty selections -->
<%= hidden_field_tag "classroom[teacher_ids][]", "" %>
<div class="mt-3 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2 max-h-60 overflow-y-auto p-2 border border-gray-200 rounded-lg bg-gray-50">
<% @teachers.each do |teacher| %>
<%# Check if teacher is assigned to this classroom %>
<% is_checked = classroom.persisted? ? classroom.teachers.include?(teacher) : false %>
<label class="flex items-start gap-2 p-3 hover:bg-white rounded-lg cursor-pointer transition-colors">
<%= check_box_tag "classroom[teacher_ids][]",
teacher.id,
is_checked,
{
class: "rounded border-gray-300 text-blue-600 focus:ring-blue-500 mt-0.5",
id: "classroom_teacher_ids_#{teacher.id}"
} %>
<div class="flex items-start gap-2 min-w-0 flex-1">
<div class="w-8 h-8 bg-blue-500 rounded-full flex items-center justify-center text-white text-sm font-medium flex-shrink-0 mt-1">
<%= teacher.display_name.first.upcase %>
</div>
<div class="min-w-0 flex-1">
<div class="text-gray-900 font-medium truncate">
<%= teacher.display_name %>
</div>
<div class="text-xs text-gray-500 truncate">
@<%= teacher.email %>
</div>
</div>
</div>
</label>
<% end %>
</div>
</div>
<div class="inline">
<%= form.submit class: "tw-btn-primary" %>
</div>
<% end %>

View File

@@ -0,0 +1,26 @@
<div class="mt-8 w-64 flex-initial">
<h3 class="bg-amber-300 py-3 px-5 font-medium text-sm tracking-wide rounded-t-xl">
<i class="fas fa-book w-4 h-4"></i>
Grade Books
</h3>
<% if grade_books.any? %>
<ul class="divide-y divide-gray-200 bg-white rounded-md shadow">
<% grade_books.each do |book| %>
<li class="px-6 py-4 hover:bg-gray-50">
<%= link_to classroom_grade_book_path(@classroom, book),
class: "text-black underline hover:text-[var(--sitf-secondary-chart2)] font-medium" do %>
<span class="flex flex-between items-center justify-between w-full">
<%= book.quarter.name %>
<i class="fa-solid fa-arrow-right"></i>
</span>
<% end %>
</li>
<% end %>
</ul>
<% else %>
<div class="text-center py-8 text-gray-500">
No grade books created for this classroom yet.
</div>
<% end %>
</div>

View File

@@ -0,0 +1,8 @@
<div class="mx-auto md:w-2/3 w-full">
<h1 class="font-bold text-4xl">Editing classroom</h1>
<%= render "form", classroom: @classroom %>
<%= link_to "Show this classroom", @classroom, class: "tw-btn-tertiary" %>
<%= link_to "Back to classrooms", classrooms_path, class: "tw-btn-tertiary" %>
</div>

View File

@@ -0,0 +1,102 @@
<div class="flex flex-col h-full w-full">
<% if notice.present? %>
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice">
<%= notice %>
</p>
<% end %>
<header class="flex items-center justify-between px-6 py-4 border-b">
<h1 class="text-2xl font-bold py-2">Classrooms</h1>
<% if policy(Classroom).new? %>
<%= link_to "New classroom", new_classroom_path,
class: "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded" %>
<% end %>
</header>
<main class="flex-1 p-6">
<%= render "shared/table_container" do %>
<thead>
<tr class="table-header-row">
<th class="table-header-cell table-header-cell-left">
<%= sort_link(:name, "Name") %>
</th>
<th class="table-header-cell table-header-cell-left">
Teacher(s)
</th>
<th class="table-header-cell table-header-cell-left">
<%= sort_link(:student_count, "Student Count") %>
</th>
<th class="table-header-cell table-header-cell-right">
<%= sort_link(:total_earnings, "Total Earnings") %>
</th>
<th class="table-header-cell table-header-cell-center">
Edit
</th>
</tr>
</thead>
<tbody>
<% if @classrooms.any? %>
<% @classrooms.each do |classroom| %>
<tr class="table-body-row">
<td class="table-body-cell">
<span class="table-cell-content">
<%= link_to classroom.name, classroom_path(classroom), class: "text-black underline hover:text-[var(--sitf-secondary-chart2)]" %>
</span>
</td>
<td class="table-body-cell py-4">
<div class="flex gap-1 overflow-x-auto py-1" style="max-width: 510px; min-height: 36px;">
<% if classroom.teachers.any? %>
<% classroom.teachers.each do |teacher| %>
<span class="inline-flex items-center px-2.5 py-1.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800 border border-blue-200 whitespace-nowrap flex-shrink-0">
<i class="fas fa-user-tie mr-1 text-blue-600"></i>
<%= teacher.display_name %>
</span>
<% end %>
<% else %>
<span class="inline-flex items-center px-2.5 py-1.5 rounded-full text-xs font-medium bg-gray-100 text-gray-500 border border-gray-200 whitespace-nowrap">
<i class="fas fa-user-slash mr-1 text-gray-400"></i>
No teacher assigned
</span>
<% end %>
</div>
</td>
<td class="table-body-cell">
<span class="table-cell-content">
<%= classroom.students.count %>
</span>
</td>
<td class="table-body-cell table-body-cell-right">
<span class="table-cell-content">
$<%= number_with_precision(classroom.students.sum { |s| s.portfolio&.calculate_total_value || 0 }, precision: 2) %>
</span>
</td>
<td class="table-body-cell table-body-cell-center">
<% if policy(classroom).edit? %>
<%= render partial: "components/action_icon_button",
locals: {
options: {
path: edit_classroom_path(classroom),
icon: "fa-pencil",
title: "Edit classroom",
aria_label: "Edit classroom",
text_class: "text-black"
}
} %>
<% else %>
<span class="table-no-permission">-</span>
<% end %>
</td>
</tr>
<% end %>
<% else %>
<tr class="table-body-row">
<td class="table-empty-cell" colspan="5">
<p class="text-lg">No classrooms found</p>
<p class="mt-2">Create your first classroom to get started!</p>
</td>
</tr>
<% end %>
</tbody>
<% end %>
</main>
</div>

View File

@@ -0,0 +1,7 @@
<div class="mx-auto md:w-2/3 w-full">
<h1 class="font-bold text-4xl">New classroom</h1>
<%= render "form", classroom: @classroom %>
<%= link_to "Back to classrooms", classrooms_path, class: "tw-btn-tertiary" %>
</div>

View File

@@ -0,0 +1,46 @@
<div class="mx-auto w-full flex">
<div class="mx-auto w-full">
<% if notice.present? %>
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
<% end %>
<div class="flex gap-4 items-center justify-between my-6">
<div class="flex gap-4">
<h1 class="text-3xl font-bold">
<%= [
@classroom.name,
("Grade #{@classroom.grades_display}" if @classroom.grades_display.present?),
@classroom.year_name
].compact.join(', ') %>
</h1>
<%= form_with url: toggle_trading_classroom_path(@classroom), method: :patch, class: "contents" do %>
<label class="inline-flex items-center cursor-pointer">
<%= check_box_tag "trading", "1", @classroom.trading_enabled?, class: "sr-only peer", disabled: !policy(@classroom).toggle_trading?, onchange: "this.form.requestSubmit()" %>
<span class="select-none text-sm font-medium">Trading:</span>
<div class="relative ms-1 w-9 h-5 bg-gray-300 rounded-full peer peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-buffer after:content-[''] after:absolute after:top-0.5 after:start-0.5 after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-green-600"></div>
</label>
<% end %>
</div>
<% if @can_manage_students %>
<div class="flex justify-end gap-3">
<%= link_to "Add Student", new_classroom_student_path(@classroom),
class: "tw-btn-primary" %>
<% if policy(@classroom).edit? %>
<%= link_to "Edit Class", edit_classroom_path(@classroom), class: "tw-btn-secondary !rounded-lg !py-3 !px-5 !text-base !text-black !ring-black" %>
<% end %>
<!-- TODO: Add bulk functionality in future PR -->
</div>
<% end %>
</div>
<div class="flex gap-8">
<div class="flex-1">
<%= render 'classroom_students_table', students: @classroom.users %>
</div>
<!-- Temporary UI, remove when tabbed table is wired up: -->
<%= render "grade_books_list", grade_books: @classroom.grade_books %>
</div>
</div>
</div>