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

[Raisinbread] Fixing help_editor module to display RB instrument instructions #6907

Merged

Conversation

AlexandraLivadas
Copy link
Contributor

@AlexandraLivadas AlexandraLivadas commented Aug 12, 2020

Edited
This PR aimed to add data to the help table in Raisinbread so that the data would generate in the Help Editor module. This will allow the Help Editor module to be manually tested.

It was found that there is a bug in this module that causes it not to save/display this information. This issue is resolved in this PR.

Here is a screenshot of the Help Editor module with the new data:
Screen Shot 2020-08-12 at 6 11 24 PM

Testing instructions (if applicable)

With a fresh RB install:

  1. Navigate to Help Editor in the frontend and see that data loads for instructions for the BMI instrument.

Link to related issue

@AlexandraLivadas AlexandraLivadas added the RaisinBread PR or issue introducing/requiring improvements to the Raidinbread dataset label Aug 12, 2020
@christinerogers
Copy link
Contributor

great, can you also comment in one line on whether the help editor seems to work in terms of editing help text?

@AlexandraLivadas
Copy link
Contributor Author

AlexandraLivadas commented Aug 14, 2020

@christinerogers The Help Editor does not correctly save changes made in the frontend to the file contents. I made changes and hit Save. The changes displayed correctly but once I hit Return to Help Editor or navigated back to the main page myself, the changes were actually not saved.

Another issue is that the button Return to Help Editor does not actually return me to the main Help Editor page. Instead, I stayed on the editing content page and the changes I made were not saved.

Copy link
Contributor

@christinerogers christinerogers left a comment

Choose a reason for hiding this comment

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

Hi Alex, see my comment below, the topic column is probably trying to match a valid test name value.
Can you dig further into the code to find out?

Dave's question on the issue here isn't actually addressed until we know that part.

@ridz1208 -- care to review otherwise?

@@ -1,5 +1,6 @@
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE TABLE `help`;
LOCK TABLES `help` WRITE;
INSERT INTO `help` (`helpID`, `parentID`, `hash`, `topic`, `content`, `created`, `updated`) VALUES (123,12,'hash','BMI Instructions','The BMI calculator instrument can calculate the BMI and BMI Classification of a visitor. The two required fields for this instrument are the Date of Administration of the instrument and the Examiner name. The height and weight of the visitor must then be entered in either standard or metric units. The instrument will not accept an entry where the height and weight are given in both units. After this information is given, the instrument will calculate the BMI and BMI Classification of the visitor.',NULL,NULL);
Copy link
Contributor

@christinerogers christinerogers Aug 27, 2020

Choose a reason for hiding this comment

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

Alex, since this doesn't actually render for the BMI -- per your comment here
I think it might be because of the value in the topic column. If you change this to bmi (which i think would be the relevant test_name value for this instrument) -- what happens?

Could you also take another step here towards resolving it by verifying in the code how the Help display/dropdown actually trying to locate relevant help text? If it's not trying to match the topic column against a valid test_name value -- then what is it trying to match/look for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I can definitely look into this :)

Copy link
Contributor Author

@AlexandraLivadas AlexandraLivadas Aug 27, 2020

Choose a reason for hiding this comment

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

@christinerogers @driusan So after some digging:
The help file is handled by helpHandler.js. This then calls the modules/help_editor/ajax/help.php file with a GET request.

