CaptainCoderOrg / IntroToCSharpSite

1 stars 1 forks source link

Pages should have a % Complete #174

Open jcollard opened 2 years ago

jcollard commented 2 years ago

It would be nice to know what percentage of a pages questions, challenges, explorations, and activity steps have been completed.

It might be nice to have a % complete listed on the page / site somewhere as well as a warning message when someone attempts to mark page complete if the page is not 100% completed.

cloudthepain commented 2 years ago

Is there a way to get how many of a component there is on a page?

jcollard commented 2 years ago

I'm not sure the best way to approach this yet. I think it will involve using a <CascadingValue>. I'm doing something similar in the ActivityStep component to be able to track all of the TaskItem and Question componenets inside so it knows when the Exploration / Challenge is complete.

I think doing something like this would be the easiest thing to do. However, it would require us to manually add in the <CascadingValue> to each page. It would be nice if we could find a way that didn't require that.

cloudthepain commented 2 years ago

Could we Serialize them somehow? Or would that assign them their own unique id

jcollard commented 2 years ago

When you say Serialize, what do you mean?

cloudthepain commented 2 years ago

I misunderstood Serialize as a function. I don't think my idea would work.

cloudthepain commented 2 years ago

Could the Cascading Value just be set to the type & name?

Cascading value = Challenge + challengeNameHere?

jcollard commented 2 years ago

Could the Cascading Value just be set to the type & name?

Cascading value = Challenge + challengeNameHere?

You can make it a string. I'm not sure if this helps us. What are you thinking?

cloudthepain commented 2 years ago

Could something like this work?

    <CascadingValue Type="Challenge/Exploration" Name = "@Name">
       <Challenge>
       </Challenge>
    </CascadingValue>
cloudthepain commented 2 years ago

The cascadingValue Type would control whether the content was presented as challenge or exploration (since I know we wanted to combine them).

Name would be a string with the name of the Challenge or exploration. We would then add those to a List or perhaps a dictionary of items? Then as they are submitted they are moved from a list of incomplete items into a list of complete items.

List incomplete items; List complete items; Percent complete = complete items / (incomplete items count + complete items count)

jcollard commented 2 years ago

Ah, I see what you're trying to do and it should work (or a version of it).

You're thinking of CascadingValue backwards. You want to "push" the parent object (in this case the Page) down into the Challenge or Exploration. This will allow those components to notify the parent (the page) when they are finished OR what percentage of completion they have.

Take a look at how the IAdventureActivity interface and the IAdventureTask interface work together:

public interface IAdventureTask
{
    public bool IsComplete {get;}
}

and

public interface IAdventureActivity
{
    public bool IsComplete { get; }
    public void AddTask (IAdventureTask task);
    public void Notify();
}

Currently, an IAdventureTask can be registered on an IAdventureActivity using the AddTask method.

If you look at Explore and Challenge they are essentially wrappers for the ActivityStep component which implements IAdventureActivity. The Question and TaskItem components implement IAdventureTask. Go take a look at them and try to understand how they work.

Something similar should be possible for the entire Page.

cloudthepain commented 2 years ago

Do you have time Friday to work on this together so I can get a better understanding of what you mean? I've been having a little bit of a hard time grasping how c# & html work together like that.