/// <summary> /// Checks if related to topic 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="topic">Topic object represents specified topic.</param> /// <returns>Long integer value representing attempt id.</returns> public long GetAttemptId(Topic topic) { GetCurrentUserIdentifier(); AttemptItemIdentifier attemptId = null; ActivityPackageItemIdentifier organizationId; var packageId = GetPackageIdentifier(topic.CourseRef.Value); // in case package has not been uploaded yet. if (packageId == null) { string zipPath = CourseService.Export(topic.CourseRef.Value); Package package = new ZipPackage(zipPath); package.CourseID = topic.CourseRef.Value; packageId = AddPackage(package); organizationId = GetOrganizationIdentifier(packageId); attemptId = CreateAttempt(organizationId.GetKey(), topic.Id); } // otherwise check if attempt was created else { organizationId = GetOrganizationIdentifier(packageId); AttemptItemIdentifier attId = GetAttemptIdentifier(organizationId, topic.Id); if (attId != null) { attemptId = attId; } else { attemptId = CreateAttempt(organizationId.GetKey(), topic.Id); } } return attemptId.GetKey(); }
/// <summary> /// Checks if related to topic 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="curriculumChapterTopicId">Iudico CurriculumChapterTopic.Id</param> /// <param name="courseId">Iudico Course.Id</param> /// <param name="topicType"><see cref="TopicTypeEnum"/> enumeration value.</param> /// <returns>Long integer value representing attempt id.</returns> public long GetAttemptId(int curriculumChapterTopicId, int courseId, TopicTypeEnum topicType) { this.GetCurrentUserIdentifier(); AttemptItemIdentifier attemptId; ActivityPackageItemIdentifier organizationId; var packageId = this.GetPackageIdentifier(courseId); // in case package has not been uploaded yet. if (packageId == null) { string zipPath = this.CourseService.Export(courseId, true); Package package = new ZipPackage(zipPath); package.CourseID = courseId; packageId = this.AddPackage(package); organizationId = this.GetOrganizationIdentifier(packageId); attemptId = this.CreateAttempt(organizationId.GetKey(), curriculumChapterTopicId, topicType); } else { // otherwise check if attempt was created organizationId = this.GetOrganizationIdentifier(packageId); AttemptItemIdentifier attId = this.GetAttemptIdentifier( organizationId, curriculumChapterTopicId, topicType); attemptId = attId ?? this.CreateAttempt(organizationId.GetKey(), curriculumChapterTopicId, topicType); } return attemptId.GetKey(); }
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); }
public void ZipPackageTestsSetUp() { zipPackage = new ZipPackage("IUDICO/TestingSystem/Models/VOs/", 12345, new DateTime(2011, 11, 11), "package.zip", 1); }