Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

challenge tasks don’t retain sort order when creating or editing a challenge #1703

Closed
wc8 opened this issue Nov 1, 2013 · 20 comments · Fixed by #12204
Closed

challenge tasks don’t retain sort order when creating or editing a challenge #1703

wc8 opened this issue Nov 1, 2013 · 20 comments · Fixed by #12204

Comments

@wc8
Copy link
Contributor

wc8 commented Nov 1, 2013

One can reorder items on the Challenges tab but the sort reverts.

EDIT by Alys 2020-05-13: Before working on this, please read the comments below and also the comments in this pull request: #12021 . If you think the code in that PR is suitable for re-use in your solution, you're welcome to use it - please mention in your PR that you've done so.

EDIT by Alys 2017: This issue will be easier to fix now because there is code for sorting tasks in Group Plans (#8358) and it can be reused for challenges. Copying from @TheHollidayInn's comment below:
"the code allows to order challenge tasks (and can be shared between all three). Although, there needs to be a taskOrder object on the challenge - not sure if that exists."

EDIT by Alys 2020-02-28: What's supposed to happen is that the order of the tasks you see on the challenge's screen should be the same as the order of the task IDs in the challenge's tasksOrder object. Below is an example of that object in a challenge's document.

An additional problem is that the challenge's page has lost the ability for the challenge owner to reorder the tasks. The owner should be able to drag and drop in the same way that a user can drag and drop their own tasks. Admins (moderators and staff) should also be able to drag and drop the challenge's tasks (there's already code for challenges that gives admins the same rights at the challenge owner). Other players should not be able to drag a challenge's tasks in the challenge's own page (of course they can drag their own copies of the tasks after they join the challenge).

{
    "_id": "b7fbd6a2-6d5e-4f28-a81f-12f42f9cf447",
    "tasksOrder": {
        "habits": [
            "990933b0-4853-4f38-92b0-3864ce576f9e",
            "3d131996-768b-46e9-937d-993452a78df2",
            "5ca7fbf1-b7b5-498e-9c6d-85d328a50099"
        ],
        "dailys": [
            "30ef773b-292e-46e7-beb1-ecf2df66cbb3",
            "62782db7-8bbd-48e4-b0b0-2ab86a5d1031"
        ],
        "todos": [
            "85a5e240-8c64-446d-baab-db6debbabdd0",
            "71a67058-e022-497a-8319-d52584383b66"
        ],
        "rewards": [
            "2c0f8ed9-a61f-4ba4-9ad4-5f36a25db02a"
        ]
    },
    "official": false,
    "memberCount": 0,
    "prize": 0,
    "name": "My Challenge",
    .... etc ....
}
@habitrpguser
Copy link

I think this issue and the closed issue #5647 ("Cannot rearrange tasks when creating or editing a challenge.") are different issues (though related). One is about tasks changing order in one's personal tasks page after joining the challenge. The other is about not being able to reorder tasks in a challenge while editing. Those are/should be two different orders. (One of the tasks inside the challenge as you see them before you join, the other of your personal tasks after you've rearranged them into your own preferred order.)

I'd very much like to have the feature to reorder challenge tasks during challenge creation. It would save much work since now the only way to do it is to delete tasks and recreate them in the right order.

@Alys Alys changed the title challenge items don’t retain sort challenge items don’t retain sort when creating or editing a challenge Feb 16, 2016
@Alys Alys removed the bug label Aug 21, 2016
@habitrpguser
Copy link

habitrpguser commented Aug 31, 2016

I just cloned a challenge, and the task order changed. So now you can't sort them when you create them, you can't sort them when you edit the challenge, and you can't rely on them staying sorted when you clone the challenge. :(

The challenge I cloned was created before the change to API v3. (I'm not sure if that makes a difference but I thought I'd mention it. I haven't tested it with newer challenges.)

@habitrpguser
Copy link

habitrpguser commented Sep 6, 2016

I did some testing about this in the Challenge Sandbox guild. Please read the (looong) description of the challenge 🐛 Bug Test Challenge 1: Testing Various Task Order Bugs for details!

To sum things up:

  • When someone creates a challenge, the tasks are saved in a different order than they are shown in when editing. The order is random (or at least unpredictable). If you try to create the same challenge twice, entering the same tasks in the same order, you will get two challenges with two different orders.
  • The same happens if you clone a challenge. The tasks of the new challenge won't be in the same order as in the original challenge. If you clone the same challenge twice (both times from the same original), you will end up with two different clones with two different task orders. (I'm not sure if they still deserve the name "clone"...) The order is random (or at least unpredictable).
  • The same happens if you create new tasks and delete old ones during editing. They won't be saved in the order they appear in during editing.
  • There is no way to "sort" challenge tasks when creating or editing (by dragging them around or by clicking on the "push to top/bottom" arrows). There never was.

Those are definitely bugs. (Ok, the last one is rather a missing feature.) So, is there no workaround? Yes, there is! (At least it has worked so far...)

  • Create a challenge with as many tasks as you need. Fill the tasks with short meaningless placeholder text. ("sdg", "bla", "."). Save.
  • Edit the challenge. Don't add or delete any tasks. Instead, edit the existing tasks. They will save in the same order.

(Of course, you could always just simply number the tasks and leave it to each participant to sort them in their own Tasks page...)

Also, please don't confuse this bug with other bugs! (For example, issue 7599 (challenge tasks are in wrong order in one's own Tasks page directly after joining, creating, or cloning), or issue 7645 (when sorting tasks in one's own Tasks page, the order isn't saved properly, or changes unexpectedly).)

