Using plan templates throws an error on Collection creation when plan is associated with an assigned TaskView

Bug #1939364 reported by Doris Tam
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Doris Tam

Bug Description

The only situation I've found this is when we copy a group with plans. The functionality to duplicate a plan doesn't seem to be an option elsewhere.

Create a plan template.
Set it as a template with assignment tasks on.
Create a task for that plan template, attaching a collection etc.
Create a new plan from the template in a group.
Submit without changing anything.
Error is thrown.

    1. Create a page.
    2. Create a group and add five members.
    3. Create a personal plan with these settings:
        1. Assignment tasks (Yes).
        2. Template (Yes).
    4. Create a task for the plan with these settings:
        1. Select your a page to be the ‘Task page’.
    5. In your group, create a new plan from your personal plan template.
    6. Check that once the template is applied, ‘Assignment tasks’ setting is ‘Yes’.
    7. Press save.

Changed in mahara:
importance: Undecided → Medium
milestone: none → 21.10.0
status: New → In Progress
Revision history for this message
Doris Tam (doristam) wrote (last edit ): Re: Copying a plans throws an error when there is no parent

# Failed template plan

1. Make a personal plan, give it a title, template (yes), and assignment tasks (yes).
2. Create a task for that plan and assign it a task page.
3. Go group plans and create a new plan based on that template.
4. Error.

This is due to plan tasks auto-creating a collection where recently we have updated the table constraints for the 'collections' table in the database and the new fields with non-null constraints are not all given a value. e.g. autotemplate, template, navigation etc.

Changed in mahara:
assignee: nobody → Doris Tam (doristam)
Revision history for this message
Doris Tam (doristam) wrote :

It would be good if we had a set of required fields like the same way we do for get_comment_options, for a list of required fields we need to give or set these values in the _construct of Collection to cover all cases.

summary: - Copying a plans throws an error when there is no parent
+ Using plan templates throws an error on Collection creation when plan is
+ associated with an assigned TaskView
Revision history for this message
Doris Tam (doristam) wrote (last edit ):

One solution:
                    $collectiondata=array(
                        // required fields
                        'group' => $targetGroupPlan->get('group'),
                        'name' => get_string('targetgroupplancollectiontitleprefix', 'artefact.plans') . $targetGroupPlan->get('title'),
                        'navigation' => 1,
                        'submittedstatus' => 0,
                        'lock' => 0,
                        'progresscompletion' => 0,
                        'autocopytemplate' => 0,
                        'template' => 0,
                        // optional fields
                        'description' => get_string('taskviewsfortemplateplan', 'artefact.plans', $targetGroupPlan->get('title')),
                    );
                    $targetTaskViewCollection = new \Collection(0, $collectiondata);

Or we can generalise it and add in the non-assigned fields in the _construct() of Collection class

Doris Tam (doristam)
description: updated
Robert Lyon (robertl-9)
Changed in mahara:
status: In Progress → Incomplete
milestone: 21.10.0 → 22.04.0
Changed in mahara:
milestone: 22.04.0 → 22.10.0
Robert Lyon (robertl-9)
Changed in mahara:
status: Incomplete → Confirmed
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review
Changed in mahara:
status: Confirmed → In Progress
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/c/mahara/+/13231
Committed: https://git.mahara.org/mahara/mahara/commit/5f5f18aa451367b61811350e5cf6ff98151dd724
Submitter: "Gold <email address hidden>"
Branch: main

commit 5f5f18aa451367b61811350e5cf6ff98151dd724
Author: Robert Lyon <email address hidden>
Date: Fri Oct 14 17:33:05 2022 +1300

Bug 1939364: fails on plans with no parent

Also mentioned in Bug 1984139 - for point 5
When copying from template

and viewing them via 'i' button

Change-Id: Ibd5c4883193a99e1b798ccf479b9b754423905f8
Signed-off-by: Robert Lyon <email address hidden>

Robert Lyon (robertl-9)
Changed in mahara:
status: In Progress → Fix Committed
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "22.10_DEV" branch: https://reviews.mahara.org/c/mahara/+/13282

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/c/mahara/+/13282
Committed: https://git.mahara.org/mahara/mahara/commit/5a4a38df36232c62af2da996f3bccfda325a63a5
Submitter: "Robert Lyon <email address hidden>"
Branch: 22.10_DEV

commit 5a4a38df36232c62af2da996f3bccfda325a63a5
Author: Robert Lyon <email address hidden>
Date: Fri Oct 14 17:33:05 2022 +1300

Bug 1939364: fails on plans with no parent

Also mentioned in Bug 1984139 - for point 5
When copying from template

and viewing them via 'i' button

Change-Id: Ibd5c4883193a99e1b798ccf479b9b754423905f8
Signed-off-by: Robert Lyon <email address hidden>
(cherry picked from commit 5f5f18aa451367b61811350e5cf6ff98151dd724)

Doris Tam (doristam)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.