Skip to content

Commit

Permalink
Merge branch 'Simon-Initiative:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dtiwarATS authored Dec 6, 2024
2 parents 3f00b0f + 20f480f commit d690cb0
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 73 deletions.
2 changes: 1 addition & 1 deletion assets/src/apps/authoring/Authoring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ const Authoring: React.FC<AuthoringProps> = (props: AuthoringProps) => {
<ErrorBoundary>
<ModalContainer>
{isLoading && (
<div id="aa-loading" className="!z-10">
<div id="aa-loading" className="!z-10 -mt-2">
<div className="loader spinner-border text-primary" role="status">
<span className="sr-only">Loading...</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion assets/src/apps/authoring/AuthoringFlowchartPageEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const AuthoringFlowchartPageEditor: React.FC<AuthoringPageEditorProps> =
return (
<div
id="advanced-authoring"
className={`advanced-authoring flowchart-editor ${!sidebarExpanded ? '' : 'ml-[135px]'}`}
className={`advanced-authoring flowchart-editor mt-8 ${!sidebarExpanded ? '' : 'ml-[135px]'}`}
ref={authoringContainer}
>
<FlowchartHeaderNav
Expand Down
2 changes: 1 addition & 1 deletion assets/src/apps/authoring/BottomPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const BottomPanel: React.FC<BottomPanelProps> = (props: BottomPanelProps)
<section
id="aa-bottom-panel"
ref={ref}
className={`aa-panel bottom-panel${panelState['bottom'] ? ' open' : ''} ${
className={`aa-panel mt-8 bottom-panel${panelState['bottom'] ? ' open' : ''} ${
!sidebarExpanded ? '' : 'ml-[135px]'
}`}
style={{
Expand Down
88 changes: 45 additions & 43 deletions assets/src/apps/authoring/ReadOnlyWarning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,51 @@ export const ReadOnlyWarning: React.FC<ReadOnlyWarningProps> = ({
url,
windowName,
}) => (
<Alert variant={alertSeverity}>
<Alert.Heading>Opening in Read-Only Mode</Alert.Heading>
{!isAttemptDisableReadOnlyFailed && (
<p>
You are about to open this page in read-only mode. You are able to view the contents of this
page, but any changes you make will not be saved. You may instead attempt to open in editing
mode, or open a preview of the page.
</p>
)}
{isAttemptDisableReadOnlyFailed && (
<p>
Unfortunately, we were unable to disable read-only mode. Another author currently has the
page locked for editing. Please try again later. In the meantime, you may continue in Read
Only mode or open a preview of the page.
</p>
)}
<hr />
<div style={{ textAlign: 'center' }}>
<Button
variant={`outline-${alertSeverity}`}
className="text-dark"
onClick={() => dismissReadOnlyWarning({ attemptEdit: false })}
>
Continue In Read-Only Mode
</Button>{' '}
<div className="mt-2">
<Alert variant={alertSeverity}>
<Alert.Heading>Opening in Read-Only Mode</Alert.Heading>
{!isAttemptDisableReadOnlyFailed && (
<>
<Button
variant={`outline-${alertSeverity}`}
className="text-dark"
onClick={() => dismissReadOnlyWarning({ attemptEdit: true })}
>
Open In Edit Mode
</Button>{' '}
</>
<p>
You are about to open this page in read-only mode. You are able to view the contents of
this page, but any changes you make will not be saved. You may instead attempt to open in
editing mode, or open a preview of the page.
</p>
)}
<Button
variant={`outline-${alertSeverity}`}
className="text-dark"
onClick={() => window.open(url, windowName)}
>
Open Preview <i className="fas fa-external-link-alt ml-1"></i>
</Button>
</div>
</Alert>
{isAttemptDisableReadOnlyFailed && (
<p>
Unfortunately, we were unable to disable read-only mode. Another author currently has the
page locked for editing. Please try again later. In the meantime, you may continue in Read
Only mode or open a preview of the page.
</p>
)}
<hr />
<div style={{ textAlign: 'center' }}>
<Button
variant={`outline-${alertSeverity}`}
className="text-dark"
onClick={() => dismissReadOnlyWarning({ attemptEdit: false })}
>
Continue In Read-Only Mode
</Button>{' '}
{!isAttemptDisableReadOnlyFailed && (
<>
<Button
variant={`outline-${alertSeverity}`}
className="text-dark"
onClick={() => dismissReadOnlyWarning({ attemptEdit: true })}
>
Open In Edit Mode
</Button>{' '}
</>
)}
<Button
variant={`outline-${alertSeverity}`}
className="text-dark"
onClick={() => window.open(url, windowName)}
>
Open Preview <i className="fas fa-external-link-alt ml-1"></i>
</Button>
</div>
</Alert>
</div>
);
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const EditingCanvas: React.FC = () => {

return (
<React.Fragment>
<section className="aa-stage" onClick={handleStageClick}>
<section className="aa-stage mt-8" onClick={handleStageClick}>
<StagePan>
{currentActivityTree &&
currentActivityTree.map((activity) => (
Expand Down
2 changes: 1 addition & 1 deletion assets/src/apps/authoring/components/ExpertHeaderNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ExpertHeaderNav: React.FC<HeaderNavProps> = (props: HeaderNavProps) => {
return (
paths && (
<nav
className={`aa-header-nav top-panel overflow-hidden${
className={`aa-header-nav mt-8 top-panel overflow-hidden${
isVisible ? ' open' : ''
} d-flex aa-panel-section-title-bar ${!sidebarExpanded ? '' : 'ml-[135px]'}`}
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const FlowchartEditor: React.FC<FlowchartEditorProps> = ({ sidebarExpande

return (
<FlowchartEventContext.Provider value={events}>
<div className={`flowchart-editor ${!sidebarExpanded ? '' : 'ml-[135px]'}`}>
<div className={`flowchart-editor mt-8 ${!sidebarExpanded ? '' : 'ml-[135px]'}`}>
<DndProvider backend={HTML5Backend}>
<div className="flowchart-left">
<FlowchartModeOptions activeMode="flowchart" onPageEditMode={onPageEditMode} />
Expand Down
2 changes: 1 addition & 1 deletion assets/src/apps/authoring/components/SidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const SidePanel: React.FC<SidePanelProps> = (props: SidePanelProps) => {
</span>
</button>
<section
className={`aa-panel ${position}-panel${panelState[position] ? ' open' : ''} ${
className={`aa-panel mt-8 ${position}-panel${panelState[position] ? ' open' : ''} ${
!sidebarExpanded ? '' : 'ml-[135px]'
}`}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const PanelPicker = () => {
<code>UI Schema:{JSON.stringify(panel.uiSchema, null, 2)}</code>
</pre>
<div className="fixed-right-panel">
<section className="aa-panel right-panel open part-property-editor">
<section className="aa-panel right-panel open part-property-editor mt-8">
<div className="aa-panel-inner">
<div className="tab-content">
<div className="fade tab-pane active show">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
</div>
</div>

<%= if @section do %>
<%= if @section && !@page_context.page.graded do %>
<%= live_render(@socket, OliWeb.Dialogue.WindowLive,
session: %{
"section_slug" => @section.slug,
Expand Down
12 changes: 7 additions & 5 deletions lib/oli_web/components/layouts/workspace.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@
<% end %>
</div>
<div class={OliWeb.Workspaces.Utils.maybe_add_padding(assigns[:uri])}>
<Components.Delivery.Layouts.breadcrumb_trail
:if={assigns[:breadcrumbs]}
breadcrumbs={assigns[:breadcrumbs]}
socket={@socket}
/>
<div class="-mt-[28px]">
<Components.Delivery.Layouts.breadcrumb_trail
:if={assigns[:breadcrumbs]}
breadcrumbs={assigns[:breadcrumbs]}
socket={@socket}
/>
</div>

<%= @inner_content %>
</div>
Expand Down
27 changes: 13 additions & 14 deletions lib/oli_web/live/breadcrumb/breadcrumb_trail_workspace_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,40 @@ defmodule OliWeb.Breadcrumb.BreadcrumbTrailWorkspaceLive do
def mount(_params, session, socket) do
breadcrumbs = session["breadcrumbs"]
breadcrumbs_count = length(breadcrumbs)
back_link = Enum.at(breadcrumbs, breadcrumbs_count - 2).link

{:ok, assign(socket, breadcrumbs: breadcrumbs, breadcrumbs_count: breadcrumbs_count)}
{:ok,
assign(socket,
breadcrumbs: breadcrumbs,
breadcrumbs_count: breadcrumbs_count,
back_link: back_link
)}
end

@spec render(any) :: Phoenix.LiveView.Rendered.t()
def render(assigns) do
~H"""
<nav aria-label="breadcrumb overflow-hidden">
<nav aria-label="breadcrumb">
<ol class="breadcrumb custom-breadcrumb">
<button
<.link
:if={@breadcrumbs_count > 1}
disabled={if @breadcrumbs_count == 2, do: false, else: false}
id="curriculum-back"
class="btn btn-sm btn-link pr-5"
phx-click="set_active"
navigate={@back_link}
>
<i class="fas fa-arrow-left"></i>
</button>
</.link>
<%= for {breadcrumb, index} <- Enum.with_index(@breadcrumbs) do %>
<.live_component
module={BreadcrumbWorkspaceLive}
id={"breadcrumb-#{index}"}
breadcrumb={breadcrumb}
is_last={length(@breadcrumbs) - 1 == index}
show_short={length(@breadcrumbs) > 3}
is_last={@breadcrumbs_count - 1 == index}
show_short={@breadcrumbs_count > 3}
/>
<% end %>
</ol>
</nav>
"""
end

def handle_event("set_active", _params, socket) do
breadcrumbs = socket.assigns.breadcrumbs
parent_link = Enum.at(breadcrumbs, length(breadcrumbs) - 2).link
{:noreply, push_navigate(socket, to: parent_link)}
end
end
38 changes: 37 additions & 1 deletion test/oli_web/live/delivery/student/lesson_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ defmodule OliWeb.Delivery.Student.LessonLiveTest do
base_project: project,
title: "The best course ever!",
start_date: ~U[2023-10-30 20:00:00Z],
analytics_version: :v2
analytics_version: :v2,
assistant_enabled: true
)

{:ok, section} = Sections.create_section_resources(section, publication)
Expand Down Expand Up @@ -1362,6 +1363,41 @@ defmodule OliWeb.Delivery.Student.LessonLiveTest do
request_path
)
end

test "can see DOT AI Bot interface if it's on a non scored page", %{
conn: conn,
user: user,
section: section,
page_1: page_1
} do
Sections.enroll(user.id, section.id, [ContextRoles.get_role(:context_learner)])
Sections.mark_section_visited_for_student(section, user)

{:ok, view, _html} = live(conn, Utils.lesson_live_path(section.slug, page_1.slug))
ensure_content_is_visible(view)

assert has_element?(view, "div[id='dialogue-window']")
assert has_element?(view, "div[id=ai_bot_collapsed]")
end

test "can not see DOT AI Bot interface if it's on a scored page", %{
conn: conn,
user: user,
section: section,
page_3: page_3
} do
Sections.enroll(user.id, section.id, [ContextRoles.get_role(:context_learner)])
Sections.mark_section_visited_for_student(section, user)

_first_attempt_in_progress =
create_attempt(user, section, page_3, %{lifecycle_state: :active})

{:ok, view, _html} = live(conn, Utils.lesson_live_path(section.slug, page_3.slug))
ensure_content_is_visible(view)

refute has_element?(view, "div[id='dialogue-window']")
refute has_element?(view, "div[id=ai_bot_collapsed]")
end
end

describe "annotations toggle" do
Expand Down
18 changes: 17 additions & 1 deletion test/oli_web/live/delivery/student/prologue_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ defmodule OliWeb.Delivery.Student.PrologueLiveTest do
base_project: project,
title: "The best course ever!",
start_date: ~U[2023-10-30 20:00:00Z],
analytics_version: :v2
analytics_version: :v2,
assistant_enabled: true
)

{:ok, section} = Sections.create_section_resources(section, publication)
Expand Down Expand Up @@ -1136,6 +1137,21 @@ defmodule OliWeb.Delivery.Student.PrologueLiveTest do
|> render() =~
"Your overall score for this assignment will be the average score of your attempts."
end

test "can not see DOT AI Bot interface if it's on a scored page", %{
conn: conn,
user: user,
section: section,
page_1: page_1
} do
Sections.enroll(user.id, section.id, [ContextRoles.get_role(:context_learner)])
Sections.mark_section_visited_for_student(section, user)

{:ok, view, _html} = live(conn, Utils.prologue_live_path(section.slug, page_1.slug))

refute has_element?(view, "div[id='dialogue-window']")
refute has_element?(view, "div[id=ai_bot_collapsed]")
end
end

describe "offline detector" do
Expand Down

0 comments on commit d690cb0

Please sign in to comment.