@Alys
Copy link
Contributor

Alys commented Jan 21, 2017

This issue might be easier to fix now because there is code for sorting tasks in Group Plans: #8358

It's possible that the code could be reused or copied for challenges. Or I might be completely wrong. :) It's probably worth a look though.

@TheHollidayInn
Copy link
Contributor

Yep, the code allows to order challenge tasks (and can be shared between all three). Although, there needs to be a taskOrder object on the challenge - not sure if that exists.

@lemoness lemoness closed this as completed Oct 7, 2017
@Alys
Copy link
Contributor

Alys commented Jun 28, 2018

This is definitely still an issue so I'm reopening it. Note the comments above from me and TheHollidayInn from January 2017 about sorting. tasksOrder does exist in challenges, for example:

{
    "_id": "21aacfa4-3eea-4d64-9cfe-efc3c60a034d",
    ...
    "tasksOrder": {
        "rewards": [],
        "todos": [
            "d5cb42b1-e7d2-4977-b2e1-5dbfde9d6a67",
            "ce4e18cc-7c76-4342-bfd2-d08cff01325b",
            "17cb44ff-5839-4f5e-a1f2-33159fe25a8a",
            "5111b729-4eba-42f9-b74a-c6a6c0656efb"
        ],
        "dailys": [],
        "habits": []
    },
    ...
}

@Alys Alys reopened this Jun 28, 2018
@paglias
Copy link
Contributor

paglias commented Jun 28, 2018

This is about challenge tasks not keeping the same order when added to the user's list? So it's different from the issue @SabreCat reported?

@Alys
Copy link
Contributor

Alys commented Jun 28, 2018

