Skip to content

Commit

Permalink
Merge pull request #365 from oat-sa/release-19.0.3
Browse files Browse the repository at this point in the history
Release 19.0.3
  • Loading branch information
shpran authored Sep 11, 2023
2 parents 44ca821 + fcb1106 commit aba11a0
Show file tree
Hide file tree
Showing 146 changed files with 382 additions and 381 deletions.
2 changes: 1 addition & 1 deletion bin/qtisdk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ switch ($module) {
Render::main();
break;
default:
CliTools\err("%RUnknown module '${requestedModuleName}'. Available modules are: " . implode(',', $availableModules) . '.%n');
CliTools\err("%RUnknown module '{$requestedModuleName}'. Available modules are: " . implode(',', $availableModules) . '.%n');
exit(Cli::EXIT_FAILURE);
}
8 changes: 4 additions & 4 deletions src/qtism/cli/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected function getArguments(): Arguments
*/
protected function error($message): void
{
$this->out("%r${message}%n", true);
$this->out("%r{$message}%n", true);
}

/**
Expand All @@ -179,7 +179,7 @@ protected function error($message): void
protected function success($message): void
{
if ($this->isVerbose() === true) {
$this->out("%g${message}%n", true);
$this->out("%g{$message}%n", true);
}

exit(self::EXIT_SUCCESS);
Expand Down Expand Up @@ -209,7 +209,7 @@ protected function missingArgument($longName): void
$msg = 'Missing argument';

if (array_key_exists($longName, $options)) {
$msg .= " '${longName}'";
$msg .= " '{$longName}'";
}

$msg .= '.';
Expand All @@ -228,7 +228,7 @@ protected function missingArgument($longName): void
protected function info($message): void
{
if ($this->isVerbose() === true) {
$this->out("%w${message}%n", true);
$this->out("%w{$message}%n", true);
}
}

Expand Down
52 changes: 26 additions & 26 deletions src/qtism/cli/Render.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ protected function checkArguments(): void
$this->missingArgument('source');
} elseif (is_readable($source) === false) {
if (file_exists($source) === false) {
$msg = "The QTI file '${source}' does not exist.";
$msg = "The QTI file '{$source}' does not exist.";
} else {
$msg = "The QTI file '${source}' cannot be read. Check permissions.";
$msg = "The QTI file '{$source}' cannot be read. Check permissions.";
}

$this->fail($msg);
Expand Down Expand Up @@ -195,24 +195,24 @@ protected function run(): void
} catch (XmlStorageException $e) {
switch ($e->getCode()) {
case XmlStorageException::READ:
$msg = "An error occurred while reading QTI file '${source}'.\nThe system returned the following error:\n";
$msg = "An error occurred while reading QTI file '{$source}'.\nThe system returned the following error:\n";
$msg .= ExceptionUtils::formatMessage($e);
$this->fail($msg);
break;

case XmlStorageException::XSD_VALIDATION:
$msg = "The QTI file '${source}' is invalid against XML Schema.\nThe system returned the following error:\n";
$msg = "The QTI file '{$source}' is invalid against XML Schema.\nThe system returned the following error:\n";
$msg .= ExceptionUtils::formatMessage($e);
$this->fail($msg);
break;

case XmlStorageException::VERSION:
$msg = "The QTI version of file '${source}' could not be detected.";
$msg = "The QTI version of file '{$source}' could not be detected.";
$this->fail($msg);
break;

default:
$msg = "An fatal error occurred while reading QTI file '${source}'.";
$msg = "An fatal error occurred while reading QTI file '{$source}'.";
$this->fail($msg);
break;
}
Expand Down Expand Up @@ -266,28 +266,28 @@ private function runGoldilocks(XmlDocument $doc, GoldilocksRenderingEngine $rend
$assessmentItemElts->item(0)->removeAttribute($attributes->item(0)->name);
}

$header .= '<html ' . implode(' ', $htmlAttributes) . ">${nl}";
$header .= "${indent}<head>${nl}";
$header .= "${indent}${indent}<meta charset=\"utf-8\">${nl}";
$header .= "${indent}${indent}<title>" . XmlUtils::escapeXmlSpecialChars($rootComponent->getTitle()) . "</title>${nl}";
$header .= "${indent}${indent}" . $renderer->getStylesheets()->ownerDocument->saveXML($renderer->getStylesheets());
$header .= "${indent}</head>${nl}";
$header .= '<html ' . implode(' ', $htmlAttributes) . ">{$nl}";
$header .= "{$indent}<head>{$nl}";
$header .= "{$indent}{$indent}<meta charset=\"utf-8\">{$nl}";
$header .= "{$indent}{$indent}<title>" . XmlUtils::escapeXmlSpecialChars($rootComponent->getTitle()) . "</title>{$nl}";
$header .= "{$indent}{$indent}" . $renderer->getStylesheets()->ownerDocument->saveXML($renderer->getStylesheets());
$header .= "{$indent}</head>{$nl}";

$itemBodyElts = $xpath->query("//div[contains(@class, 'qti-itemBody')]");
if ($itemBodyElts->length > 0) {
$body = $xml->saveXml($itemBodyElts->item(0));
$body = substr($body, strlen('<div>'));
$body = substr($body, 0, strlen('</div>') * -1);
$body = "<body ${body}</body>${nl}";
$body = "<body {$body}</body>{$nl}";
} else {
$body = $xml->saveXml($xml->documentElement) . ${nl};
$body = $xml->saveXml($xml->documentElement) . {$nl};
}

if ($arguments['document'] === true) {
$footer = "</html>\n";
}
} else {
$body = $xml->saveXml($xml->documentElement) . ${nl};
$body = $xml->saveXml($xml->documentElement) . {$nl};
}

// Indent body...
Expand All @@ -299,7 +299,7 @@ private function runGoldilocks(XmlDocument $doc, GoldilocksRenderingEngine $rend

foreach (preg_split('/\n|\r/u', $body, -1, PREG_SPLIT_NO_EMPTY) as $bodyLine) {
// do stuff with $line
$indentBody .= "${indent}${bodyLine}${nl}";
$indentBody .= "{$indent}{$bodyLine}{$nl}";
}

$body = $indentBody;
Expand Down Expand Up @@ -342,23 +342,23 @@ private function runXhtml(XmlDocument $doc, XhtmlRenderingEngine $renderer): str
}

$header .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
$header .= "<html>${nl}";
$header .= "${indent}<head>${nl}";
$header .= "${indent}${indent}<meta charset=\"utf-8\">${nl}";
$header .= "<html>{$nl}";
$header .= "{$indent}<head>{$nl}";
$header .= "{$indent}{$indent}<meta charset=\"utf-8\">{$nl}";

if (!empty($title)) {
$header .= "${indent}${indent}<title>" . $title . "</title>${nl}";
$header .= "{$indent}{$indent}<title>" . $title . "</title>{$nl}";
}

$header .= "${indent}${indent}" . $renderer->getStylesheets()->ownerDocument->saveXML($renderer->getStylesheets());
$header .= "${indent}</head>${nl}";
$header .= "${indent}<body>${nl}";
$header .= "{$indent}{$indent}" . $renderer->getStylesheets()->ownerDocument->saveXML($renderer->getStylesheets());
$header .= "{$indent}</head>{$nl}";
$header .= "{$indent}<body>{$nl}";

$footer = "${indent}</body>${nl}";
$footer = "{$indent}</body>{$nl}";
$footer .= "</html>\n";
}

$body = $xml->saveXml($xml->documentElement) . ${nl};
$body = $xml->saveXml($xml->documentElement) . {$nl};

// Indent body...
$indentBody = '';
Expand All @@ -369,7 +369,7 @@ private function runXhtml(XmlDocument $doc, XhtmlRenderingEngine $renderer): str

foreach (preg_split('/\n|\r/u', $body, -1, PREG_SPLIT_NO_EMPTY) as $bodyLine) {
// do stuff with $line
$indentBody .= "${indent}${indent}${bodyLine}${nl}";
$indentBody .= "{$indent}{$indent}{$bodyLine}{$nl}";
}

$body = $indentBody;
Expand Down
22 changes: 11 additions & 11 deletions src/qtism/common/beans/Bean.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ public function getGetter($property): BeanMethod
}

if ($this->hasProperty($propertyName) === false) {
$msg = "The bean has no '${propertyName}' property.";
$msg = "The bean has no '{$propertyName}' property.";
throw new BeanException($msg, BeanException::NO_METHOD);
}

if (($getterName = $this->hasGetter($propertyName)) === false) {
$msg = "The bean has no public getter for a '${propertyName}' property.";
$msg = "The bean has no public getter for a '{$propertyName}' property.";
throw new BeanException($msg, BeanException::NO_METHOD);
}

Expand Down Expand Up @@ -214,12 +214,12 @@ public function getSetter($property): BeanMethod
}

if ($this->hasProperty($propertyName) === false) {
$msg = "The bean has no '${propertyName}' property.";
$msg = "The bean has no '{$propertyName}' property.";
throw new BeanException($msg, BeanException::NO_METHOD);
}

if ($this->hasSetter($propertyName) === false) {
$msg = "The bean has no public setter for a '${propertyName}' property.";
$msg = "The bean has no public setter for a '{$propertyName}' property.";
throw new BeanException($msg, BeanException::NO_METHOD);
}

Expand Down Expand Up @@ -314,11 +314,11 @@ public function getProperty($propertyName): BeanProperty
try {
return new BeanProperty($className, $propertyName);
} catch (BeanException $e) {
$msg = "The bean property with name '${propertyName}' in class '${className}' could not be retrieved.";
$msg = "The bean property with name '{$propertyName}' in class '{$className}' could not be retrieved.";
throw new BeanException($msg, BeanException::NO_PROPERTY, $e);
}
} else {
$msg = "No bean property with name '${propertyName}' in class '${className}'.";
$msg = "No bean property with name '{$propertyName}' in class '{$className}'.";
throw new BeanException($msg, BeanException::NO_PROPERTY);
}
}
Expand Down Expand Up @@ -490,13 +490,13 @@ protected function validateStrictBean(): void
$name = $param->getName();

if ($this->hasProperty($name) === false) {
$msg = "The constructor parameter '${name}' of class '${class}' has no related bean property.";
$msg = "The constructor parameter '{$name}' of class '{$class}' has no related bean property.";
throw new BeanException($msg, BeanException::NO_PROPERTY);
} elseif ($this->hasGetter($name) === false) {
$msg = "The constructor parameter '${name}' of class '${class}' has no related bean getter.";
$msg = "The constructor parameter '{$name}' of class '{$class}' has no related bean getter.";
throw new BeanException($msg, BeanException::NO_METHOD);
} elseif ($this->hasSetter($name) === false) {
$msg = "The construct parameter '${name}' of class '${class}' has no related bean setter.";
$msg = "The construct parameter '{$name}' of class '{$class}' has no related bean setter.";
throw new BeanException($msg, BeanException::NO_METHOD);
}
}
Expand All @@ -512,10 +512,10 @@ protected function validateStrictBean(): void
if ($this->hasProperty($name) === true) {
// Annotated property found.
if ($this->hasGetter($name) === false) {
$msg = "The bean property '${name}' has no related bean getter.";
$msg = "The bean property '{$name}' has no related bean getter.";
throw new BeanException($msg, BeanException::NO_METHOD);
} elseif ($this->hasSetter($name) === false) {
$msg = "The bean property '${name}' has no related bean setter.";
$msg = "The bean property '{$name}' has no related bean setter.";
throw new BeanException($msg, BeanException::NO_METHOD);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/qtism/common/beans/BeanMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct($class, $name)
try {
$this->setMethod(new ReflectionMethod($class, $name));
} catch (ReflectionException $e) {
$msg = "The method '${name}' does not exist.";
$msg = "The method '{$name}' does not exist.";
throw new BeanException($msg, BeanException::NO_METHOD, $e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/qtism/common/beans/BeanParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct($class, $method, $name)
try {
$this->setParameter(new ReflectionParameter([$class, $method], $name));
} catch (ReflectionException $e) {
$msg = "No such parameter '${name}' for method '${method}' of class '${class}'.";
$msg = "No such parameter '{$name}' for method '{$method}' of class '{$class}'.";
throw new BeanException($msg, BeanException::NO_PARAMETER, $e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/qtism/common/beans/BeanProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public function __construct($class, $name)
try {
$this->setProperty(new ReflectionProperty($class, $name));
} catch (ReflectionException $e) {
$msg = "The class property with name '${name}' does not exist in class '${class}'.";
$msg = "The class property with name '{$name}' does not exist in class '{$class}'.";
throw new BeanException($msg, BeanException::NO_PROPERTY, $e);
} catch (BeanException $e) {
$msg = "The property with name '${name}' for class '${class}' is not annotated.";
$msg = "The property with name '{$name}' for class '{$class}' is not annotated.";
throw new BeanException($msg, BeanException::NO_PROPERTY, $e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/qtism/common/collections/IdentifierCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function checkType($value): void
$msg = "IdentifierCollection class only accept string values, '" . gettype($value) . "' given.";
throw new InvalidArgumentException($msg);
} elseif (!Format::isIdentifier($value)) {
$msg = "IdentifierCollection class only accept valid QTI Identifiers, '${value}' given.";
$msg = "IdentifierCollection class only accept valid QTI Identifiers, '{$value}' given.";
throw new InvalidArgumentException($msg);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/qtism/common/datatypes/QtiPair.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function setFirst($first): void
if (Format::isIdentifier($first)) {
$this->first = $first;
} else {
$msg = "'${first}' is an invalid QTI identifier.";
$msg = "'{$first}' is an invalid QTI identifier.";
throw new InvalidArgumentException($msg);
}
}
Expand All @@ -102,7 +102,7 @@ public function setSecond($second): void
if (Format::isIdentifier($second)) {
$this->second = $second;
} else {
$msg = "'${second}' is an invalid QTI identifier.";
$msg = "'{$second}' is an invalid QTI identifier.";
throw new InvalidArgumentException($msg);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/qtism/common/datatypes/files/FileSystemFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public static function createFromExistingFile($source, $destination, $mimeType,
// Should we build the path to $destination?
$pathinfo = pathinfo($destination);
if (isset($pathinfo['dirname']) === false) {
$msg = "The destination argument '${destination}' is a malformed path.";
$msg = "The destination argument '{$destination}' is a malformed path.";
throw new RuntimeException($msg);
}

Expand Down Expand Up @@ -251,12 +251,12 @@ public static function createFromExistingFile($source, $destination, $mimeType,

$sourceFp = @fopen($source, 'r');
if ($sourceFp === false) {
throw new RuntimeException("Source file '${source}' could not be open.");
throw new RuntimeException("Source file '{$source}' could not be open.");
}

$destinationFp = @fopen($destination, 'w');
if ($destinationFp === false) {
throw new RuntimeException("Destination file '${destination}' could not be open.");
throw new RuntimeException("Destination file '{$destination}' could not be open.");
}

fwrite($destinationFp, $packedFilename . $packedMimeType);
Expand All @@ -273,12 +273,12 @@ public static function createFromExistingFile($source, $destination, $mimeType,
return new static($destination);
} else {
// Source file not readable.
$msg = "File '${source}' found but not readable.";
$msg = "File '{$source}' found but not readable.";
throw new RuntimeException($msg);
}
} else {
// Source file not found.
$msg = "Unable to find source file at '${source}'.";
$msg = "Unable to find source file at '{$source}'.";
throw new RuntimeException($msg);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/qtism/common/storage/BinaryStreamAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,15 @@ protected function handleBinaryStreamException(StreamException $e, $typeError, $
switch ($e->getCode()) {
case StreamException::NOT_OPEN:
$strAction = ucfirst($strAction);
$msg = "${strAction} a ${strType} from a closed binary stream is not permitted.";
$msg = "{$strAction} a {$strType} from a closed binary stream is not permitted.";
throw new BinaryStreamAccessException($msg, $this, BinaryStreamAccessException::NOT_OPEN, $e);

case StreamException::READ:
$msg = "An error occurred while ${strAction} a ${strType}.";
$msg = "An error occurred while {$strAction} a {$strType}.";
throw new BinaryStreamAccessException($msg, $this, $typeError, $e);

default:
$msg = "An unknown error occurred while ${strAction} a ${strType}.";
$msg = "An unknown error occurred while {$strAction} a {$strType}.";
throw new BinaryStreamAccessException($msg, $this, BinaryStreamAccessException::UNKNOWN, $e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/qtism/common/utils/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function formatMessage(\Exception $e, $withClassName = true): stri
do {
$className = get_class($e);
$message = $e->getMessage();
$returnValue .= ($withClassName === true) ? "[${className}] ${message}" : $message;
$returnValue .= ($withClassName === true) ? "[{$className}] {$message}" : $message;

if ($e = $e->getPrevious()) {
$returnValue .= "\nCaused by:\n";
Expand Down
4 changes: 2 additions & 2 deletions src/qtism/common/utils/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public static function isClass(string $string): bool
public static function scale10(float $float, string $x = 'x', $precision = false): string
{
// 1. Transform in 'E' notation.
$mask = ($precision === false) ? '%e' : "%.${precision}e";
$mask = ($precision === false) ? '%e' : "%.{$precision}e";
$strFloat = sprintf($mask, $float);

// 2. Transform the 'E' notation into 'x 10^n' notation.
Expand All @@ -398,7 +398,7 @@ public static function scale10(float $float, string $x = 'x', $precision = false
}
}

return $parts[0] . " ${x} 10" . $newMantissa;
return $parts[0] . " {$x} 10" . $newMantissa;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/qtism/data/AssessmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function setIdentifier($identifier): void
$this->identifier = $identifier;
$this->notify();
} else {
$msg = "'${identifier}' is not a valid QTI Identifier.";
$msg = "'{$identifier}' is not a valid QTI Identifier.";
throw new InvalidArgumentException($msg);
}
}
Expand Down
Loading

0 comments on commit aba11a0

Please sign in to comment.