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 May 10, 2024
2 parents ff2cea0 + 0817342 commit 76bec34
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 89 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:
name: Elixir build and test
runs-on: ubuntu-latest

environment: ci-build-test

env:
MIX_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions assets/src/data/content/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export const PurposeTypes: Purpose[] = [
{ value: 'learnbydoing', label: 'Learn by doing' },
{ value: 'learnmore', label: 'Learn more' },
{ value: 'manystudentswonder', label: 'Many students wonder' },
{ value: 'priorknowledgecheck', label: 'Prior Knowledge Check' },
{ value: 'quiz', label: 'Quiz' },
{ value: 'simulation', label: 'Simulation' },
{ value: 'walkthrough', label: 'Walkthrough' },
Expand Down
34 changes: 30 additions & 4 deletions lib/oli/resources/collaboration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -539,28 +539,36 @@ defmodule Oli.Resources.Collaboration do
{"popularity", :desc} ->
{:desc_nulls_last,
dynamic(
[_post, _sr, _spp, _pr, _rev, _user, replies, _read_replies],
[_post, _sr, _spp, _pr, _rev, _user, replies, _read_replies, _reactions],
replies.count
)}

{"popularity", :asc} ->
{:asc_nulls_first,
dynamic(
[_post, _sr, _spp, _pr, _rev, _user, replies, _read_replies],
[_post, _sr, _spp, _pr, _rev, _user, replies, _read_replies, _reactions],
replies.count
)}

{"date", sort_order} ->
{sort_order,
dynamic(
[post, _sr, _spp, _pr, _rev, _user, _replies, _read_replies],
[post, _sr, _spp, _pr, _rev, _user, _replies, _read_replies, _reactions],
post.updated_at
)}
end

results =
from(
post in Post,
join: sr in SectionResource,
on: sr.resource_id == post.resource_id and sr.section_id == post.section_id,
join: spp in SectionsProjectsPublications,
on: spp.section_id == post.section_id and spp.project_id == sr.project_id,
join: pr in PublishedResource,
on: pr.publication_id == spp.publication_id and pr.resource_id == post.resource_id,
join: rev in Revision,
on: rev.id == pr.revision_id,
join: user in User,
on: post.user_id == user.id,
left_join: replies in subquery(replies_subquery()),
Expand Down Expand Up @@ -633,6 +641,14 @@ defmodule Oli.Resources.Collaboration do
results =
from(
post in Post,
join: sr in SectionResource,
on: sr.resource_id == post.resource_id and sr.section_id == post.section_id,
join: spp in SectionsProjectsPublications,
on: spp.section_id == post.section_id and spp.project_id == sr.project_id,
join: pr in PublishedResource,
on: pr.publication_id == spp.publication_id and pr.resource_id == post.resource_id,
join: rev in Revision,
on: rev.id == pr.revision_id,
join: user in User,
on: post.user_id == user.id,
left_join: replies in subquery(replies_subquery()),
Expand All @@ -652,7 +668,8 @@ defmodule Oli.Resources.Collaboration do
post: %{
post
| replies_count: coalesce(replies.count, 0),
read_replies_count: coalesce(read_replies.count, 0)
read_replies_count: coalesce(read_replies.count, 0),
resource_slug: rev.slug
},
total_count: over(count(post.id))
}
Expand Down Expand Up @@ -1193,6 +1210,14 @@ defmodule Oli.Resources.Collaboration do
Repo.all(
from(
post in Post,
join: sr in SectionResource,
on: sr.resource_id == post.resource_id and sr.section_id == post.section_id,
join: spp in SectionsProjectsPublications,
on: spp.section_id == post.section_id and spp.project_id == sr.project_id,
join: pr in PublishedResource,
on: pr.publication_id == spp.publication_id and pr.resource_id == post.resource_id,
join: rev in Revision,
on: rev.id == pr.revision_id,
left_join: replies in subquery(replies_subquery()),
on: replies.thread_root_id == post.id,
left_join: read_replies in subquery(read_replies_subquery(user_id)),
Expand Down Expand Up @@ -1224,6 +1249,7 @@ defmodule Oli.Resources.Collaboration do
post
| replies_count: coalesce(replies.count, 0),
read_replies_count: coalesce(read_replies.count, 0),
resource_slug: rev.slug,
headline:
fragment(
"""
Expand Down
1 change: 1 addition & 0 deletions lib/oli/resources/collaboration/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ defmodule Oli.Resources.Collaboration.Post do
has_many :reactions, Oli.Resources.Collaboration.UserReactionPost

field :resource_type_id, :id, virtual: true
field :resource_slug, :id, virtual: true
field :replies_count, :integer, virtual: true
field :read_replies_count, :integer, virtual: true
field :is_read, :boolean, virtual: true
Expand Down
1 change: 1 addition & 0 deletions lib/oli/utils/purposes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule Oli.Utils.Purposes do
def label_for("learnbydoing"), do: "Learn by doing"
def label_for("learnmore"), do: "Learn More"
def label_for("manystudentswonder"), do: "Many students wonder"
def label_for("priorknowledgecheck"), do: "Prior Knowledge Check"
def label_for("quiz"), do: "Quiz"
def label_for("simulation"), do: "Simulation"
def label_for("walkthrough"), do: "Walkthrough"
Expand Down
48 changes: 3 additions & 45 deletions lib/oli_web/components/delivery/schedule.ex
Original file line number Diff line number Diff line change
Expand Up @@ -155,55 +155,13 @@ defmodule OliWeb.Components.Delivery.Schedule do
<% @purpose == :application -> %>
<Icons.exploration />
<% @graded && @progress == 100 -> %>
<<<<<<< HEAD <Icons.square_checked /> =======
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
class="fill-[#0caf61] group-[.past-start]:fill-[#89c8aa] dark:group-[.past-start]:fill-[#085c36]"
>
<path d="M5 21C4.45 21 3.97917 20.8042 3.5875 20.4125C3.19583 20.0208 3 19.55 3 19V5C3 4.45 3.19583 3.97917 3.5875 3.5875C3.97917 3.19583 4.45 3 5 3H17.925L15.925 5H5V19H19V12.05L21 10.05V19C21 19.55 20.8042 20.0208 20.4125 20.4125C20.0208 20.8042 19.55 21 19 21H5Z" />
<path d="M11.7 16.025L6 10.325L7.425 8.9L11.7 13.175L20.875 4L22.3 5.425L11.7 16.025Z" />
</svg>
>>>>>>> master
<Icons.square_checked />
<% @graded -> %>
<Icons.flag />
<% @progress == 100 -> %>
<<<<<<< HEAD <Icons.check progress={1.0} />
<Icons.check progress={1.0} />
<% true -> %>
<Icons.bullet /> =======
<svg
xmlns="http://www.w3.org/2000/svg"
width="25"
height="24"
viewBox="0 0 25 24"
fill="none"
role="completed check icon"
>
<path
d="M10.0496 17.9996L4.34961 12.2996L5.77461 10.8746L10.0496 15.1496L19.2246 5.97461L20.6496 7.39961L10.0496 17.9996Z"
class="fill-[#0caf61] group-[.past-start]:fill-[#89c8aa] dark:group-[.past-start]:fill-[#085c36]"
/>
</svg>
<% true -> %>
<svg
xmlns="http://www.w3.org/2000/svg"
class="m-2"
width="8"
height="8"
viewBox="0 0 8 8"
fill="none"
>
<circle
cx="4"
cy="4"
r="4"
class="fill-gray-700 dark:fill-white group-[.past-start]:fill-gray-400 dark:group-[.past-start]:fill-gray-700"
/>
</svg>
>>>>>>> master
<Icons.bullet />
<% end %>
</div>
"""
Expand Down
36 changes: 27 additions & 9 deletions lib/oli_web/live/delivery/student/discussions_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ defmodule OliWeb.Delivery.Student.DiscussionsLive do
}

def mount(_params, _session, socket) do
%{current_user: current_user, section: section} = socket.assigns

is_instructor = Sections.has_instructor_role?(current_user, section.slug)

if connected?(socket),
do:
Phoenix.PubSub.subscribe(
Expand Down Expand Up @@ -46,6 +50,7 @@ defmodule OliWeb.Delivery.Student.DiscussionsLive do
{
:ok,
assign(socket,
is_instructor: is_instructor,
active_tab: :discussions,
posts: posts,
notes: notes,
Expand Down Expand Up @@ -506,7 +511,9 @@ defmodule OliWeb.Delivery.Student.DiscussionsLive do
posts_search_results={@posts_search_results}
/>
<.notes_section
:if={not @is_instructor}
ctx={@ctx}
section_slug={@section.slug}
current_user={@current_user}
notes={@notes}
note_params={@note_params}
Expand Down Expand Up @@ -618,7 +625,7 @@ defmodule OliWeb.Delivery.Student.DiscussionsLive do
</h3>
</div>
<.actions
<.posts_actions
post_params={@post_params}
course_collab_space_config={@course_collab_space_config}
posts_search_term={@posts_search_term}
Expand Down Expand Up @@ -660,6 +667,7 @@ defmodule OliWeb.Delivery.Student.DiscussionsLive do

attr :notes, :list
attr :ctx, :map
attr :section_slug, :string
attr :current_user, :any
attr :note_params, :map
attr :more_notes_exist?, :boolean
Expand All @@ -682,7 +690,12 @@ defmodule OliWeb.Delivery.Student.DiscussionsLive do
<div role="notes list" class="w-full">
<%= for post <- @notes do %>
<div class="mb-3">
<Annotations.post class="bg-white" post={post} current_user={@ctx.user} />
<Annotations.post
class="bg-white"
post={post}
current_user={@ctx.user}
go_to_post_href={~p"/sections/#{@section_slug}/lesson/#{post.resource_slug}"}
/>
</div>
<% end %>
<div :if={@notes == []} class="flex p-4 text-center w-full">
Expand All @@ -704,7 +717,12 @@ defmodule OliWeb.Delivery.Student.DiscussionsLive do
</div>
<% results -> %>
<div role="search-results list" class="w-full">
<Annotations.search_results search_results={results} current_user={@current_user} />
<Annotations.search_results
section_slug={@section_slug}
search_results={results}
current_user={@current_user}
show_go_to_post_link={true}
/>
</div>
<% end %>
</section>
Expand All @@ -715,19 +733,19 @@ defmodule OliWeb.Delivery.Student.DiscussionsLive do
attr :course_collab_space_config, Oli.Resources.Collaboration.CollabSpaceConfig
attr :posts_search_term, :string

defp actions(assigns) do
defp posts_actions(assigns) do
~H"""
<div role="posts actions" class="w-full flex gap-6">
<div class="flex flex-1 space-x-3">
<div class="flex flex-1 space-x-3 justify-between">
<Annotations.search_box
class="flex-1"
class="flex-1 max-w-[600px]"
search_term={@posts_search_term}
on_search="search_posts"
on_clear_search="clear_search_posts"
/>
<.dropdown
id="sort-dropdown"
id="sort-posts-dropdown"
role="sort"
class="inline-flex"
button_class="rounded-[3px] py-[10px] px-6 flex justify-center items-center whitespace-nowrap text-[14px] leading-[20px] font-normal text-white bg-[#0F6CF5] hover:bg-blue-600"
Expand Down Expand Up @@ -777,9 +795,9 @@ defmodule OliWeb.Delivery.Student.DiscussionsLive do
defp notes_actions(assigns) do
~H"""
<div role="notes actions" class="w-full flex gap-6">
<div class="flex flex-1 space-x-3">
<div class="flex flex-1 space-x-3 justify-between">
<Annotations.search_box
class="flex-1"
class="flex-1 max-w-[600px]"
search_term={@notes_search_term}
on_search="search_notes"
on_clear_search="clear_search_notes"
Expand Down
Loading

0 comments on commit 76bec34

Please sign in to comment.