Beispiel #1
0
        /// <summary>
        /// Checks if related to theme package has been already uploaded.
        /// In case it was not uploaded - upload package.
        /// Check attempt has been created and get attempt id.
        /// </summary>
        /// <param name="theme">Theme object represents specified theme.</param>
        /// <returns>Long integer value representing attempt id.</returns>
        public long GetAttemptId(Theme theme)
        {
            GetCurrentUserIdentifier();
            AttemptItemIdentifier attemptId = null;
            ActivityPackageItemIdentifier organizationId;
            var packageId = GetPackageIdentifier(theme.CourseRef);

            // in case package has not been uploaded yet.
            if (packageId == null)
            {
                string zipPath = CourseService.Export(theme.CourseRef);
                Package package = new ZipPackage(zipPath);
                package.CourseID = theme.CourseRef;
                packageId = AddPackage(package);
                organizationId = GetOrganizationIdentifier(packageId);
                attemptId = CreateAttempt(organizationId.GetKey(), theme.Id);
            }
            // otherwise check if attempt was created
            else
            {
                organizationId = GetOrganizationIdentifier(packageId);

                AttemptItemIdentifier attId = GetAttemptIdentifier(organizationId, theme.Id);
                if (attId != null)
                {
                    attemptId = attId;
                }
                else
                {
                    attemptId = CreateAttempt(organizationId.GetKey(), theme.Id);
                }
            }

            return attemptId.GetKey();
        }
Beispiel #2
0
 public void ZipPackagePropertiesTest2()
 {
     ZipPackageTestsSetUp();
     zipPackage = new ZipPackage("IUDICO/TestingSystem/Models/VOs/");
     Assert.AreEqual(zipPackage.CourseID, default(int));
     Assert.AreEqual(zipPackage.FileName, default(string));
     Assert.AreEqual(zipPackage.ZipPath, "IUDICO/TestingSystem/Models/VOs/");
     Assert.AreEqual(zipPackage.Owner, default(long));
     Assert.AreEqual(zipPackage.UploadDateTime, null);
 }
Beispiel #3
0
 public void ZipPackageTestsSetUp()
 {
     zipPackage = new ZipPackage("IUDICO/TestingSystem/Models/VOs/", 12345,
                                               new DateTime(2011, 11, 11), "package.zip", 1);
 }