views:

61

answers:

2

I've got a list of student/assignment pairs coming in to my application via flat file into a List object and I'd like to validate those assignment names against a list of assignments I have to see which student has done what assignment (if any).

So - I have a list of students, a list of student/assignment pairs, and a list of assignments.

I want to create output like the following:

1. (Heading) -- Student Name -- Assignent One -- Assignment TWo
2. (Detail)  -- John Smith   --  <complete>   -- <complete>

How can I accomplish this?

What I have so far: // HACCStudentBlogs stores the list of students in a dictionary I've been appending to the key's value with every found blog (crude, I know) //

Dictionary<string, string> studentBlogs = new Dictionary<string, string>();
            foreach (JObject o in root)
            {
                createDate = (string)o["createdDate"];
                studentName = (string)d[(string)o["contributorName"]];
                submittedStudents.Add(studentName);
                title=(string)o["title"];

                    if (HACCstudentBlogs.ContainsKey(studentName))
                    {

                        HACCstudentBlogs[studentName] += "\t" + title.ToUpper();
                    }
                    else
                    {



                    }




            }
+1  A: 
  1. Since you want one row per student, it's easiest to loop over the list of students and do something for each student.

  2. In this case, "something" means that we need to assemble a line of output.

  3. Each line of output is going to have the student's information, and then needs a piece for each assignment. So inside the loop over the students, there will be a loop over the assignments.

  4. In the loop over the assignments, we need to look up and see if we have a pair for that student and assignment. If so, we spit out "complete." Otherwise, "incomplete."

So a plausible way to structure the program would be something like this:

// print some header information
foreach (var student in studentList)
{
    Display(student.Name);
    foreach (var assignment in assignmentList)
    {
       if (Exists(student, assignment, studentAssignmentPairs))
           Display("<complete>");
       else
           Display("<incomplete>");
    }
    // newline
}

with some added flair for formatting it nicely.

Enough to get started?

mquander
A: 

we really need to know what the list object looks like

but using foreach over a Linq .Distint() woudld be a good startng point

Yakyb