Exemple #1
0
        public void DeleteResource(int resourceID)
        {
            DatabaseCall dbc = new DatabaseCall("Courses_DeleteResource", DBCallType.Execute);

            dbc.AddParameter("@CourseResourceID", resourceID);
            dbc.Execute();
        }
Exemple #2
0
        public static CourseM Load(System.Guid courseGUID)
        {
            DatabaseCall dbc = new DatabaseCall("Courses_LoadCourseByGUID", DBCallType.Select);

            dbc.AddParameter("@CourseGUID", courseGUID);
            return(LoadCourseFromDatabase(dbc));
        }
Exemple #3
0
        internal void Delete()
        {
            DatabaseCall dbc = new DatabaseCall("Courses_DeleteCourse", DBCallType.Execute);

            dbc.AddParameter("@CourseID", this._courseID);
            dbc.Execute();
        }
        public void ClearStarter()
        {
            DatabaseCall dbc = new DatabaseCall("Assignments_ClearStarter", DBCallType.Execute);

            dbc.AddParameter("@AssignmentID", _assignmentID);
            dbc.Execute();
        }
Exemple #5
0
        public static CourseM Load(string courseName)
        {
            DatabaseCall dbc = new DatabaseCall("Courses_LoadCourseByName", DBCallType.Select);

            dbc.AddParameter("@ShortName", courseName);
            return(LoadCourseFromDatabase(dbc));
        }
Exemple #6
0
        private static UserM LoadUserFromDatabase(DatabaseCall dbc)
        {
            UserM newUser = new UserM();

            System.Data.DataSet ds = new System.Data.DataSet();
            dbc.Fill(ds);
            if ((ds.Tables.Count <= 0) || (ds.Tables[0].Rows.Count <= 0))
            {
                return(newUser);
            }

            newUser._userID            = Convert.ToInt32(ds.Tables[0].Rows[0]["UserID"]);
            newUser._lastName          = ds.Tables[0].Rows[0]["LastName"].ToString();
            newUser._middleName        = ds.Tables[0].Rows[0]["MiddleName"].ToString();
            newUser._firstName         = ds.Tables[0].Rows[0]["FirstName"].ToString();
            newUser._emailAddress      = ds.Tables[0].Rows[0]["Email"].ToString();
            newUser._universityID      = ds.Tables[0].Rows[0]["UniversityIdentifier"].ToString();
            newUser._username          = ds.Tables[0].Rows[0]["UserName"].ToString();
            newUser._password          = ds.Tables[0].Rows[0]["Password"].ToString();
            newUser._lastUpdatedDate   = Convert.ToDateTime(ds.Tables[0].Rows[0]["LastUpdatedDate"].ToString());
            newUser._lastUpdatedUserID = Convert.ToInt32(ds.Tables[0].Rows[0]["LastUpdatedUserID"]);
            newUser._changedPassword   = Convert.ToBoolean(ds.Tables[0].Rows[0]["ChangedPassword"]);

            return(newUser);
        }
Exemple #7
0
        private static CourseM LoadCourseFromDatabase(DatabaseCall dbc)
        {
            CourseM newCourse = new CourseM();

            System.Data.DataSet ds = new System.Data.DataSet();
            dbc.Fill(ds);

            if ((ds.Tables.Count <= 0) || (ds.Tables[0].Rows.Count <= 0))
            {
                return(newCourse);
            }

            newCourse._courseID              = Convert.ToInt32(ds.Tables[0].Rows[0]["CourseID"]);
            newCourse._courseGUID            = new System.Guid(ds.Tables[0].Rows[0]["CourseGUID"].ToString());
            newCourse.Name                   = ds.Tables[0].Rows[0]["ShortName"].ToString();
            newCourse.Description            = ds.Tables[0].Rows[0]["Description"].ToString();
            newCourse.LastUpdatedDate        = Convert.ToDateTime(ds.Tables[0].Rows[0]["LastUpdatedDate"]);
            newCourse.LastUpdatedUserID      = Convert.ToInt32(ds.Tables[0].Rows[0]["LastUpdatedUserID"]);
            newCourse.HomepageURL            = ds.Tables[0].Rows[0]["HomepageURL"].ToString();
            newCourse.SendEmailRemindersFlag = Convert.ToBoolean(ds.Tables[0].Rows[0]["SendEmailRemindersFlag"]);
            newCourse.StartDate              = Convert.ToDateTime(ds.Tables[0].Rows[0]["StartDate"]);
            newCourse.EndDate                = Convert.ToDateTime(ds.Tables[0].Rows[0]["EndDate"]);
            newCourse.RootStoragePath        = ds.Tables[0].Rows[0]["RootStoragePath"].ToString();

            return(newCourse);
        }
        internal static void Delete(int assignid)
        {
            DatabaseCall dbc = new DatabaseCall("Assignments_Purge", DBCallType.Execute);

            dbc.AddParameter("@AssignmentID", assignid);
            dbc.Execute();
        }
