importify various fixing

This commit is contained in:
2024-10-14 08:49:17 +02:00
parent fccdaada7e
commit d83f4e0e34
10 changed files with 244 additions and 155 deletions
@@ -9,10 +9,13 @@ $reportId = isset($_POST['reportId']) ? $_POST['reportId'] : 0;
// Query per ottenere le analisi associate al report, comprese le parti
$query = "
SELECT a.nameanalysisvoc AS name, rp.result_Rating AS finalRating
FROM result_project rp
LEFT JOIN analysisvocabulary a ON rp.result_TestName = a.idanalysisvocabulary
WHERE rp.idreports = ?";
SELECT
a.nameanalysisvoc AS name,
ap.test_Rating AS finalRating
FROM result_project rp
LEFT JOIN analysis_project ap ON rp.idanalysis_project = ap.idAnalysis_Project
LEFT JOIN analysisvocabulary a ON ap.result_TestName = a.idanalysisvocabulary
WHERE rp.idreports = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $reportId);
$stmt->execute();
@@ -24,23 +27,34 @@ $analysis = [];
// Raggruppa le analisi e seleziona il rating più restrittivo
while ($row = $result->fetch_assoc()) {
$name = $row['name'];
$rating = strtoupper($row['finalRating']); // Normalizziamo tutto in maiuscolo per uniformità
$rating = strtoupper(trim($row['finalRating'])); // Normalize to uppercase and trim spaces
// Convert specific terms into normalized ratings
if ($rating === 'COMPLIES') {
$rating = 'PASS';
}
// Initialize the rating if not set
if (!isset($analysis[$name])) {
// Se l'analisi non è ancora presente, la aggiungiamo
$analysis[$name] = $rating;
} else {
// Applica il rating più restrittivo: Fail > N/A > Pass
// Apply the most restrictive rating: Fail > Data > N/A > // > Pass
if ($analysis[$name] != 'FAIL' && ($rating == 'FAIL' || $rating == "DOESN'T COMPLY")) {
$analysis[$name] = 'FAIL';
} elseif ($analysis[$name] != 'FAIL' && $analysis[$name] != 'N/A' && ($rating == 'N/A' || $rating == '//')) {
} elseif ($analysis[$name] != 'FAIL' && $analysis[$name] != 'DATA' && $rating == 'DATA') {
$analysis[$name] = 'DATA';
} elseif ($analysis[$name] != 'FAIL' && $analysis[$name] != 'DATA' && $analysis[$name] != 'N/A' && $rating == 'N/A') {
$analysis[$name] = 'N/A';
} elseif ($analysis[$name] == 'PASS' && ($rating == 'PASS' || $rating == 'COMPLIES')) {
} elseif ($analysis[$name] != 'FAIL' && $analysis[$name] != 'DATA' && $analysis[$name] != 'N/A' && $analysis[$name] != '//' && $rating == '//') {
$analysis[$name] = '//';
} elseif ($analysis[$name] == 'PASS' && $rating == 'PASS') {
$analysis[$name] = 'PASS';
}
}
}
// Trasforma i dati in un array
$finalAnalysis = [];
foreach ($analysis as $name => $finalRating) {
+1 -1
View File
@@ -308,7 +308,7 @@ $result = $conn->query($query);
ratingClass = 'bg-danger text-white';
} else if (analysis.finalRating === 'PASS') {
ratingClass = 'bg-success text-white';
} else if (analysis.finalRating === '//' || analysis.finalRating === 'N/A') {
} else if (analysis.finalRating === '//' || analysis.finalRating === 'N/A' || analysis.finalRating === 'DATA') {
ratingClass = 'bg-warning text-dark';
}