-
Notifications
You must be signed in to change notification settings - Fork 32
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
feature: add support of 'list' type #300
feature: add support of 'list' type #300
Conversation
* | ||
* Copyright (c) 2013-2020 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); | ||
* | ||
* @author Jérôme Bogaerts <jerome@taotesting.com> |
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 pretty sure he is not the author of this class ;)
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 I write myself?
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Copyright (c) 2013-2020 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
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.
* Copyright (c) 2013-2020 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); | |
* Copyright (c) 2021 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); | |
* | ||
* @param string $type | ||
*/ | ||
private function setBaseType(string $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.
I think both set
methods can be removed as they don't provide any extra logic before assigning the value to the attribute. Wdyt?
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.
Yes, I've removed it
@@ -201,14 +202,32 @@ public function unmarshall($json) | |||
|
|||
if (isset($v['base']) || (array_key_exists('base', $v) && $v['base'] === null)) { | |||
$unit = ['base' => $v['base']]; | |||
$unmarshallItem = $this->unmarshallUnit($unit); | |||
} elseif (isset($v['list']) || (array_key_exists('list', $v) && $v['list'] === null)) { |
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 the right side of the condition (array_key_exists('list', $v) && $v['list'] === null)
makes sense for this context. I think the else
condition is enough in this case.
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.
You mean, we can leave only check on isset
there?
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.
$arr = [];
$arr['key'] = null;
isset($arr['key']) //false
but at the right condition will be true in this keys
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, I was in a hurry, @quintanilhar, you were right here, in this context the first condition is enough
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.
yes @Businesspunk, that's the idea.
$listNewItems = []; | ||
|
||
$baseType = key($list); | ||
$listItems = $list[$baseType]; |
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.
Consider removing this variable and using $list[$baseType]
in the foreach to avoid creating another variable to hold the result "$listNewItems"
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.
You mean that I have to use only $listItems
variable, without creation $listNewItems
?
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.
You can use, you're declaring $listItems
just to use in the foreach
and then you have another variable $listNewItems
, the "new" part sounds a bit weird. So that my proposal is to get rid of the variable $listNewItems
.
$this::assertTrue($list4->equals($list5)); | ||
} | ||
|
||
public function testToString() |
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.
public function testToString() | |
public function testConvertsToString() | |
|
||
class ListTest extends QtiSmTestCase | ||
{ | ||
public function testEquality() |
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.
Consider creating 2 tests for the different outputs:
testReturnsTrueWhenListIsEqualTo
testReturnsFalseWhenListIsDifferent
f53cbc4
to
57d3aad
Compare
57d3aad
to
9b9debc
Compare
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.
- New code is covered by tests (if applicable)
- Tests are running successfully (old and new ones) on my local machine (if applicable)
- New code is respecting code style rules
- New code is respecting best practices
- New code is not subject to concurrency issues (if applicable)
- Feature is working correctly on my local machine (if applicable)
- Acceptance criteria are respected
- Pull request title and description are meaningful
- Pull request's target is not
master
- Commits are following conventional commits
- Changelog is updated according to changes (if applicable)
- Documentation is updated according to changes (if applicable)
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 think you'll need the counterpart in src/qtism/pci/json/Marshaller.php
* @license GPLv2 | ||
*/ | ||
|
||
namespace qtism\common\datatypes; |
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 understand why you do it this way, but it makes it look like QtiList is a base type. Well, maybe we can do it this way for the sake of simplification, but at least, mention that it's a convenience and kept in qtism/common/datatype for the sake of simplicity.
423ab79
to
0c67545
Compare
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, extract the existing implementation to a new method and use it in the record list parsing.
@@ -375,4 +375,29 @@ public function unmarshallInvalidProvider() | |||
['{ "record" : [ { "namez" } ] '], | |||
]; | |||
} | |||
|
|||
public function testUnmarshallListType() |
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.
public function testUnmarshallListType() | |
public function testUnmarshallListWithinRecord() |
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.
- New code is covered by tests (if applicable)
- Tests are running successfully (old and new ones) on my local machine (if applicable)
- New code is respecting code style rules
- New code is respecting best practices
- New code is not subject to concurrency issues (if applicable)
- Feature is working correctly on my local machine (if applicable)
- Acceptance criteria are respected
- Pull request title and description are meaningful
- Pull request's target is not
master
- Commits are following conventional commits
- Changelog is updated according to changes (if applicable)
- Documentation is updated according to changes (if applicable)
bf9f207
to
64f4e91
Compare
* | ||
* @param array $parsedJson | ||
* @return MultipleContainer | ||
* @throws FileManagerException |
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 think this exception is not thrown here. Can you confirm, please?
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 type in 'list' will be file it can be
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.
unmarshallFile will be called, which can throw this exception
64f4e91
to
947ccb5
Compare
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.
- New code is covered by tests (if applicable)
- Tests are running successfully (old and new ones) on my local machine (if applicable)
- New code is respecting code style rules
- New code is respecting best practices
- New code is not subject to concurrency issues (if applicable)
- Feature is working correctly on my local machine (if applicable)
- Acceptance criteria are respected
- Pull request title and description are meaningful
- Pull request's target is not
master
- Commits are following conventional commits
- Commits messages are meaningful
- Commits are atomic
- Changelog is updated according to changes (if applicable)
- Documentation is updated according to changes (if applicable)
TR-1351
Have added support of 'list' type and fix incorrect response in case of 'list' typesHow to test (Solar)