Exemple #9
0
        internal static bool CommitImport(string importID)
        {
            DatabaseCall dbc = new DatabaseCall("Import_LoadPendingImport", DBCallType.Select);

            dbc.AddParameter("@ImportID", importID);
            System.Data.DataSet ds = new System.Data.DataSet();
            dbc.Fill(ds);

            if ((ds.Tables.Count <= 0) || (ds.Tables[0].Rows.Count <= 0))
            {
                return(false);
            }

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                try
                {
                    UserM user = UserM.Load(Convert.ToInt32(ds.Tables[0].Rows[i]["UserID"]));
                    user.GenerateNewPassword();
                    user.AddToCourse(Convert.ToInt32(ds.Tables[0].Rows[i]["CourseID"]));
                }
                catch
                {
                }
            }
            return(true);
        }
Exemple #10
0
        public static RoleM[] GetAllRoles()
        {
            DatabaseCall dbc = new DatabaseCall("Roles_BrowseAll", DBCallType.Select);

            System.Data.DataSet ds = new System.Data.DataSet();
            dbc.Fill(ds);

            if (ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            {
                return(new RoleM[0]);
            }
            else
            {
                RoleM[] roles = new RoleM[(ds.Tables[0].Rows.Count)];
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int    roleID   = Convert.ToInt32(ds.Tables[0].Rows[i]["RoleID"]);
                    string roleName = ds.Tables[0].Rows[i]["Name"].ToString();

                    // replace with localized name if available
                    string localizedName = SharedSupport.GetLocalizedString("UserRole_" + roleName);
                    if (localizedName != String.Empty)
                    {
                        roleName = localizedName;
                    }
                    roles[i] = new RoleM(roleID, roleName);
                }
                return(roles);
            }
        }
Exemple #11
0
        internal static void AbortImport(string importID)
        {
            DatabaseCall dbc = new DatabaseCall("Import_AbortImport", DBCallType.Execute);

            dbc.AddParameter("@ImportID", importID);

            dbc.Execute();
        }
        private void AddFile(string filename)
        {
            DatabaseCall dbc = new DatabaseCall("StudentAssignments_AddFile", DBCallType.Execute);

            dbc.AddParameter("@UserAssignmentID", _userAssignmentID);
            dbc.AddParameter("@FileName", filename);
            dbc.Execute();
        }
Exemple #13
0
        public static UserM LoadByEmail(string email)
        {
            DatabaseCall dbc = new DatabaseCall("Users_LoadUserByEmail", DBCallType.Select);

            dbc.AddParameter("@Email", email);

            return(LoadUserFromDatabase(dbc));
        }
Exemple #14
0
        public static UserM Load(int userID)
        {
            DatabaseCall dbc = new DatabaseCall("Users_LoadUserByUserID", DBCallType.Select);

            dbc.AddParameter("@UserID", userID);

            return(LoadUserFromDatabase(dbc));
        }
Exemple #15
0
        public static UserM LoadByUserName(string username)
        {
            DatabaseCall dbc = new DatabaseCall("Users_LoadUserByUsername", DBCallType.Select);

            dbc.AddParameter("@UserName", username);

            return(LoadUserFromDatabase(dbc));
        }
Exemple #16
0
        public static UserM LoadByUniversityID(string universityID)
        {
            DatabaseCall dbc = new DatabaseCall("Users_LoadUserByUniversityID", DBCallType.Select);

            dbc.AddParameter("@UniversityID", universityID);

            return(LoadUserFromDatabase(dbc));
        }
