/* * @Override * public Object clone() throws CloneNotSupportedException * { * * TimedAssessmentRule tar = (TimedAssessmentRule) super.clone( ); * tar.effectIndex = effectIndex; * if( effects != null ) { * tar.effects = new List<TimedAssessmentEffect>(); * for (TimedAssessmentEffect tae : effects) * tar.effects.add((TimedAssessmentEffect)tae.clone()); * } * tar.startTime = startTime; * tar.elapsedTime = elapsedTime; * tar.endConditions = ( endConditions != null ? (Conditions) endConditions.clone( ) : null ); * tar.isDone = isDone; * tar.usesEndConditions = usesEndConditions; * return tar; * }*/ public override object Clone() { TimedAssessmentRule tar = (TimedAssessmentRule)base.Clone(); tar.effectIndex = effectIndex; if (effects != null) { tar.effects = new List <TimedAssessmentEffect>(); foreach (TimedAssessmentEffect tae in effects) { tar.effects.Add((TimedAssessmentEffect)tae.Clone()); } } tar.startTime = startTime; tar.elapsedTime = elapsedTime; tar.endConditions = (endConditions != null ? (Conditions)endConditions.Clone() : null); tar.isDone = isDone; tar.usesEndConditions = usesEndConditions; return(tar); }
public object DOMParse(XmlElement element, params object[] parameters) { AssessmentProfile profile = new AssessmentProfile(); profile.setShowReportAtEnd(ExString.EqualsDefault(element.GetAttribute("show-report-at-end"), "yes", false)); profile.setName(element.GetAttribute("name")); profile.setEmail(element.GetAttribute("send-to-email")); profile.setSendByEmail(!string.IsNullOrEmpty(profile.getEmail())); profile.setScorm12(ExString.EqualsDefault(element.GetAttribute("scorm12"), "yes", false)); profile.setScorm2004(ExString.EqualsDefault(element.GetAttribute("scorm2004"), "yes", false)); var smtpConfig = element.SelectSingleNode("smtp-config") as XmlElement; if (smtpConfig != null) { profile.setSmtpSSL(ExString.EqualsDefault(element.GetAttribute("smtp-ssl"), "yes", false)); profile.setSmtpServer(smtpConfig.GetAttribute("smtp-server")); profile.setSmtpPort(smtpConfig.GetAttribute("smtp-port")); profile.setSmtpUser(smtpConfig.GetAttribute("smtp-user")); profile.setSmtpPwd(smtpConfig.GetAttribute("smtp-pwd")); } // NORMAL ASSESMENT RULES foreach (XmlElement ell in element.SelectNodes("assessment-rule")) { var currentAssessmentRule = new AssessmentRule("", 0, false); fillAssesmentRule(ell, currentAssessmentRule, parameters); profile.addRule(currentAssessmentRule); } // TIMED ASSESMENT RULES foreach (XmlElement ell in element.SelectNodes("timed-assessment-rule")) { bool usesEndConditions = ExString.EqualsDefault(element.GetAttribute("usesEndConditions"), "yes", false); var tRule = new TimedAssessmentRule("", 0, false); fillAssesmentRule(ell, tRule, parameters); if (usesEndConditions || tRule.isRepeatRule()) { tRule.setUsesEndConditions(usesEndConditions); } tRule.setInitConditions(DOMParserUtility.DOMParse(element.SelectSingleNode("init-condition"), parameters) as Conditions ?? new Conditions()); tRule.setEndConditions(DOMParserUtility.DOMParse(element.SelectSingleNode("end-condition"), parameters) as Conditions ?? new Conditions()); foreach (XmlElement ell_ in element.SelectNodes("assessEffect")) { int timeMin = ExParsers.ParseDefault(ell_.GetAttribute("time-min"), int.MinValue); int timeMax = ExParsers.ParseDefault(ell_.GetAttribute("time-max"), int.MinValue); if (timeMin != int.MinValue && timeMax != int.MaxValue) { tRule.addEffect(timeMin, timeMax); } else { tRule.addEffect(); } } profile.addRule(tRule); } return(profile); }