This one is about the challenge owner editing the challenge to sort the tasks on the challenges page (basically the same as #10464). #7599 is for tasks keeping the same order when first added to the user's list.

@Alys Alys changed the title challenge items don’t retain sort when creating or editing a challenge challenge tasks don’t retain sort order when creating or editing a challenge Dec 6, 2019
@alecbrick
Copy link
Contributor

It looks like this isn't an issue anymore. Should it be closed?

@Alys
Copy link
Contributor

Alys commented Feb 28, 2020

It is still an issue. What's supposed to happen is that the order of the tasks you see on the challenge's screen should be the same as the order of the task IDs in the challenge's tasksOrder object. Below is an example of that object in a challenge's document. (What seems to happen currently is that the tasks stay in a fixed order, but it's not the order they're meant to be in.)

However I've realised that the challenge's page has lost the ability for the challenge owner to reorder the tasks. They should be able to drag and drop in the same way that a user can drag and drop their own tasks. Admins (moderators and staff) should also be able to drag and drop the challenge's tasks (there's already code for challenges that gives admins the same rights at the challenge owner). Other players should not be able to drag a challenge's tasks.

I'll update the top post with this information since dragging-and-dropping should be implemented at the same time as obeying the tasksOrder object.

{
    "_id": "b7fbd6a2-6d5e-4f28-a81f-12f42f9cf447",
    "tasksOrder": {
        "habits": [
            "990933b0-4853-4f38-92b0-3864ce576f9e",
            "3d131996-768b-46e9-937d-993452a78df2",
            "5ca7fbf1-b7b5-498e-9c6d-85d328a50099"
        ],
        "dailys": [
            "30ef773b-292e-46e7-beb1-ecf2df66cbb3",
            "62782db7-8bbd-48e4-b0b0-2ab86a5d1031"
        ],
        "todos": [
            "85a5e240-8c64-446d-baab-db6debbabdd0",
            "71a67058-e022-497a-8319-d52584383b66"
        ],
        "rewards": [
            "2c0f8ed9-a61f-4ba4-9ad4-5f36a25db02a"
        ]
    },
    "official": false,
    "memberCount": 0,
    "prize": 0,
    "name": "My Challenge",
    .... etc ....
}

@alecbrick
Copy link
Contributor

I've created a PR! #12021

@shanaqui
Copy link

shanaqui commented May 5, 2020

Hi @alecbrick, are you still working on this one? :) If I don't hear back, I'll set this back to "help wanted" in about a week.

@shanaqui
Copy link

@alecbrick I'm setting this issue back to help wanted, but if you want to pick it back up, let us know!

@Alys
Copy link
Contributor

Alys commented May 13, 2020

I've removed some old comments that are no longer relevant and updated the top post to mention that a contributor should review the other comments here and in #12021

Ideally we should collate all the comments from both sources and purge anything irrelevant to make this easier to pick up. :-/ If I can find time I might do that.

@paglias
Copy link
Contributor

paglias commented May 13, 2020

I'm going to take over that PR, it was almost done and contains a lot of good refactoring, I'll try to finish it this or next week

@habitrpguser
Copy link

I checked again today - and when cloning a challenge, the cloned challenge still has a different (apparently randomly mixed up) task order than the original challenge.
(Today I also deleted my "Bug Test Challenge 1" from 2016 that I linked to in a previous comment. Most of the detailed test description in that challenge was obsolete and useless by now.)

@shanaqui
Copy link

Thanks for the update! I don't think a fix has actually been completed for this anyway, so it would be expected that things are still not working that way... is that right, @paglias?

@paglias
Copy link
Contributor

paglias commented Nov 24, 2020

@habitrpguser this is still open indeed! We have a quite complete PR at #12204 and if you could finish the remaining issues it would be great!

@habitrpguser
Copy link

This bug still happens! I don't know if challenge tasks change order if a challenge is cloned once (I couldn't reproduce that), but they definitely do if a challenge is cloned and then that clone is cloned again. Please see examples:

https://habitica.com/challenges/79fabb8c-f99a-459f-bdb7-ed810f25661b

https://habitica.com/challenges/7f96108c-c086-4ae1-9fa4-7b2006bbb965

https://habitica.com/challenges/6cec332e-8ddc-46f7-afe6-f2a9cb212311

@Alys
Copy link
Contributor

Alys commented Jun 9, 2021

@habitrpguser Thanks! I've logged it as a new issue here: #13328

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment