-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add annotations overview page & improve Cypress commands (#668)
* Scaffold annotation overview page * Show all annotations in card list * Only show annotations of current user * Add links to annotations and fix empty comments * Fix annotation caching issue by fixing initialization This might fix #637 * Open annotation automatically on link click * Group annotations by lecture * Fix accordion header class naming * Link to blog when no annotation is created yet * Delete unnecessary whitespace * Localize text in annotation overview * Refactor annotations overview controller * Init view to see students annotations as teacher/editor * Use existing methods to grab media * Improve description of student annotations * Use links to feedback player for shared annotations * Use same bootstrap button for "Create annotation" * Only show students annotations if current user is teacher or editor * Fix grammar mistake * Refactor annotations overview controller * Refactor accordion label assignment * Color cards shared by students according to category * Rename js file to "url_annotation_opener" * Clarify color choices in user-facing text * Get rid of turbolinks:load and apply directly This is to avoid caching issues. * Fix initial state of accordion buttons * Show medium title and date * Expose MaMpf to another port to avoid clashing with dev * Add an endpoint to skip validation when creating factory * Use local file system also in test environment * Enable reloading in cypress tests * Wrap value in `createUserAndLogin` (cypress) * Init annotations factory for usage in cypress tests * Customize title of lectures/lessons * Test appearance of annotation overview cards * Use parameterized tests and test timestamp * Add back missing index variable in test * Test annotation border color * Add factorybot to known words * Add i18n retrieval in Cypress tests * Test annotation sections & improve i18n controller * Test student annotation cards & more properties of cards * Move annotation section test to the top * Move "grouped by lecture" test up * Test rendering of math content * Move overview controller to existing annotation controller (it is now called "index") * Move annotation-retrieval to user model * Move annotation_open_link to helper * Make extraction method private in controller Also removed the TODO note regarding nil values * Remove TODO note as "Won't be done" * Remove unnecessary long url helper calling * Pass in medium instead of medium id * Fix spelling mistake in media helper * Use link_to Rails helper * Don't use custom route name for annotations overview It is now just the "index" and the route is called "/annotations" * Sort according to lecture.updated_at * Extract "annotations by lecture" retrieval to own method This is to avoid duplicated code. * Add comment explaining transform keys * Rename partial view to index_accordion * Extract border color to helper method * Open annotations with video in new tab * Add number of annotations in accordion header * Add default title to lecture factory with_title * Fix ordering in cypress tests & sort according to creation date * Fix cypress tests when anchor link opens new tab * Fix ordering in math content test * Fix ordering and new tab in feedback video test * Fix border color test order * Change default cypress viewport dimensions * Place :index ability in other code block * Use params instead of manually constructing url * Use URI helper to construct annotation id link * Use flat_map instead of map(...).flatten
- Loading branch information
Showing
38 changed files
with
715 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
module.exports = { | ||
e2e: { | ||
// Add configuration here | ||
// Base URL is set via Docker environment variable | ||
viewportHeight: 1000, | ||
viewportWidth: 1400, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function colorAnnotationCardsSharedByStudents() { | ||
const annotationCards = $("[data-annotation-card-category]"); | ||
for (let card of annotationCards) { | ||
const category = card.dataset.annotationCardCategory; | ||
if (!category) { | ||
continue; | ||
} | ||
const color = Category.getByName(category).color; | ||
card.style.borderColor = color; | ||
} | ||
} | ||
|
||
colorAnnotationCardsSharedByStudents(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/assets/javascripts/thyme/annotations/url_annotation_opener.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
function openAnnotationIfSpecifiedInUrl() { | ||
const annotationValue = new URLSearchParams(window.location.search).get("ann"); | ||
if (!annotationValue) { | ||
return; | ||
} | ||
const annotationId = Number(annotationValue); | ||
thymeAttributes.annotationArea.showAnnotationWithId(annotationId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.subtle-background { | ||
background-image: linear-gradient(30deg, #fafdff 12%, transparent 12.5%, transparent 87%, #fafdff 87.5%, #fafdff), linear-gradient(150deg, #fafdff 12%, transparent 12.5%, transparent 87%, #fafdff 87.5%, #fafdff), linear-gradient(30deg, #fafdff 12%, transparent 12.5%, transparent 87%, #fafdff 87.5%, #fafdff), linear-gradient(150deg, #fafdff 12%, transparent 12.5%, transparent 87%, #fafdff 87.5%, #fafdff), linear-gradient(60deg, #fafdff77 25%, transparent 25.5%, transparent 75%, #fafdff77 75%, #fafdff77), linear-gradient(60deg, #fafdff77 25%, transparent 25.5%, transparent 75%, #fafdff77 75%, #fafdff77); | ||
background-size: 42px 74px; | ||
background-position: 0 0, 0 0, 21px 37px, 21px 37px, 0 0, 21px 37px; | ||
} | ||
|
||
.annotation-overview-item { | ||
border-width: 1.5px; | ||
cursor: pointer; | ||
transition: box-shadow 120ms cubic-bezier(0.33, 1, 0.68, 1); | ||
|
||
&:hover { | ||
box-shadow: rgba(0, 0, 0, 0.23) 1px 2px 8px -2px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Cypress | ||
# Allows to access i18n keys in Cypress tests. | ||
class I18nController < CypressController | ||
def create | ||
unless params[:i18n_key].is_a?(String) | ||
msg = "Argument `i18n_key` must be a string indicating the i18n key." | ||
msg += " But we got: '#{params[:i18n_key]}'" | ||
raise(ArgumentError, msg) | ||
end | ||
|
||
substitutions = {} | ||
if params[:substitutions].present? | ||
unless params[:substitutions].is_a?(Hash) | ||
msg = "Argument `substitution` must be a hash indicating the substitutions." | ||
msg += " But we got: '#{params[:substitutions]}'" | ||
raise(ArgumentError, msg) | ||
end | ||
substitutions = params[:substitutions].to_unsafe_hash.symbolize_keys | ||
end | ||
|
||
i18n_key = params[:i18n_key] | ||
|
||
render json: I18n.t(i18n_key, **substitutions), status: :created | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require "uri" | ||
|
||
module AnnotationsHelper | ||
def annotation_open_link(annotation, is_shared) | ||
link = if is_shared | ||
feedback_video_link_timed(annotation.medium_id, annotation.timestamp) | ||
else | ||
video_link_timed(annotation.medium_id, annotation.timestamp) | ||
end | ||
link = URI.parse(link) | ||
link.query = link.query.present? ? "#{link.query}&ann=#{annotation.id}" : "ann=#{annotation.id}" | ||
link.to_s | ||
end | ||
|
||
def annotation_index_border_color(annotation, is_student_annotation) | ||
# The border color of annotation cards shared by students, will be set | ||
# via JS according to the color of the annotation CATEGORY. | ||
return "" if is_student_annotation | ||
|
||
"border-color: #{annotation[:color]}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.