From 0d25073191801b2193ae4c65008219b1df44977e Mon Sep 17 00:00:00 2001
From: Alexander Loewe <Alexander.Loewe@Outlook.de>
Date: Sun, 9 Jul 2023 15:13:07 +0200
Subject: [PATCH] Fixed a Problem with test titles in grading scheme

---
 classes/utility/proforma_xml/grading_scheme_handler.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/classes/utility/proforma_xml/grading_scheme_handler.php b/classes/utility/proforma_xml/grading_scheme_handler.php
index debe168..1f6db5b 100644
--- a/classes/utility/proforma_xml/grading_scheme_handler.php
+++ b/classes/utility/proforma_xml/grading_scheme_handler.php
@@ -246,7 +246,11 @@ class grading_scheme_handler {
             }
         }
         if(!$foundTitle) {
-            $node->set_title($this->tests[$refid] !== null && $this->tests[$refid]->getElementsByTagNameNS($this->namespace, 'title')[0]->nodeValue);
+            $title = "";
+            if ($this->tests[$refid] !== null && $this->tests[$refid]->getElementsByTagNameNS($this->namespace, 'title')->length >= 1) {
+                $title = $this->tests[$refid]->getElementsByTagNameNS($this->namespace, 'title')[0]->nodeValue;
+            }
+            $node->set_title($title);
         }
         if (($list = $elem->getElementsByTagNameNS($this->namespace, 'description'))->length == 1) {
             $node->set_description($list[0]->nodeValue);
-- 
GitLab