Skip to content
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

Converts LTI views to React #1415

Merged

Conversation

cayb0rg
Copy link
Contributor

@cayb0rg cayb0rg commented Nov 8, 2022

Changes

  • Converts LTI views to React
  • Removes jquery from test_provider and test_learner pages
  • Updates deprecated assertContains to assertContainsEquals in test functions

Copy link
Member

@clpetersonucf clpetersonucf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some high level design comments:

  • It looks like you're trying to re-implement get_owners and request_access in the v1 API, but those API requests actually already exist - they're just not in v1. I know, it's confusing. post_request_access is a method in fuel/app/classes/controller/api/instance.php. The API in Materia is currently not great: older API requests are in v1, and newer API requests are in their respective API controller. It's something that has to be rebuilt from the ground up in the future python rewrite. get_owners probably isn't even required, the ownership is assessed in the LTI preview controller, and we're better off emitting that flag to the window like other JS constants in other React views.
  • Generally, try and avoid making changes to any of the old (or creating new) stylesheets in src/css. My goal is to kill these completely, and implement CSS in one of two places: a common stylesheet (include.scss) in the components directory, or a component-specific stylesheet in that same directory. With several LTI components making use of similar styles, it'd probably make sense for them all to inherit the same stylesheet.
  • I noticed you made a change to the post_login.php partial under themes/default/lti/partials. That's also part of the deprecated file structure, as those views are all being removed. Anything you're changing there should be changed in the corresponding components instead. The individual React views and their components are replacing the old PHP partials.

@clpetersonucf
Copy link
Member

Updated with changes to the main react branch. Something I'm noticing: the LTI picker isn't loading any widgets, which I suspect is due to pagination in the widget_paginate_instances_get, but haven't looked at it in detail.

Copy link
Member

@clpetersonucf clpetersonucf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff is looking better, but I left some additional feedback items below.

The test suite is failing consistently:

There was 1 failure:

1) Test_Api_V1::test_widget_instance_lock_for_another_user
Failed asserting that false is true.

/var/www/html/fuel/app/tests/api/v1.php:496

The only other thing I'm noticing is that attempting to test LTI Assignment Launch in the test provider yields the message LTI Assignment URL can not be blank! even when the the assignment URL is populated.

@@ -1185,4 +1185,28 @@ static private function _get_instance_for_play_id($play_id)
if ( ! ($inst = Widget_Instance_Manager::get($inst_id))) throw new \HttpNotFoundException;
return $inst;
}

// Sends a notification to user requesting access to instance
static public function request_access(string $inst_id, int $owner_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API call is unnecessary, newer API endpoints are in the API controllers. post_request_access is in fuel/app/classes/controller/api/instance.php.

\Css::push_group(['core', 'lti']);

if ($is_selector_mode && ! empty($return_url))
{
\Js::push_inline('var RETURN_URL = "'.$return_url.'"');
}
$this->insert_analytics();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would double-check that these are necessary: insert_analytics is in the commoncontrollertemplate trait, so it may already be included.

src/util/api.js Outdated

// Request access to widget
export const apiRequestAccess = (instId, ownerId) => {
return fetch('/api/json/request_access', fetchOptions({ body: `data=${formatFetchBody([instId, ownerId])}` }))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll have to update this endpoint to api/instance/request_access to switch over from the api/v1 gateway to the instance API controller. You can look at other api/instance (or any other request besides api/json/...) to see if anything else has to be restructured for the request.

@clpetersonucf
Copy link
Member

The only other thing I'm noticing is that attempting to test LTI Assignment Launch in the test provider yields the message LTI Assignment URL can not be blank! even when the the assignment URL is populated.

Update: this is probably because the test provider was relying on jquery for basic functionality, which is no longer bundled with Materia. We can probably update the page to use a CDN link for jQuery. I'd rather not bundle it with Materia's JS and CSS assets.

@clpetersonucf clpetersonucf added the React Branch Related to the React rewrite for Materia label Mar 22, 2023
Copy link
Contributor

@FrenjaminBanklin FrenjaminBanklin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the LTI-relevant XML files got caught up in sweeping deletions, but those should probably be restored.

There are a few spots I noticed that could use some cleanup re: extraneous white space and removing anything left over from debugging.

The LTI test provider's behavior seems a bit unpredictable, but I haven't really been able to nail down a pattern. Buttons that should be sending requests with bad OAuth signatures appear not to be causing any problems when they probably should, for example. Since so much is being changed, this may also be a good time to add the means to make additional checks - loading a widget as an instructor who does not own it, loading a widget in guest mode, loading an unknown assignment, etc.

Also, though it's minor, it looks like the course navigation screen's appearance is different. The two columns should be taking up the same amount of vertical space, but one is taller than the other.

@@ -145,6 +145,7 @@ static public function get_widget_score_distribution($inst_id)

// we have to post process this query O(n)
$semesters = [];
\Log::Error(count($result));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug leftovers?


$this->insert_analytics();
$instance_owner_list = $current_user_owns ? [] : (array_map(function ($object)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to clean up any trailing whitespace.

$this->theme->set_partial('content', 'partials/select_item');
$this->theme->set_partial('header', 'partials/header_empty');
$this->insert_analytics();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to clean up any trailing whitespace.

$this->theme->get_template()
->set('title', 'Widget Connected Successfully')
->set('page_type', 'preview');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to clean up any trailing whitespace.

@@ -1564,4 +1569,4 @@ protected function assert_validation_error_message($msg)
$this->assertInstanceOf('\Materia\Msg', $msg);
$this->assertEquals('Validation Error', $msg->title);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing new line is good practice.


let sectionRender = null
if (displayState == 'selectInstance') {
sectionRender =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to clean up trailing whitespace.

// redirect the client to the return url with our new variables
window.location = `${window.RETURN_URL}${separator}embed_type=basic_lti&url=${url}`
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to clean up trailing whitespace.

let pgSpan = document.querySelector('.progress-container span')
pg.classList.add('success')
pgSpan.innerText = 'Success!'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to clean up trailing whitespace.

const { data, isFetching: isFetching, refetch: refetchInstances} = useQuery({
queryKey: 'instances',
queryFn: () => apiGetWidgetInstances(state.page),
staleTime: Infinity,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to clean up trailing whitespace.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it's still being loaded as part of the on_score_updated_event LTI event. Is it being replaced with something? If not, restore this file.

Copy link
Member

@clpetersonucf clpetersonucf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good. The new components should be styled to match the new design language, but I can take care of that on the base react branch. I don't see any obvious red flags, and the bad oauth signature validation issue is also present on master, having to do with PHP short open tags on the dynamically generated forms.

…tch react design language. A few random fixes and tweaks.
@clpetersonucf clpetersonucf merged commit dfb116c into ucfopen:issue/support-dashboard-in-react Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
React Branch Related to the React rewrite for Materia
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants