Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-40570

Assignments NPE when model answer showTo is not set

    Details

    • Type: Bug
    • Status: Verified
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 12.3
    • Fix Version/s: 12.4, 19.0 [Tentative]
    • Component/s: Assignments
    • Labels:
      None
    • 12 status:
      Resolved
    • Test Plan:
      Hide

      Please add a Test Plan here.

      Show
      Please add a Test Plan here.

      Description

      When an Assignments model answer does not have a selection for "Show to students", it causes an NPE:

      caused by: java.lang.NullPointerException
      at org.sakaiproject.assignment.impl.AssignmentSupplementItemServiceImpl.canViewModelAnswer(AssignmentSupplementItemServiceImpl.java:451)

      because AssignmentSupplementItemServiceImpl.java has:

                                              int show = m.getShowTo();
      

      which is an autoboxing error (assigning Integer null to int).

      The column definition for this field allows NULL values:

      CREATE TABLE `ASN_MA_ITEM_T` (
        `ID` bigint(20) NOT NULL,
        `ASSIGNMENT_ID` varchar(255) DEFAULT NULL,
        `TEXT` varchar(255) DEFAULT NULL,
        `SHOW_TO` int(11) DEFAULT NULL,
        PRIMARY KEY (`ID`),
        CONSTRAINT `FKDE1CE707935EEE07` FOREIGN KEY (`ID`) REFERENCES `ASN_SUP_ITEM_T` (`ID`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 
      

      This should be fixed:

      • In the UI, to require a selection for "show to students"
      • In the schema definition, to disallow null values
      • In the code, to avoid this common autoboxing error

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                ern Earle R Nietzel
                Reporter:
                smarquard Stephen Marquard
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Git Source Code