-1

I am working on a programm in C# forms, where the user has to solve problems. Only when the user has finished a problem he is free to continue with the next one.

I want to save the progress of the user so he doesnt have to do it all over again when he closes and reopens the programm. I thought maybe a bool array (for each problem one bool, solved true or false) could do the job.

But how do i Save it?

Denji
  • 15
  • 6
  • How do you store the problems? How do you show them to the user? – ikerbera Nov 16 '18 at 09:11
  • 1
    Possible duplicate of [saving state between program restarts](https://stackoverflow.com/questions/7522228/saving-state-between-program-restarts) – FCin Nov 16 '18 at 09:14
  • I have a form where you can choose the problems by buttons, then the programm checks if certain circumstances allow the user to open this problem. If the check is positive a new form opens with the problem and he can solve the riddle. – Denji Nov 16 '18 at 09:15

3 Answers3

1

1) Create table for question where your questions.

2) Create another table for answer where you will save question ID and answer after user question it with user ID.

3) This two table should have relationship with Answer table FK.

4) In answer table status column should store the final submission by user.

5) If the final submission status is not submited then you can bind all the question with answer by users from Answer table. Ans same you can go to pending question which user supposed to answer last time he left.

6) 5th step you should do on form initiate. Get validate and move to next question.

Nakul
  • 137
  • 1
  • 11
0

There are many ways to do this, you could use json,csv,xml ecc....

Simply you create a file with some information and then when the user re-open your application the file is loaded and parsed.

The following example loads XML into an XmlDocument object, modifies it, and then saves it to a file named data.xml:

 // Create the XmlDocument.
    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<item><name>wrench</name></item>");

    // Add a price element.
    XmlElement newElem = doc.CreateElement("price");
    newElem.InnerText = "10.95";
    doc.DocumentElement.AppendChild(newElem);

    // Save the document to a file. White space is
    // preserved (no white space).
    doc.PreserveWhitespace = true;
    doc.Save("data.xml");

The result is a file that contains this:

<item><name>wrench</name><price>10.95</price></item>
MatteoCracco97
  • 426
  • 6
  • 17
0

When you want to save the data. You can use a database or in a local file. So you save everything in it and load it after the start of the program and check it. I hope this will help you :)

Max
  • 21
  • 5