-
Notifications
You must be signed in to change notification settings - Fork 623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ?teach parameter to see instructor version of homepage regardless of user role (#5812) #5983
Draft
Abishekcs
wants to merge
4
commits into
WikiEducationFoundation:master
Choose a base branch
from
Abishekcs:feature/override-instructor-role
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+43
−7
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2a2cc48
feat: add `?teach` parameter to allow users to indicate instructor st…
Abishekcs 8badc9e
Undo some changes from "Previous commit message"
Abishekcs 84361b6
Implement ?teach parameter on homepage to render instructor view for …
Abishekcs 00818c4
Set user role to INSTRUCTOR upon completion of instructor orientation…
Abishekcs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ def create_or_update | |
return if @slide.nil? | ||
complete_slide if should_set_slide_completed? | ||
complete_module if last_slide? | ||
make_training_module_user_instructor if instructor_training_complete? | ||
@completed = @training_module_user.completed_at.present? | ||
render_slide | ||
end | ||
|
@@ -31,6 +32,38 @@ def mark_exercise_complete | |
|
||
private | ||
|
||
def instructor_training_complete? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feature should not be in the same PR. I'd prefer to first merge the simplest possible version that will address the issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay |
||
return false unless params[:library_id] == 'instructors' && last_slide? | ||
|
||
library = TrainingLibrary.find_by(slug: params[:library_id]) | ||
return false unless library | ||
|
||
library.categories.all? do |category| | ||
category_modules_complete?(category) | ||
end | ||
end | ||
|
||
def category_modules_complete?(category) | ||
category['modules'].all? do |mod| | ||
module_complete?(mod) | ||
end | ||
end | ||
|
||
def module_complete?(mod) | ||
training_module = TrainingModule.find_by(slug: mod['slug']) | ||
return false unless training_module | ||
|
||
progress_manager = ::TrainingProgressManager.new(current_user, training_module) | ||
progress_manager.assignment_status == 'Completed' | ||
end | ||
|
||
def make_training_module_user_instructor | ||
# Do not downgrade admins' permissions. | ||
return if @training_module_user.user.admin? | ||
|
||
@training_module_user.user.update(permissions: User::Permissions::INSTRUCTOR) | ||
end | ||
|
||
def set_training_module | ||
@training_module = TrainingModule.find_by(slug: params[:module_id]) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
- if @pres.can_create_course? | ||
= link_to course_creator_path, class: 'button dark dashboard-cta' do | ||
- if @pres.can_create_course? || @instructor_view | ||
= link_to course_creator_path, class: 'button dark dashboard-cta', style: 'margin-right: 10px;' do | ||
= t("courses.creator.create_short") | ||
%i.icon.icon-plus | ||
- elsif @pres.show_explore_button? | ||
= link_to explore_path, class: 'button dark dashboard-cta' do | ||
= t("courses.creator.find") | ||
%span.icon.icon-rt_arrow | ||
|
||
- if @pres.show_orientation_review? | ||
- if @pres.show_orientation_review? || @instructor_view | ||
= link_to @pres.orientation_path, class: 'button' do | ||
= t("dashboard.review_orientation") | ||
%i.icon.icon-rt_arrow_dark | ||
%i.icon.icon-rt_arrow_dark{ style: 'background-position: 0px 11px'} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the better way to handle this is inside the DashboardPresenter, by passing the 'teach' parameter to the presenter.
Using a separate instance variable makes it more complicated to get all the correct behaviors (such as showing the link to instructor orientation but not the create course button, if the user has not already completed that training module). With the presenter approach, I think there will be no changes needed in the view templates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I will make the required changes. Thank you for the review