pub struct Section {
pub number: u16,
pub root: String,
pub fixture: Fixture,
pub levels: Vec<Level>,
}Expand description
A section of the course: its number, the directory (relative to the workspace) every path of its levels is relative to, a fixture shared by all of them, and the levels.
use shellgame::engine::prelude::*;
let section = Section::new(2, "level-2")
.fixture(Fixture::new().dir("location-A"))
.intro(intro("Práce se soubory", "Úvod."))
.levels([level(1, "První").answer(exact("a")).solution("shellgame submit a")]);
assert_eq!(section.levels[0].id.to_string(), "2.0");
assert_eq!(section.levels[1].id.to_string(), "2.1");Fields§
§number: u16The section number.
root: StringThe section directory relative to the workspace: "" for section 0 (the workspace
itself), "level-N" for the others.
fixture: FixtureApplied before each level’s own fixture.
levels: Vec<Level>The intro (N.0) and the levels, in the order they were added.
Implementations§
Source§impl Section
impl Section
Sourcepub fn new(number: u16, root: impl Into<String>) -> Self
pub fn new(number: u16, root: impl Into<String>) -> Self
An empty section. root is relative to the workspace.
Sourcepub fn fixture(self, fixture: Fixture) -> Self
pub fn fixture(self, fixture: Fixture) -> Self
Add a fixture shared by every level of the section, applied before the level’s own.
Sourcepub fn levels<I>(self, levels: I) -> Selfwhere
I: IntoIterator<Item = Level>,
pub fn levels<I>(self, levels: I) -> Selfwhere
I: IntoIterator<Item = Level>,
Add levels; each gets this section’s number.
Sourcepub fn get(&self, number: u16) -> Option<&Level>
pub fn get(&self, number: u16) -> Option<&Level>
The level with this number, if the section has it.
Sourcepub fn section_root(
&self,
workspace: &Path,
) -> Result<PathBuf, ContainmentError>
pub fn section_root( &self, workspace: &Path, ) -> Result<PathBuf, ContainmentError>
The absolute directory every path of this section’s levels is relative to, with the
containment rules applied: the workspace and level-N must not be symlinks.