Ejemplo n.º 1
0
solution_id add_solution(database& db, assignment_id assignment, std::vector<student_id> solvers,
		std::vector<task> editied_tasks) {
	auto id = db.new_solution_id();
	for(auto solver: solvers) {
		db.get_student(solver).add_solution(id);
	}
	auto tmp = solution{assignment, id, std::move(solvers), std::move(editied_tasks)};
	db.add_solution(std::move(tmp));
	return id;
}
Ejemplo n.º 2
0
void assignment::print_results(const std::vector<student_id>& students, database& db) const {
	std::cout << "\"Name\", \"id\", ";
	for(auto&& task: m_max_points) {
		std::cout << '"' << task.first << "\", ";
	}
	std::cout << '\n';
	for (auto stud: students) {
		const auto& student = db.get_student(stud);
		const auto& solutions = student.solutions();
		auto it = std::find_if(begin(solutions), end(solutions),
		                       [&](const auto& sol) {return db.get_solution(sol).assignment() == m_id;});
		if (it == end(solutions)) {
			continue;
		}
		const auto& solution = db.get_solution(*it);
		std::cout << '"' << student.name() << "\", \"" << student.id() << "\", ";
		for(auto&& task: m_max_points) {
			std::cout << '"' << solution.get_task(task.first).points() << "\", ";
		}
		std::cout << '\n';
	}
}