Exemple #17
0
        public static void RemoveFromCourse(int userID, int courseID)
        {
            DatabaseCall dbc = new DatabaseCall("Users_Purge", DBCallType.Execute);

            dbc.AddParameter("@UserID", userID);
            dbc.AddParameter("@CourseID", courseID);
            dbc.Execute();
        }
        public string StarterFilesXML(System.Guid guid)
        {
            try
            {
                DataSet     ds              = new DataSet();
                string      downloadRoot    = SharedSupport.AddBackSlashToDirectory(System.Web.HttpContext.Current.Request.MapPath(String.Empty, Constants.ASSIGNMENTMANAGER_DOWNLOAD_DIRECTORY, true));
                string      storageLocation = String.Empty;
                AssignmentM assign          = AssignmentM.Load(_assignmentID);
                storageLocation = SharedSupport.AddBackSlashToDirectory(assign.StorageDirectory + Constants.STARTER_PROJECT_PATH);

                //add unique guid to download path
                downloadRoot = downloadRoot + SharedSupport.AddBackSlashToDirectory(guid.ToString());

                DatabaseCall dbc = new DatabaseCall("Assignments_GetFiles", DBCallType.Select);
                dbc.AddParameter("@AssignmentID", _assignmentID);
                dbc.Fill(ds);

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    string source      = String.Empty;
                    string destination = String.Empty;

                    string filename = ds.Tables[0].Rows[i]["FileName"].ToString().Trim();
                    filename    = filename.Replace(@"\", @"/");
                    source      = SharedSupport.RemoveIllegalFilePathCharacters(storageLocation + filename);
                    destination = SharedSupport.RemoveIllegalFilePathCharacters(downloadRoot + filename);
                    //check to see if destination directory exists
                    string destinationDir = destination.Substring(0, destination.LastIndexOf("\\") + 1);
                    if (!Directory.Exists(destinationDir))
                    {
                        Directory.CreateDirectory(destinationDir);
                    }
                    //check if file is there
                    if (System.IO.File.Exists(source))
                    {
                        System.IO.File.Copy(source, destination, true);
                    }
                    else
                    {
                        throw new System.IO.FileNotFoundException(SharedSupport.GetLocalizedString("Assignment_UploadedFileNotFound"));
                    }

                    if (filename.StartsWith(@"/"))
                    {
                        ds.Tables[0].Rows[i]["FileName"] = guid + filename;
                    }
                    else
                    {
                        ds.Tables[0].Rows[i]["FileName"] = guid + @"/" + filename;
                    }
                }
                return(ds.GetXml());
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
        public static AssignmentList GetSubmissionsForAssignment(int AssignmentID)
        {
            DatabaseCall   dbc        = new DatabaseCall("Courses_GetSubmissionsList", DBCallType.Select);
            AssignmentList assignList = new AssignmentList();

            dbc.AddParameter("@AssignmentID", AssignmentID);
            dbc.Fill(assignList.assignmentDS);
            return(assignList);
        }
Exemple #20
0
        public void AddResource(string name, string resourceValue)
        {
            DatabaseCall dbc = new DatabaseCall("Courses_AddResource", DBCallType.Execute);

            dbc.AddParameter("@CourseID", _courseID);
            dbc.AddParameter("@Name", name);
            dbc.AddParameter("@ResourceValue", resourceValue);
            dbc.Execute();
        }
Exemple #21
0
        public static void SetRoleInCourse(int userID, int courseID, int roleID)
        {
            DatabaseCall dbc = new DatabaseCall("Roles_UpdateRoleInCourse", DBCallType.Execute);

            dbc.AddParameter("@UserID", userID);
            dbc.AddParameter("@CourseID", courseID);
            dbc.AddParameter("@RoleID", roleID);
            dbc.Execute();
        }
        public void ClearSubmissions()
        {
            DatabaseCall dbc = new DatabaseCall("StudentAssignments_ClearSubmissions", DBCallType.Execute);

            dbc.AddParameter("@UserID", _userID);
            dbc.AddParameter("@AssignmentID", _assignmentID);

            dbc.Execute();
        }
Exemple #23
0
        public void ImportToCourse(int courseID, string importID)
        {
            DatabaseCall dbc = new DatabaseCall("Users_ImportToCourse", DBCallType.Execute);

            dbc.AddParameter("@UserID", _userID);
            dbc.AddParameter("@CourseID", courseID);
            dbc.AddParameter("@ImportID", importID);
            dbc.Execute();
        }
Exemple #24
0
        internal void AddToCourse(int courseID, PermissionsID roleID)
        {
            DatabaseCall dbc = new DatabaseCall("Users_AddToCourse", DBCallType.Execute);

            dbc.AddParameter("@UserID", _userID);
            dbc.AddParameter("@CourseID", courseID);
            dbc.AddParameter("RoleID", (int)roleID);
            dbc.Execute();
        }
        private int SaveAssignmentToDatabase(StoredProcType procType)
        {
            int          retID = 0;
            DatabaseCall dbc   = null;

            switch (procType)
            {
            case StoredProcType.New:
                dbc = new DatabaseCall("Assignments_AddNewAssignment", DBCallType.Execute);
                dbc.AddOutputParameter("@AssignmentID");
                dbc.AddOutputParameter("@CourseAssignmentID");
                break;

            case StoredProcType.Update:
                dbc = new DatabaseCall("Assignments_UpdateExistingAssignment", DBCallType.Execute);
                dbc.AddParameter("@AssignmentID", this.AssignmentID);
                break;

            default:
                throw new Exception("Invalid Stored Procedure");
            }

            dbc.AddParameter("@ShortName", this.ShortName);
            dbc.AddNTextParameter("@Description", this.Description);
            dbc.AddParameter("@LastUpdatedDate", this.LastUpdatedDate);
            dbc.AddParameter("@LastUpdatedUserID", this.LastUpdatedUserID);
            dbc.AddParameter("@StarterProjectFlag", this.StarterProjectFlag);
            dbc.AddParameter("@MakeFile", this.MakeFile);
            dbc.AddParameter("@CompilerType", this.CompilerType);
            dbc.AddParameter("@CourseID", this.CourseID);
            dbc.AddParameter("@DueDate", this.DueDate);
            dbc.AddParameter("@MultipleSubmitsFlag", this.MultipleSubmitsFlag);
            dbc.AddParameter("@SendReminders", this.SendReminders);
            dbc.AddParameter("@AutoGradeFlag", this.AutoGradeFlag);
            dbc.AddParameter("@InputFile", this.InputFile);   // set to either DBNull or String Valu);
            dbc.AddParameter("@OutputFile", this.OutputFile); // set to either DBNull or String Valu);
            dbc.AddParameter("@GradeType", this.GradeType);
            dbc.AddParameter("@AutoCompileFlag", this.AutoCompileFlag);
            dbc.AddParameter("@AssignmentURL", this.AssignmentURL);   // set to either DBNull or String Valu);
            dbc.AddParameter("@CommandLineArgs", this.CommandLineArgs);
            dbc.AddParameter("@SendPastDue", this.SendPastDue);
            dbc.AddParameter("@SendNewProject", this.SendNewProject);
            dbc.AddParameter("@SendUpdatedProject", this.SendUpdatedProject);
            dbc.AddParameter("@PastDueWarningDays", this.PastDueWarningDays);
            dbc.AddParameter("@ReminderWarningDays", this.ReminderWarningDays);

            dbc.Execute();

            if (procType == StoredProcType.New)
            {
                retID = Convert.ToInt32(dbc.GetOutputParam("@AssignmentID"));
                _courseAssignmentID = Convert.ToInt32(dbc.GetOutputParam("@CourseAssignmentID"));
            }

            return(retID);
        }
Exemple #26
0
        public static UserList GetListFromCourse(int courseID)
        {
            UserList     userList = new UserList();
            DatabaseCall dbc      = new DatabaseCall("Courses_GetUserList", DBCallType.Select);

            dbc.AddParameter("@CourseID", courseID);

            dbc.Fill(userList.ds);
            return(userList);
        }
        public static AssignmentList GetAssignmentListNotInCourse(int CourseID)
        {
            //****
            DatabaseCall   dbc        = new DatabaseCall("Courses_GetAssignmentListNotInCourse", DBCallType.Select);
            AssignmentList assignList = new AssignmentList();

            dbc.AddParameter("@CourseID", CourseID);
            dbc.Fill(assignList.assignmentDS);
            return(assignList);
        }
Exemple #28
0
        private int saveCourseToDatabase(CourseStoredProcType sprocType)
        {
            DatabaseCall dbc;
            int          retID = 0;

            if (sprocType == CourseStoredProcType.Add)
            {
                dbc = new DatabaseCall("Courses_AddNewCourse", DBCallType.Execute);
                dbc.AddOutputParameter("@CourseID");
            }
            else if (sprocType == CourseStoredProcType.Update)
            {
                dbc = new DatabaseCall("Courses_UpdateExistingCourse", DBCallType.Execute);
                dbc.AddParameter("@CourseID", this._courseID);
            }
            else
            {
                throw new Exception("Unknown Stored Procedure Type");
            }

            dbc.AddParameter("@CourseGUID", _courseGUID);
            dbc.AddParameter("@ShortName", _courseName);
            dbc.AddNTextParameter("@Description", _description);
            dbc.AddParameter("@LastUpdatedDate", System.DateTime.Now);
            dbc.AddParameter("@LastUpdatedUserID", _lastUpdatedUserID);
            dbc.AddParameter("@HomepageURL", _homepageURL);
            dbc.AddParameter("@MultipleSubmitsFlag", false);
            dbc.AddParameter("@SendEmailRemindersFlag", _sendEmailRemindersFlag);
            dbc.AddParameter("@StartDate", _startDate);
            dbc.AddParameter("@EndDate", _endDate);
            dbc.AddParameter("@RootStoragePath", _rootStoragePath);

            dbc.Execute();

            if (sprocType == CourseStoredProcType.Add)
            {
                try
                {
                    retID          = Convert.ToInt32(dbc.GetOutputParam("@CourseID"));
                    this._courseID = retID;
                }
                catch
                {
                }
            }
            //Write course data to file
            saveCourseXML();
            return(retID);
        }
        public static StudentAssignmentM Load(int userAssignmentID)
        {
            System.Data.DataSet ds = new System.Data.DataSet();

            DatabaseCall dbc = new DatabaseCall("StudentAssignments_LoadAssignmentByUserAssignmentID", DBCallType.Select);

            dbc.AddParameter("@UserAssignmentID", userAssignmentID);

            dbc.Fill(ds);

            if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)
            {
                return(null);
            }
            return(PopulateNewAssignment(ds));
        }
        internal static AssignmentM Load(int assignmentID)
        {
            //set courseID = 0, it will get overwritten when we load.
            AssignmentM retVal = new AssignmentM(0);

            DatabaseCall dbc = new DatabaseCall("Assignments_LoadAssignment", DBCallType.Select);

            dbc.AddParameter("@AssignmentID", assignmentID);
            DataSet ds = new DataSet();

            dbc.Fill(ds);
            if (ds.Tables.Count <= 0)
            {
                return(null);
            }

            // Populate the return value.
            retVal._assignmentID       = assignmentID;
            retVal.Description         = ds.Tables[0].Rows[0]["Description"].ToString();
            retVal.StarterProjectFlag  = Convert.ToBoolean(ds.Tables[0].Rows[0]["StarterProjectFlag"]);
            retVal.ShortName           = ds.Tables[0].Rows[0]["ShortName"].ToString();
            retVal.CompilerType        = ds.Tables[0].Rows[0]["CompilerType"].ToString();
            retVal.LastUpdatedDate     = Convert.ToDateTime(ds.Tables[0].Rows[0]["LastUpdatedDate"].ToString());
            retVal.LastUpdatedUserID   = Convert.ToInt32(ds.Tables[0].Rows[0]["LastUpdatedUserID"]);
            retVal.DueDate             = Convert.ToDateTime(ds.Tables[0].Rows[0]["DueDate"].ToString());
            retVal.AssignmentURL       = ds.Tables[0].Rows[0]["AssignmentURL"].ToString();
            retVal.CommandLineArgs     = ds.Tables[0].Rows[0]["CommandLineArgs"].ToString();
            retVal.InputFile           = ds.Tables[0].Rows[0]["InputFile"].ToString();
            retVal.OutputFile          = ds.Tables[0].Rows[0]["OutputFile"].ToString();
            retVal.MultipleSubmitsFlag = Convert.ToBoolean(ds.Tables[0].Rows[0]["MultipleSubmitsFlag"]);
            retVal.AutoGradeFlag       = Convert.ToBoolean(ds.Tables[0].Rows[0]["AutoGradeFlag"]);
            retVal.AutoCompileFlag     = Convert.ToBoolean(ds.Tables[0].Rows[0]["AutoCompileFlag"]);
            retVal.SendReminders       = Convert.ToBoolean(ds.Tables[0].Rows[0]["SendReminders"]);
            retVal.SendPastDue         = Convert.ToBoolean(ds.Tables[0].Rows[0]["SendPastDue"]);
            retVal.SendNewProject      = Convert.ToBoolean(ds.Tables[0].Rows[0]["SendNewProject"]);
            retVal.SendUpdatedProject  = Convert.ToBoolean(ds.Tables[0].Rows[0]["SendUpdatedProject"]);
            retVal.GradeType           = Convert.ToByte(ds.Tables[0].Rows[0]["GradeType"]);
            retVal.CourseAssignmentID  = Convert.ToInt32(ds.Tables[0].Rows[0]["CourseAssignmentID"]);
            retVal.ReminderWarningDays = Convert.ToInt32(ds.Tables[0].Rows[0]["ReminderWarningDays"]);
            retVal.PastDueWarningDays  = Convert.ToInt32(ds.Tables[0].Rows[0]["PastDueWarningDays"]);

            retVal.CourseID = Convert.ToInt32(ds.Tables[0].Rows[0]["CourseID"]);
            return(retVal);
        }