public object Clone()
        {
            AssessmentProfile ap = (AssessmentProfile)this.MemberwiseClone();

            ap.email = (email != null ? email : null);
            if (flags != null)
            {
                ap.flags = new List <string>();
                foreach (string s in flags)
                {
                    ap.flags.Add((s != null ? s : null));
                }
            }
            ap.name = (name != null ? name : null);
            if (rules != null)
            {
                ap.rules = new List <AssessmentRule>();
                foreach (AssessmentRule ar in rules)
                {
                    ap.rules.Add((AssessmentRule)ar.Clone());
                }
            }
            ap.sendByEmail     = sendByEmail;
            ap.showReportAtEnd = showReportAtEnd;
            ap.smtpPort        = (smtpPort != null ? smtpPort : null);
            ap.smtpPwd         = (smtpPwd != null ? smtpPwd : null);
            ap.smtpServer      = (smtpServer != null ? smtpServer : null);
            ap.smtpSSL         = smtpSSL;
            ap.smtpUser        = (smtpUser != null ? smtpUser : null);
            if (vars != null)
            {
                ap.vars = new List <string>();
                foreach (string s in vars)
                {
                    ap.vars.Add((s != null ? s : null));
                }
            }
            ap.scorm12   = scorm12;
            ap.scorm2004 = scorm2004;
            return(ap);
        }
        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);
        }
Exemplo n.º 3
0
 /**
  * Adds new assessment profile
  *
  * @param assessProfile
  *            the new assessment profile to add
  */
 public void addAssessmentProfile(AssessmentProfile assessProfile)
 {
     assessmentProfiles.Add(assessProfile);
 }