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 committed Sep 20, 2024
2 parents b34717f + 275cf93 commit d69cf74
Show file tree
Hide file tree
Showing 51 changed files with 1,613 additions and 413 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const Step3Advanced: React.FC<{
<h2>Note</h2>

<p>
Projects created in Advanced Authoring do not open in Basic Authoring. This requires
Projects created in Advanced Authoring do not open in Simple Authoring. This requires
creating a new lesson project.
</p>
</div>
Expand Down Expand Up @@ -185,7 +185,7 @@ const Step2: React.FC<{
<div className="big-icon">
<D6 />
</div>
<label>Basic authoring</label>
<label>Simple authoring</label>
<p>Easily build lessons using templates, simplified interactions, and conditioning.</p>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ const lessonSchema: JSONSchema7 = {
title: 'Enable History',
type: 'boolean',
},
displayRefreshWarningPopup: {
type: 'boolean',
title: 'Refresh warning popup',
default: 'true',
},
customCSS: {
title: 'Custom CSS',
type: 'string',
Expand Down Expand Up @@ -156,6 +161,11 @@ export const simpleLessonSchema: JSONSchema7 = {
title: 'Enable History',
type: 'boolean',
},
displayRefreshWarningPopup: {
type: 'boolean',
title: 'Refresh warning popup',
default: 'true',
},
},
},
},
Expand Down Expand Up @@ -240,6 +250,7 @@ export const transformModelToSchema = (model: any) => {
title: model.title,
customCSS: model.customCss,
enableHistory: model.custom.allowNavigation || model.custom.enableHistory || false,
displayRefreshWarningPopup: model.custom.displayRefreshWarningPopup || true,
},
CustomLogic: {
variables: model.custom.variables,
Expand Down Expand Up @@ -269,6 +280,7 @@ export const transformSchemaToModel = (schema: any) => {
defaultScreenWidth: schema.Properties.Size.width,
defaultScreenHeight: schema.Properties.Size.height,
enableHistory: schema.Properties.enableHistory,
displayRefreshWarningPopup: schema.Properties.displayRefreshWarningPopup,
variables,
logoutMessage: schema.Properties.FinishPanel.logoutMessage,
logoutPanelImageURL: schema.Properties.FinishPanel.logoutPanelImageURL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ export const transformSchemaToModel = (schema: any) => {
useHtmlProps: true,
backgroundColor: palette.backgroundColor || 'transparent',
borderColor: palette.borderColor || 'transparent',
borderRadius: parseNumString(palette.borderRadius) || 0,
borderWidth: parseNumString(palette.borderWidth) || 0,
borderRadius: parseNumString(palette?.borderRadius) || 0,
borderWidth: parseNumString(palette?.borderWidth) || 0,
borderStyle: palette.borderStyle || 'none',
};
}
Expand Down
16 changes: 16 additions & 0 deletions assets/src/apps/delivery/Delivery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ const Delivery: React.FC<DeliveryProps> = ({
handleUserThemePreferende();
}, []);

useEffect(() => {
const displayRefreshWarningPopup = content?.custom?.displayRefreshWarningPopup || true;

// Only show the prompt if it's not in preview mode and not in review mode
if (displayRefreshWarningPopup && isInstructor && !previewMode && !reviewMode) {
const unloadCallback = (event: any) => {
event.preventDefault();
event.returnValue = '';
return '';
};

window.addEventListener('beforeunload', unloadCallback);
return () => window.removeEventListener('beforeunload', unloadCallback);
}
}, [content?.custom?.displayRefreshWarningPopup]);

const setInitialPageState = () => {
// the standard lib relies on first the userId and userName session variables being set
const userScript = `let session.userId = ${userId};let session.userName = "${
Expand Down
6 changes: 5 additions & 1 deletion assets/src/components/common/SelectTimezone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export const SelectTimezone: React.FC<SelectTimezoneProps> = ({
submitAction,
}) => {
const ref = useRef<HTMLFormElement>(null);
const onSelect = ({ target: { value } }: any) => {
const onSelect = ({ target: { value }, isTrusted, nativeEvent }: any) => {
// Only submit the form if the change event was triggered by a user action to
// prevent this from being triggered by the browser's autofill feature or
// any react re-renders.
if (!isTrusted || !nativeEvent) return;
ref.current?.submit();
};

Expand Down
6 changes: 3 additions & 3 deletions assets/src/components/misc/DarkModeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const DarkModeSelector = ({ showLabels = true }: DarkModeSelectorProps) =
<svg
className={classNames(
isChecked(mode, 'auto') && 'hidden',
'dark:stroke-[#B8B4BF] stroke-black/70 hover:dark:stroke-white hover:stroke-black/90',
'dark:stroke-[#B8B4BF] stroke-black/70 hover:stroke-black hover:dark:stroke-white',
)}
width="20"
height="20"
Expand Down Expand Up @@ -109,7 +109,7 @@ export const DarkModeSelector = ({ showLabels = true }: DarkModeSelectorProps) =
xmlns="http://www.w3.org/2000/svg"
className={classNames(
isChecked(mode, 'light') && 'stroke-black/90',
'dark:stroke-[#B8B4BF] stroke-black/70 hover:stroke-black/90 hover:dark:stroke-white',
'dark:stroke-[#B8B4BF] stroke-black/70 hover:stroke-black hover:dark:stroke-white',
)}
>
<path
Expand All @@ -130,7 +130,7 @@ export const DarkModeSelector = ({ showLabels = true }: DarkModeSelectorProps) =
{maybeLabel('Light', showLabels)}
</ToggleOption>
<ToggleOption id="dark" checked={isChecked(mode, 'dark')} onChange={onSelect('dark')}>
<div className="dark:stroke-[#B8B4BF] stroke-black/70 hover:stroke-black/90 hover:dark:stroke-white">
<div className="dark:stroke-[#B8B4BF] stroke-black/70 hover:stroke-black hover:dark:stroke-white">
<svg
width="20"
height="20"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ExternalActivity: React.FC<PartComponentProps<CapiIframeModel>> = (props)
const [lessonId, setLessonId] = useState('');

// these rely on being set every render and the "model" useState value being set
const { title, allowScrolling, configData } = model;
const { allowScrolling, configData, description } = model;
const getInterestedVariable = (StateSnapshot: Record<string, any>, domain: string) => {
return Object.keys(StateSnapshot).reduce((collect: Record<string, any>, key) => {
if (key.indexOf(`${domain}.${id}.`) === 0) {
Expand Down Expand Up @@ -1135,9 +1135,11 @@ const ExternalActivity: React.FC<PartComponentProps<CapiIframeModel>> = (props)
data-janus-type={tagName}
ref={frameRef}
style={externalActivityStyles}
title={title}
title={description}
src={frameSrc}
scrolling={scrolling}
aria-label={description}
aria-describedby={id}
allow="accelerometer *; magnetometer; gyroscope; fullscreen; autoplay; clipboard-write; encrypted-media; xr-spatial-tracking; gamepad *;"
/>
) : null;
Expand Down
10 changes: 10 additions & 0 deletions assets/src/components/parts/janus-capi-iframe/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export const simpleSchema: JSONSchema7Object = {
title: 'Allow Scrolling',
type: 'boolean',
},
description: {
title: 'description',
description: 'provides title and aria-label content',
type: 'string',
},
};

export const schema: JSONSchema7Object = {
Expand All @@ -29,6 +34,11 @@ export const schema: JSONSchema7Object = {
title: 'Source',
type: 'string',
},
description: {
title: 'description',
description: 'provides title and aria-label content',
type: 'string',
},
allowScrolling: {
title: 'Allow Scrolling',
type: 'boolean',
Expand Down
8 changes: 4 additions & 4 deletions assets/src/components/parts/janus-text-flow/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ export const transformModelToSchema = (model: Partial<TextFlowModel>) => {
if (palette.useHtmlProps) {
paletteStyles.backgroundColor = palette.backgroundColor;
paletteStyles.borderColor = palette.borderColor;
paletteStyles.borderWidth = parseNumString(palette.borderWidth.toString());
paletteStyles.borderWidth = parseNumString(palette?.borderWidth?.toString()) || 0;
paletteStyles.borderStyle = palette.borderStyle;
paletteStyles.borderRadius = parseNumString(palette.borderRadius.toString());
paletteStyles.borderRadius = parseNumString(palette?.borderRadius?.toString()) || 0;
} else {
paletteStyles.borderWidth = `${palette.lineThickness ? palette.lineThickness + 'px' : 0}`;
paletteStyles.borderRadius = 0;
Expand Down Expand Up @@ -189,8 +189,8 @@ export const transformSchemaToModel = (schema: Partial<TextFlowModel>) => {
useHtmlProps: true,
backgroundColor: palette.backgroundColor || 'transparent',
borderColor: palette.borderColor || 'transparent',
borderRadius: parseNumString(palette.borderRadius.toString()) || 0,
borderWidth: parseNumString(palette.borderWidth.toString()) || 0,
borderRadius: parseNumString(palette?.borderRadius?.toString()) || 0,
borderWidth: parseNumString(palette?.borderWidth?.toString()) || 0,
borderStyle: palette.borderStyle || 'none',
};
}
Expand Down
4 changes: 4 additions & 0 deletions lib/oli/accounts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ defmodule Oli.Accounts do
update_user(user, %{author_id: author.id})
end

def unlink_user_author_account(user) do
update_user(user, %{author_id: nil})
end

@doc """
Returns true if a user belongs to an LMS.
"""
Expand Down
12 changes: 11 additions & 1 deletion lib/oli/analytics/summary/browse_insights.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,28 @@ defmodule Oli.Analytics.Summary.BrowseInsights do
def browse_insights(
%Paging{limit: limit, offset: offset},
%Sorting{} = sorting,
%BrowseInsightsOptions{project_id: project_id, section_ids: section_ids} = options
%BrowseInsightsOptions{
project_id: project_id,
section_ids: section_ids,
text_search: text_search
} = options
) do
where_by = build_where_by(options)
total_count = get_total_count(project_id, section_ids, where_by)

text_search_condition =
if text_search && text_search != "",
do: dynamic([_s, _pub, _pr, rev], ilike(rev.title, ^"%#{text_search}%")),
else: true

# Now build the main query with limit, offset, and aggregations
query =
ResourceSummary
|> join(:left, [s], pub in Publication, on: pub.project_id == ^project_id)
|> join(:left, [s, pub], pr in PublishedResource, on: pr.publication_id == pub.id)
|> join(:left, [s, pub, pr], rev in Revision, on: rev.id == pr.revision_id)
|> where(^where_by)
|> where(^text_search_condition)
|> add_select(total_count, options)
|> add_order_by(sorting, options)
|> limit(^limit)
Expand Down
6 changes: 4 additions & 2 deletions lib/oli/analytics/summary/browse_insights_options.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ defmodule Oli.Analytics.Summary.BrowseInsightsOptions do
defstruct [
:project_id,
:section_ids,
:resource_type_id
:resource_type_id,
:text_search
]

@type t() :: %__MODULE__{
project_id: integer(),
section_ids: list(),
resource_type_id: integer()
resource_type_id: integer(),
text_search: String.t()
}
end
14 changes: 14 additions & 0 deletions lib/oli/delivery/sections.ex
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,20 @@ defmodule Oli.Delivery.Sections do
false
end

@doc """
Determines if a user is a platform (institution) administrator.
"""
def is_institution_admin?(%User{} = user) do
PlatformRoles.has_roles?(
user,
[
PlatformRoles.get_role(:system_administrator),
PlatformRoles.get_role(:institution_administrator)
],
:any
)
end

@doc """
Enrolls a user or users in a course section
## Examples
Expand Down
2 changes: 2 additions & 0 deletions lib/oli/delivery/sections/updates.ex
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ defmodule Oli.Delivery.Sections.Updates do

case result do
{:ok, _} ->
Oli.Delivery.Sections.SectionCache.clear(section.slug)

Broadcaster.broadcast_update_progress(section.id, new_publication.id, :complete)

_ ->
Expand Down
22 changes: 11 additions & 11 deletions lib/oli_web/components/common.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,31 +106,31 @@ defmodule OliWeb.Components.Common do
"rounded text-white hover:text-white bg-primary-500 hover:bg-primary-600 active:bg-primary-700 focus:ring-2 focus:ring-primary-400 dark:bg-primary-600 dark:hover:bg-primary dark:active:bg-primary-400 focus:outline-none dark:focus:ring-primary-700 hover:no-underline"

:secondary ->
"rounded text-body-color bg-transparent hover:bg-gray-200 active:text-white active:bg-primary-700 focus:ring-2 focus:ring-primary-400 dark:text-body-color-dark dark:hover:bg-gray-600 dark:active:bg-primary-400 focus:outline-none dark:focus:ring-primary-700 hover:no-underline"
"rounded text-body-color hover:text-body-color bg-transparent hover:bg-gray-200 active:text-white active:bg-primary-700 focus:ring-2 focus:ring-primary-400 dark:text-body-color-dark dark:hover:bg-gray-600 dark:active:bg-primary-400 focus:outline-none dark:focus:ring-primary-700 hover:no-underline"

:tertiary ->
"rounded text-primary-700 bg-primary-50 hover:bg-primary-100 active:bg-primary-200 focus:ring-2 focus:ring-primary-100 dark:text-primary-300 dark:bg-primary-800 dark:hover:bg-primary-700 dark:active:bg-primary-600 focus:outline-none dark:focus:ring-primary-800 hover:no-underline"
"rounded text-primary-700 hover:text-primary-700 bg-primary-50 hover:bg-primary-100 active:bg-primary-200 focus:ring-2 focus:ring-primary-100 dark:text-primary-300 dark:bg-primary-800 dark:hover:bg-primary-700 dark:active:bg-primary-600 focus:outline-none dark:focus:ring-primary-800 hover:no-underline"

:light ->
"rounded text-body-color bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus:ring-2 focus:ring-gray-100 dark:text-white dark:bg-gray-800 dark:hover:bg-gray-700 dark:active:bg-gray-600 focus:outline-none dark:focus:ring-gray-800 hover:no-underline"
"rounded text-body-color hover:text-body-color bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus:ring-2 focus:ring-gray-100 dark:text-white dark:bg-gray-800 dark:hover:bg-gray-700 dark:active:bg-gray-600 focus:outline-none dark:focus:ring-gray-800 hover:no-underline"

:dark ->
"rounded text-white bg-gray-700 hover:bg-gray-800 active:bg-gray-600 focus:ring-2 focus:ring-gray-600 dark:text-white dark:bg-gray-700 dark:hover:bg-gray-600 dark:active:bg-gray-500 focus:outline-none dark:focus:ring-gray-500 hover:no-underline"
"rounded text-white hover:text-white bg-gray-700 hover:bg-gray-800 active:bg-gray-600 focus:ring-2 focus:ring-gray-600 dark:text-white dark:bg-gray-700 dark:hover:bg-gray-600 dark:active:bg-gray-500 focus:outline-none dark:focus:ring-gray-500 hover:no-underline"

:info ->
"rounded text-white bg-gray-500 hover:bg-gray-600 active:bg-gray-700 focus:ring-2 focus:ring-gray-400 dark:bg-gray-600 dark:hover:bg-gray-500 dark:active:bg-gray-400 focus:outline-none dark:focus:ring-gray-700 hover:no-underline"
"rounded text-white hover:text-white bg-gray-500 hover:bg-gray-600 active:bg-gray-700 focus:ring-2 focus:ring-gray-400 dark:bg-gray-600 dark:hover:bg-gray-500 dark:active:bg-gray-400 focus:outline-none dark:focus:ring-gray-700 hover:no-underline"

:success ->
"rounded text-white bg-green-600 hover:bg-green-700 active:bg-green-800 focus:ring-2 focus:ring-green-700 dark:bg-green-600 dark:hover:bg-green-500 dark:active:bg-green-400 focus:outline-none dark:focus:ring-green-700 hover:no-underline"
"rounded text-white hover:text-white bg-green-600 hover:bg-green-700 active:bg-green-800 focus:ring-2 focus:ring-green-700 dark:bg-green-600 dark:hover:bg-green-500 dark:active:bg-green-400 focus:outline-none dark:focus:ring-green-700 hover:no-underline"

:warning ->
"rounded text-white bg-yellow-500 hover:bg-yellow-600 active:bg-yellow-700 focus:ring-2 focus:ring-yellow-400 dark:bg-yellow-600 dark:hover:bg-yellow-500 dark:active:bg-yellow-400 focus:outline-none dark:focus:ring-yellow-700 hover:no-underline"
"rounded text-white hover:text-white bg-yellow-500 hover:bg-yellow-600 active:bg-yellow-700 focus:ring-2 focus:ring-yellow-400 dark:bg-yellow-600 dark:hover:bg-yellow-500 dark:active:bg-yellow-400 focus:outline-none dark:focus:ring-yellow-700 hover:no-underline"

:danger ->
"rounded text-white bg-red-500 hover:bg-red-600 active:bg-red-700 focus:ring-2 focus:ring-red-400 dark:bg-red-600 dark:hover:bg-red-500 dark:active:bg-red-400 focus:outline-none dark:focus:ring-red-700 hover:no-underline"
"rounded text-white hover:text-white bg-red-500 hover:bg-red-600 active:bg-red-700 focus:ring-2 focus:ring-red-400 dark:bg-red-600 dark:hover:bg-red-500 dark:active:bg-red-400 focus:outline-none dark:focus:ring-red-700 hover:no-underline"

:link ->
"rounded text-blue-500 hover:text-blue-600 active:text-blue-700 focus:ring-2 focus:ring-blue-400 dark:text-blue-600 dark:hover:text-blue-500 dark:active:text-blue-400 focus:outline-none dark:focus:ring-blue-700 hover:underline cursor-pointer"
"rounded text-blue-500 hover:text-blue-600 hover:text-blue-600 active:text-blue-700 focus:ring-2 focus:ring-blue-400 dark:text-blue-600 dark:hover:text-blue-500 dark:active:text-blue-400 focus:outline-none dark:focus:ring-blue-700 hover:underline cursor-pointer"

:link_info ->
"rounded text-gray-500 hover:text-gray-600 active:text-gray-700 focus:ring-2 focus:ring-gray-400 dark:text-gray-600 dark:hover:text-gray-500 dark:active:text-gray-400 focus:outline-none dark:focus:ring-gray-700 hover:underline cursor-pointer"
Expand Down Expand Up @@ -205,7 +205,7 @@ defmodule OliWeb.Components.Common do
<button
type={@type}
class={[
"whitespace-nowrap",
"whitespace-nowrap overflow-hidden text-ellipsis",
button_variant_classes(@variant, disabled: @rest[:disabled]),
button_size_classes(@size),
@class
Expand All @@ -218,7 +218,7 @@ defmodule OliWeb.Components.Common do
<a
href={@href}
class={[
"whitespace-nowrap",
"whitespace-nowrap overflow-hidden text-ellipsis",
button_variant_classes(@variant, disabled: @rest[:disabled]),
button_size_classes(@size),
@class
Expand Down
5 changes: 4 additions & 1 deletion lib/oli_web/components/delivery/layouts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule OliWeb.Components.Delivery.Layouts do
alias OliWeb.Icons
alias Oli.Resources.Collaboration.CollabSpaceConfig
alias OliWeb.Delivery.Student.Utils
alias OliWeb.Workspace.Utils, as: WorkspaceUtils
alias OliWeb.Workspaces.Utils, as: WorkspaceUtils

attr(:ctx, SessionContext)
attr(:is_system_admin, :boolean, required: true)
Expand Down Expand Up @@ -560,6 +560,9 @@ defmodule OliWeb.Components.Delivery.Layouts do
["", "workspaces", "course_author", project_slug, "products"] ->
~p"/workspaces/course_author/#{project_slug}/products?#{params}"

["", "workspaces", "course_author", project_slug, "insights"] ->
~p"/workspaces/course_author/#{project_slug}/insights?#{params}"

_ ->
~p"/"
end
Expand Down
Loading

0 comments on commit d69cf74

Please sign in to comment.