diff --git a/modules/help_editor/ajax/help.php b/modules/help_editor/ajax/help.php index ece254af0db..43d29112048 100644 --- a/modules/help_editor/ajax/help.php +++ b/modules/help_editor/ajax/help.php @@ -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) { + // 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); diff --git a/modules/help_editor/help/help_editor.md b/modules/help_editor/help/help_editor.md index 242f87e183d..14824172f64 100644 --- a/modules/help_editor/help/help_editor.md +++ b/modules/help_editor/help/help_editor.md @@ -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. diff --git a/modules/help_editor/php/edit_help_content.class.inc b/modules/help_editor/php/edit_help_content.class.inc index b4d726d6b02..b45d5b12f1b 100644 --- a/modules/help_editor/php/edit_help_content.class.inc +++ b/modules/help_editor/php/edit_help_content.class.inc @@ -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; @@ -128,11 +137,10 @@ class Edit_Help_Content extends \NDB_Form $this->addBasicTextArea( 'content', 'Content', - [], - array( + [ 'cols' => 140, 'rows' => 30, - ) + ] ); } diff --git a/php/libraries/NDB_BVL_Instrument.class.inc b/php/libraries/NDB_BVL_Instrument.class.inc index 2be6ddf4979..39d244cea8f 100644 --- a/php/libraries/NDB_BVL_Instrument.class.inc +++ b/php/libraries/NDB_BVL_Instrument.class.inc @@ -275,6 +275,8 @@ abstract class NDB_BVL_Instrument extends NDB_Page $obj->displayAllFields = true; } + // Set page name to testName + $obj->name = $instrument; // Sets up page variables such as $this->commentID and $this->form $obj->setup($commentID, $page); diff --git a/raisinbread/RB_files/RB_help.sql b/raisinbread/RB_files/RB_help.sql index 28b5f0e222c..241bfa5dcc8 100644 --- a/raisinbread/RB_files/RB_help.sql +++ b/raisinbread/RB_files/RB_help.sql @@ -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;