In THAT file, it first tries to render the help file by either using the module name (which is given by the request parameter testName or using the subtest parameter (in this case "bmi" or "aosi"). If it's not a module, it instead tries to load data from the help table using the request parameter subtest as the identifier. But when I went to an instrument data entry page and used the Developer Tool, I saw that when the GET request is sent to help.php, it only provides the testName parameter in the request and doesn't provide a subtest value, so it never checks if there's a file in the help table and instead just looks for the markdown help file for the Instruments module.

Let me know if this makes sense, I can explain it in more detail if necessary. I don't know how to fix this as of now. I can keep looking to see how to edit the GET request to provide the subtest parameter, but I haven't figured out where to do that yet.

@ridz1208
Copy link
Collaborator

ridz1208 commented Sep 1, 2020

@zaliqarosli can you team up with @AlexandraLivadas to figure out what is happening in this module ?

our options would be to either fix it if it doesnt work as intended or remove the module entirely

@zaliqarosli
Copy link
Contributor

@ridz1208 yeah sure @AlexandraLivadas wanna slack me or get on a call to explain what's going on?

@ridz1208
Copy link
Collaborator

ridz1208 commented Sep 9, 2020

@zaliqarosli @AlexandraLivadas have you guys firgured it out ? is it working for bmi specifically now ?

@ridz1208
Copy link
Collaborator

ridz1208 commented Sep 9, 2020

fixes #5691

@zaliqarosli
Copy link
Contributor

@ridz1208 yeah i fixed it - sent a PR to this PR branch. @AlexandraLivadas can you merge the changes?

@@ -1,5 +1,3 @@
import swal from 'sweetalert2';
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this downgrading from swal2 to swal1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When @zaliqarosli was making the changes, she said that this statement threw an error. However, when I added this line back on my local version, I did not get the same error. I'm not sure why this was causing issues for her but not me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it should be downgraded.

Copy link
Contributor

@zaliqarosli zaliqarosli Sep 21, 2020

Choose a reason for hiding this comment

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

undoing the changes on this file is still giving me the error:

Screen Shot 2020-09-21 at 1 16 02 PM

@laemtl also reported seeing this error in #6940. (Laetitia, any chance you could give this PR a test, with and without these changes to this file?)

this PR as is fixes all issues. @driusan @HenriRabalais @maltheism any of you know how to properly fix this without downgrading to swal1?

Copy link
Contributor

@laemtl laemtl Sep 21, 2020

Choose a reason for hiding this comment

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

Yes sure! I'm also working on #7018 so it might be helpful to fix this problem with swal.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I understand why the file can't just be moved from the js directory to jsx and added to the webpack config so that webpack compiles it and it can use swal2?

Copy link
Contributor

@laemtl laemtl Sep 21, 2020

Choose a reason for hiding this comment

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

@driusan Eslint fails with /var/www/html/loris/modules/help_editor/jsx/help_editor_helper.js
33:13 error A function with a name starting with an uppercase letter should only be used as a constructor new-cap

markdownContent = document.createElement('div');
ReactDOM.render(
       RMarkdown({content: content}),
       markdownContent
);

I pushed a commit which fixes the pb with the fix found here which changes the eslint rules.

Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't it be kind of against our repo standard that we're calling a non-react non-jsx file a jsx file and putting it under that directory? help_editor_helper.js isn't a component and doesn't need to be compiled. there's a way to call sweetalert2 with normal JS:

Screen Shot 2020-09-21 at 5 37 34 PM

but using require() also throws an error. surely just making the file a jsx file isn't the right move?

Copy link
Member

@maltheism maltheism Sep 21, 2020

Choose a reason for hiding this comment

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

@zaliqarosli nodejs, browserify, or webpack supports require() but not javascript on the browser. The browser shouldn't have access to node_modules on the server anyways.

I think it's not great that we cannot use import in the js directory as well. It would be nice to keep helper code away from the component directory. Although, I do like the thought of js directory just having compiled js code from jsx with nothing else.

Copy link
Contributor

@laemtl laemtl Sep 22, 2020

Choose a reason for hiding this comment

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

@zaliqarosli You are right, I migrated my fix to #7018. I'm not sure the way I tackled it is the best. I kind of agree that it is weird to have this file under jsx/. I wonder if reactifying it should be preferable? Isn't the plan to completely remove the jQuery dependencies in the future?

@zaliqarosli zaliqarosli added Discussion Required PR or issue awaiting the resolution of a discussion between all involved parties UI PR or issue introducing/requiring improvements to the LORIS User Interface Bug PR or issue introducing/requiring bug fixes (not mutually exclusive with the Feature label) labels Sep 21, 2020
@laemtl laemtl force-pushed the 2020-08-12-addDataForHelpEditor branch 4 times, most recently from 7ce172c to bca66c8 Compare September 22, 2020 02:31
@zaliqarosli zaliqarosli removed Needs Work PR awaiting additional changes by the author or contains issues that the author needs to fix Passed Manual Tests PR has undergone proper testing by at least one peer labels Jul 5, 2021
@zaliqarosli
Copy link
Contributor

is discussion still required here?

@AlexandraLivadas
Copy link
Contributor Author

@zaliqarosli No, I don't think so. I think this was approved a while ago and just needed to be tested and reviewed again on the 23.0 branch

@zaliqarosli zaliqarosli removed the Discussion Required PR or issue awaiting the resolution of a discussion between all involved parties label Jul 5, 2021
Copy link
Contributor

@zaliqarosli zaliqarosli left a comment

Choose a reason for hiding this comment

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

everything else looks good. just wondering about one leftover comment. i am happy to approve this PR as is though

modules/help_editor/ajax/help.php Show resolved Hide resolved
@zaliqarosli
Copy link
Contributor

could someone test this? i'm having trouble with my dev VM. @jstirling91 would you be interested?

Copy link
Contributor

@zaliqarosli zaliqarosli left a comment

Choose a reason for hiding this comment

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

everything else looks good! will test now

modules/help_editor/ajax/help.php Outdated Show resolved Hide resolved
Co-authored-by: Zaliqa <zaliqa.rosli@mcin.ca>
@zaliqarosli
Copy link
Contributor

@AlexandraLivadas any chance you could edit the help_editor .md help file to say "This module displays existing help content for LORIS instrument pages" instead of what's there?

Screen Shot 2021-07-06 at 11 46 37 AM

@ridz1208
Copy link
Collaborator

ridz1208 commented Jul 6, 2021

@driusan this one is in your hands, it's going to 23 since it's a bugfix requested by IBIS

Copy link
Contributor

@zaliqarosli zaliqarosli left a comment

Choose a reason for hiding this comment

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

LGTM!!

@zaliqarosli zaliqarosli added the Passed Manual Tests PR has undergone proper testing by at least one peer label Jul 6, 2021
@ridz1208
Copy link
Collaborator

ridz1208 commented Jul 8, 2021

@driusan i think this one is yours as well

Copy link
Contributor

@zaliqarosli zaliqarosli left a comment

Choose a reason for hiding this comment

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

ill approve again since the last commit. also retested

@driusan driusan merged commit 92d8b80 into aces:23.0-release Jul 12, 2021
@driusan driusan added this to the 23.0.5 milestone Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug PR or issue introducing/requiring bug fixes (not mutually exclusive with the Feature label) Passed Manual Tests PR has undergone proper testing by at least one peer RaisinBread PR or issue introducing/requiring improvements to the Raidinbread dataset UI PR or issue introducing/requiring improvements to the LORIS User Interface
Projects
None yet
8 participants