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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions modules/help_editor/ajax/help.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,30 @@
include_once "helpfile.class.inc";

if (!empty($moduleName)) {
$helpID = \LORIS\help_editor\HelpFile::hashToID(
md5($subpageName ?? $moduleName)
);
}
try {
$helpID = \LORIS\help_editor\HelpFile::hashToID(
md5($subpageName ?? $moduleName)
);
$help_file = \LORIS\help_editor\HelpFile::factory($helpID);
$data = $help_file->toArray();
} catch (\NotFound $e) {
zaliqarosli marked this conversation as resolved.
Show resolved Hide resolved
// Send data with empty strings so that the content can be edited
$data = [
'content' => '',
'topic' => '',
'updated' => ''
];
}

$help_file = \LORIS\help_editor\HelpFile::factory($helpID);
$data = $help_file->toArray();
$data['content'] = trim($data['content']);
$data['content'] = trim($data['content']);

if (empty($data['updated'])) {
$data['updated'] = "-";
// if document was never updated should display date created
if (!empty($data['created'])) {
$data['updated'] = $data['created'];
if (empty($data['updated'])) {
// if document was never updated should display date created
if (!empty($data['created']) && isset($data['created'])) {
$data['updated'] = $data['created'];
} else {
$data['updated'] = "-";
}
}
}
print json_encode($data);
Expand Down
7 changes: 5 additions & 2 deletions modules/help_editor/help/help_editor.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Help Editor

This module displays existing help content for LORIS modules and pages.
This module displays existing help content for LORIS instrument pages.

Use the *Selection Filter* section to search by Topic or Content keywords.

Click on the blue link in any *Topic* or *Parent Topic* column to edit the content within. Make your edits within the Edit Help Content page, and click **Save**.
Click on the blue link in any *Topic* or *Parent Topic* column to edit the content within. Make your edits within the Edit Help Content page, and click **Save**.

To add new help content for an instrument, navigate to the instrument's page from any candidate and any session. Click on the `?` icon in the navigation bar at the top
of the page. In the help pop-up box, click the `Edit` button. This will take you to the *Edit Help Content* page where you can save help content for that instrument.
20 changes: 14 additions & 6 deletions modules/help_editor/php/edit_help_content.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,22 @@ class Edit_Help_Content extends \NDB_Form
$parentID = htmlspecialchars($_GET['parentID']);
}
if (!empty($_REQUEST['section'])) {
$helpID = HelpFile::hashToID(md5($_REQUEST['section']));
try {
$helpID = HelpFile::hashToID(md5($_REQUEST['section']));
} catch (\NotFound $e) {
$helpID = '';
}
}
if (!empty($_REQUEST['section'])
&& $_REQUEST['subsection'] != 'undefined'
) {
$helpID = HelpFile::hashToID(md5($_REQUEST['subsection']));
$parentID = HelpFile::hashToID(md5($_GET['section']));
try {
$helpID = HelpFile::hashToID(md5($_REQUEST['subsection']));
$parentID = HelpFile::hashToID(md5($_GET['section']));
} catch (\NotFound $e) {
$helpID = '';
$parentID = '';
}
}
$this->tpl_data['section'] = $safeSection;
$this->tpl_data['subsection'] = $safeSubsection;
Expand Down Expand Up @@ -128,11 +137,10 @@ class Edit_Help_Content extends \NDB_Form
$this->addBasicTextArea(
'content',
'Content',
[],
array(
[
'cols' => 140,
'rows' => 30,
)
]
);

}
Expand Down
2 changes: 2 additions & 0 deletions php/libraries/NDB_BVL_Instrument.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ abstract class NDB_BVL_Instrument extends NDB_Page
$obj->displayAllFields = true;
}

// Set page name to testName
$obj->name = $instrument;
zaliqarosli marked this conversation as resolved.
Show resolved Hide resolved
// Sets up page variables such as $this->commentID and $this->form
$obj->setup($commentID, $page);

Expand Down
1 change: 1 addition & 0 deletions raisinbread/RB_files/RB_help.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE TABLE `help`;
LOCK TABLES `help` WRITE;
INSERT INTO `help` (`helpID`, `hash`, `topic`, `content`, `created`, `updated`) VALUES (123,'810dc6911c825b55eff684098f2beb19','bmi','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.','2020-09-01 01:03:09',NULL);
UNLOCK TABLES;
SET FOREIGN_KEY_CHECKS=1;