1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
ash / glanceables / classroom / glanceables_classroom_types.cc [blame]
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/glanceables/classroom/glanceables_classroom_types.h"
#include <optional>
#include <sstream>
#include <string>
#include "base/i18n/time_formatting.h"
#include "base/time/time.h"
#include "url/gurl.h"
namespace ash {
// ----------------------------------------------------------------------------
// GlanceablesClassroomCourse:
GlanceablesClassroomCourse::GlanceablesClassroomCourse(const std::string& id,
const std::string& name)
: id(id), name(name) {}
std::string GlanceablesClassroomCourse::ToString() const {
std::stringstream ss;
ss << "id: " << id << ", name: " << name;
return ss.str();
}
// ----------------------------------------------------------------------------
// GlanceablesClassroomAggregatedSubmissionsState
GlanceablesClassroomAggregatedSubmissionsState::
GlanceablesClassroomAggregatedSubmissionsState(int total_count,
int number_turned_in,
int number_graded)
: total_count(total_count),
number_turned_in(number_turned_in),
number_graded(number_graded) {}
void GlanceablesClassroomAggregatedSubmissionsState::Reset() {
total_count = 0;
number_turned_in = 0;
number_graded = 0;
}
// ----------------------------------------------------------------------------
// GlanceablesClassroomAssignment
GlanceablesClassroomAssignment::GlanceablesClassroomAssignment(
const std::string& course_title,
const std::string& course_work_title,
const GURL& link,
const std::optional<base::Time>& due,
const base::Time& last_update,
std::optional<GlanceablesClassroomAggregatedSubmissionsState>
submissions_state)
: course_title(course_title),
course_work_title(course_work_title),
link(link),
due(due),
last_update(last_update),
submissions_state(std::move(submissions_state)) {}
std::string GlanceablesClassroomAssignment::ToString() const {
std::stringstream ss;
ss << "Course Title: " << course_title
<< ", Course Work Title: " << course_work_title << ", Link: " << link;
if (due.has_value()) {
ss << ", Due: " << base::TimeFormatHTTP(due.value());
}
ss << ", Last Update: " << base::TimeFormatHTTP(last_update);
if (submissions_state.has_value()) {
ss << ", total_submission_count: " << submissions_state->total_count
<< ", number turned in: " << submissions_state->number_turned_in
<< ", number graded:" << submissions_state->number_graded;
}
return ss.str();
}
} // namespace ash