public string studyCreate(string studyName, string hearIn, string seeIn, int hours, int minutes, int seconds, int trials, int target, int adminID)
 {
     DataAccessor database = new DataAccessor();
     Study s = database.createStudy(studyName, hearIn, seeIn, hours, minutes, seconds, trials, target);
     StudiesAdmin sa = database.createStudiesAdmin(s.ID, adminID);
     return ("Created " + s.Name + " with admin " + sa.Admin.Username + ".");
 }
 public string studyDelete(int studyID)
 {
     DataAccessor database = new DataAccessor();
     Study s = database.getStudyByID(studyID);
     string name = s.Name;
     if (database.deleteStudy(studyID))
     {
         return name + " was successfully deleted.";
     }
     return "Error.";
 }
 public string saveTrialBlock(TrialBlockData results)
 {
     DataAccessor database = new DataAccessor();
     results.parseStrings();
     bool complete = database.recordTrialBlock(results);
     if (complete) return "You have now completed the study.  Thank you for participating.";
     bool? offerAnother = database.allowTrial(database.getUserByID(results.userID));
     if (offerAnother == null) return "You have now completed the study.  Thank you for participating.";
     else if (offerAnother == true) return "Your results have been recorded.  Please participate again today. <INPUT TYPE=\"button\" onClick=\"history.go(0)\" VALUE=\"Go again now.\">";
     return "Thank you for your continuing participation.  That will be all for today.";
 }
 public ActionResult adminPanel(int studyID, int userID)
 {
     DataAccessor database = new DataAccessor();
     if (database.validStudyAndUserIDs(studyID, userID))
     {
         ViewData["UserID"] = userID;
         ViewData["StudyID"] = studyID;
         return PartialView("adminPanel", database.userStudyBlocks(userID, studyID));
     }
     else
         return PartialView("SelectSomething");
 }
 public ActionResult Index( FormCollection form )
 {
     DataAccessor data = new DataAccessor();
     String username = form["username"];
     String password = form["password"];
     if (!data.isUser(username))
     {
         Session["Error"] = "No such user: "******"Error");
     }
     User current = data.login(username, password);
     if (current == null)
     {
         Session["Error"] = "Invalid password";
         return RedirectToAction("Error");
     }
     Session["User"] = current;
     return View();
 }
 public string studyUpdate(int studyID, string hearIn, string seeIn, int hours, int minutes, int seconds, int trials, double fluency)
 {
     DataAccessor database = new DataAccessor();
     database.updateStudy(studyID, hearIn, seeIn, hours, minutes, seconds, trials, fluency);
     return "Update successful.";
 }
 public String getWord(int key)
 {
     DataAccessor database = new DataAccessor();
     return serializer.Serialize(new SimpleWord(database.getWord(key)));
 }
 public bool checkUserMovable(int userID)
 {
     DataAccessor database = new DataAccessor();
     return database.userEligibileToMove(userID);
 }
        public string userUpdate(int userID, bool userActive, string userPassword, int studyID, int studyUserGroupID)
        {
            DataAccessor database = new DataAccessor();
            User u = database.getUserByID(userID);
            User uu = database.login(u.Username, userPassword);
            StudiesUser su = database.studiesUserFromUser(u);
            bool movable = database.userEligibileToMove(userID);

            if (database.studyIDFromUser(u) != studyID || su.UserGroupID != studyUserGroupID)
            {
                if (!movable) return "Error: Cannot move user.";
                database.updateStudiesUser(userID, studyID, studyUserGroupID);
            }

            if(uu == null || (u.Active != userActive) )
            {
                database.updateUser(userID, userActive, userPassword);
            }
            return "Update successful.";
        }
示例#10
0
 public string userDelete(int userID)
 {
     DataAccessor database = new DataAccessor();
     User u = database.getUserByID(userID);
     string username = u.Username;
     if (database.deleteUser(userID))
     {
         return username + " was successfully deleted.";
     }
     return "Error.";
 }
示例#11
0
 public string userCreate(string userName, bool userActive, string userPassword, int studyID, int studyUserGroupID)
 {
     DataAccessor database = new DataAccessor();
     User u;
     StudiesUser su;
     try
     {
         u = database.createUser(userName, userActive, userPassword);
     }
     catch (Exception e)
     {
         return "Error attemping to create " + userName + ": " + e.Message;
     }
     try
     {
         su = database.createStudiesUsers(u.ID, studyID, studyUserGroupID);
     }
     catch (Exception e)
     {
         try
         {
             database.deleteUser(u.ID);
         }
         catch (Exception ohshit)
         {
             return "Failed to associate user with study, cannot delete user.";
         }
         return "Error attemping to associate " + userName + " with StudyID[" + studyID.ToString() + "] StudyUserGroupID[" + studyUserGroupID.ToString() + "]: " + e.Message;
     }
     return (u.Username + " is now part of " + su.Study.Name + ".");
 }