-
Notifications
You must be signed in to change notification settings - Fork 173
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
[Survey module] Make public module #3609
Conversation
…roll to top on next and prev
…tatic fields diplay values if present
@@ -0,0 +1,60 @@ | |||
<?php | |||
/** | |||
* Implements the main LORIS user login page to handle authentication |
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.
This comment and the one below should be updated
static function formatElement($element, $elName) | ||
{ | ||
$tempElement = array( | ||
"Type" => $element['type'], |
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.
How do you make sure the key 'type' exists in the array?
Is the function intended to "eat" LorisFormElement
?
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.
Yeah, this class is designed so that it could hypothetically replace the current way we convert the instrument to JSON for the API. The inputted element is expected to be in the format outputted by LorisForm which as far as I know always has the type set.
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.
Could you type hint $element
to \LorisFormElement
?
|
||
} | ||
|
||
?> |
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.
remove that line please.
*/ | ||
function getReactReview() | ||
{ | ||
$DB = Database::singleton(); |
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.
Please use NDB_Factory->database()
import Page from './DirectEntryForm'; | ||
|
||
/*eslint-disable */ | ||
class DirectEntry extends React.Component { |
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.
The indentation should be 2 spaces
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.
2 spaces is only used to reduce size of javascript files. Since this is compiled into a minified file I feel like 4 spaces is better suited as it aligns with our standards for php along with making this file easier to read
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.
But 4 spaces do not align with our JSX standard and make files harder to read
// Since the Instrument data is set when the component is | ||
// mounted we want to display nothing until it has been set | ||
return ( | ||
<div></div> |
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.
A loading span would be nice.
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 am making a Loader
Component I hope to make a pull request for soon.
</div> | ||
) | ||
} | ||
} |
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.
please add proptypes so that reviewData is described properly.
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.
Default props would also be useful.
render() { | ||
|
||
let questions = this.props.reviewData.questions.map((element) => { | ||
console.log(element); |
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.
this can be removed
let questions = this.props.reviewData.questions.map((element) => { | ||
console.log(element); | ||
return ( | ||
<tr className='reviewPage'> |
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.
missing key prop
|
||
componentWillMount() { | ||
|
||
$.ajax({ |
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.
This should be done in ComponentDidMount because ComponentWillMoiunt is done just before the first render and this.setState might not trigger a second rendering whit the new state. Otherwise, the method name is now UNSAFE_componentWillMount()
* @license Loris license | ||
* @link https://www.github.com/aces/Loris/ | ||
*/ | ||
class DirectDataEntryMainPage |
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.
htdocs/survey.php still exists
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.
Need some clarifications and changes.
|
||
unset($Values['CommentID']); | ||
unset($Values['UserID']); | ||
// unset($Values['Testdate']); |
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.
Is this meant to be un-commented eventually, or should it be removed?
|
||
$this->tpl_data['Values'] = json_encode($Values); | ||
|
||
echo json_encode($this->tpl_data); |
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.
Since the entirety of $this->tpl_data
is being json_encoded, is the json_encode on 129
necessary? I believe json_encode works recursively.
dataType: 'json', | ||
success: function(data) { | ||
const InstrumentJSON = JSON.parse(data.InstrumentJSON); | ||
const Values = JSON.parse(data.Values); |
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.
Should these be parsed? Are they not already encoded before being returned by the ajax call and therefore already in the proper format to be set as JSON objects?
// Since the Instrument data is set when the component is | ||
// mounted we want to display nothing until it has been set | ||
return ( | ||
<div></div> |
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 am making a Loader
Component I hope to make a pull request for soon.
class ReviewPage extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
} |
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.
If no functions need to be bound or state's set, then the constructor can be removed.
</div> | ||
) | ||
} | ||
} |
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.
Default props would also be useful.
/** | ||
* This is used by the Loris survey module to retrieve the email | ||
* template for the current instrument. It is used in the survey_accounts | ||
* page via AJAX to update the email template with the current page |
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.
missing ending dot
|
||
/** | ||
* Handles a request by delegating to the appropriate | ||
* handle method |
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.
should have an ending dot to stay consistant with other comments
$values = array(); | ||
|
||
foreach ($temp->questions as $value) { | ||
// $this->form->directValues[$value->SourceField] = $value->response; |
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.
To be deleted?
/** | ||
* This file contains React component for Direct Data Entry | ||
* | ||
* @author Jordan Stirling (StiringApps ltd.) |
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'm not sure about advertising in the codebase... but in any case you've got a typo here 😸
@jstirling91 in general we are trying to use return type declarations for new PHP code. Would you be able to add these to your function signatures? Should be quick. given that they're already documented with return types. |
@driusan @ridz1208 |
@zaliqarosli lets talk about this one |
This needs to be discussed with Dave, Rida, Tom Beaudry. |
Had a meeting with @driusan @thomasbeaudry & @driusan regarding how to handle this PR; |
See related Issue for status of this |
This pull request creates a public module structure for the survey module. It redesigns the old version to use React using API like calls to retrieve, partially save and validate forms.