Exemple #1
0
 def __init__(self, s, base_url, mb, exname):
     # s = requests.session()  # 全局参数
     self.s = s
     self.base_url = base_url
     self.A = MssqlUtil()
     sql1 = "select a.ExperimentID,a.CaseID from dbo.AFCS_Experiment a join dbo.AFCS_TeacherInfo b " \
         "on a.AddUser = b.TeacherID " \
         "where MobileNo = '"+mb+"' " \
         "and ExperimentName = '"+exname+"' " \
         "and ExperimentStatus = '1'"
     B1 = self.A.mssql_getrows(sql1)  #根据教师手机号、实验名找该教师下已开始的实验id、案例id
     self.ExperimentID1 = str(B1[0][0])
     self.CaseID1 = str(B1[0][1])
     sql2 = "SELECT ClassID FROM dbo.AFCS_ClassSelect where ExperimentID ='" + self.ExperimentID1 + "'"
     B2 = self.A.mssql_getrows(sql2)  #根据教师实验id找实验下的班级id 取第1个班级
     self.ClassID2 = str(B2[0][0])
     sql3 = "select QuestionsID,QuestionsContent,QuestionOrderNo from   dbo.AFCS_PolicyCaseQuestions where CaseID = '" + self.CaseID1 + "' and QuestionType='1'"
     sql3s = "select * from   dbo.AFCS_PolicyCaseQuestions where CaseID = '" + self.CaseID1 + "' and QuestionType='2'"
     B3 = self.A.mssql_getrows(sql3)  #根据案例id找思考题id (简答题)
     B3s = self.A.mssql_getrows(sql3s)  #根据案例id找思考题id (选择题)
     self.QuestionsID3 = str(B3[0][0])
     self.QuestionsContent3 = str(B3[0][1])
     self.QuestionOrderNo3 = str(B3[0][2])
     self.QuestionsID3s = str(B3s[0][0])
     self.QuestionsContent3s = str(B3s[0][1])
     self.QuestionOrderNo3s = str(B3s[0][2])
     sql4 = "select StudentID FROM  dbo.AFCS_ClassStudents where ClassID = '" + self.ClassID2 + "'"
     B4 = self.A.mssql_getrows(sql4)  #根据班级id找学生id 取第一个学生
     self.StudentID4 = str(B4[0][0])
class ScreenOperationTmp():
    def __init__(self, ExperimentID, base_url):
        self.base_url = base_url
        self.A = MssqlUtil()
        sqlselgroup = "select GroupID from dbo.AFCS_Group where ExperimentID ='" + ExperimentID + "'"
        Bselgroup = self.A.mssql_getrows(sqlselgroup)
        self.Groupidlist = Bselgroup

    def JoinGroup(self, groupId, studentId):  #观点分组
        # url = "http://192.168.0.167/kesgo.Service/wcf/DiscussionService.svc/JoinGroup"  # 问号前面的
        url = urljoin(self.base_url,
                      "kesgo.Service/wcf/DiscussionService.svc/JoinGroup")
        par = {"groupId": groupId, "studentId": studentId}
        h = {
            "User-Agent":
            "Mozilla/5.0 (Linux; Android 8.1.0; MI 8 Build/OPM1.171019.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/62.0.3202.84 Mobile Safari/537.36",
            "Accept": "application/json, text/plain, */*"
        }
        r = requests.get(url, params=par, headers=h)
 def setUpClass(cls):
     cls.A = MssqlUtil()
Exemple #4
0
class ScreenOperationOne():
    def __init__(self, s, base_url, mb, exname):
        # s = requests.session()  # 全局参数
        self.s = s
        self.base_url = base_url
        self.A = MssqlUtil()
        sql1 = "select a.ExperimentID,a.CaseID from dbo.AFCS_Experiment a join dbo.AFCS_TeacherInfo b " \
            "on a.AddUser = b.TeacherID " \
            "where MobileNo = '"+mb+"' " \
            "and ExperimentName = '"+exname+"' " \
            "and ExperimentStatus = '1'"
        B1 = self.A.mssql_getrows(sql1)  #根据教师手机号、实验名找该教师下已开始的实验id、案例id
        self.ExperimentID1 = str(B1[0][0])
        self.CaseID1 = str(B1[0][1])
        sql2 = "SELECT ClassID FROM dbo.AFCS_ClassSelect where ExperimentID ='" + self.ExperimentID1 + "'"
        B2 = self.A.mssql_getrows(sql2)  #根据教师实验id找实验下的班级id 取第1个班级
        self.ClassID2 = str(B2[0][0])
        sql3 = "select QuestionsID,QuestionsContent,QuestionOrderNo from   dbo.AFCS_PolicyCaseQuestions where CaseID = '" + self.CaseID1 + "' and QuestionType='1'"
        sql3s = "select * from   dbo.AFCS_PolicyCaseQuestions where CaseID = '" + self.CaseID1 + "' and QuestionType='2'"
        B3 = self.A.mssql_getrows(sql3)  #根据案例id找思考题id (简答题)
        B3s = self.A.mssql_getrows(sql3s)  #根据案例id找思考题id (选择题)
        self.QuestionsID3 = str(B3[0][0])
        self.QuestionsContent3 = str(B3[0][1])
        self.QuestionOrderNo3 = str(B3[0][2])
        self.QuestionsID3s = str(B3s[0][0])
        self.QuestionsContent3s = str(B3s[0][1])
        self.QuestionOrderNo3s = str(B3s[0][2])
        sql4 = "select StudentID FROM  dbo.AFCS_ClassStudents where ClassID = '" + self.ClassID2 + "'"
        B4 = self.A.mssql_getrows(sql4)  #根据班级id找学生id 取第一个学生
        self.StudentID4 = str(B4[0][0])

    def WriteQuestion(self):
        #填写思考题(问答题)
        url = urljoin(
            self.base_url,
            "kesgo.Service/wcf/CaseService.svc/AddOrUpdateQuestionPreview")
        #url = "http://192.168.0.167/kesgo.Service/wcf/CaseService.svc/AddOrUpdateQuestionPreview"
        body = {
            "questionpreviewinfo":
            "{\"QuestionsID\":\"" + self.QuestionsID3 + "\","
            "\"QuestionsContent\":\"" + self.QuestionsContent3 + "\","
            "\"CaseID\":\"" + self.CaseID1 + "\","
            "\"QuestionOrderNo\":" + self.QuestionOrderNo3 + ","
            "\"QuestionType\":1,"
            #"\"PreviewID\":\"280b969f-08be-439e-9f75-19500545598d\","
            "\"PreviewID\":\"00000000-0000-0000-0000-000000000000\","
            "\"ExperimentID\":\"" + self.ExperimentID1 + "\","
            "\"PreviewContent\":\"" + str(random.randint(1, 1000)) + "\","
            "\"StudentID\":\"" + self.StudentID4 + "\","
            "\"AddTime\":\"/Date(-62135596800000)/\","
            "\"Grade\":0,"
            "\"IsSubmit\":2,"
            "\"CaseQuesOption\":\"[]\","
            "\"PicList\":\"[]\"}"
        }
        h = {"Content-Type": "application/json;charset=UTF-8"}
        r = self.s.post(url, json=body, headers=h)
        print(r.status_code)

    def GetPreviewID(self):
        url3 = "http://192.168.0.167/kesgo.Service/wcf/CaseService.svc/GetQuesByWhere"
        par = {"expID": self.ExperimentID1, "stuID": self.StudentID4}
        h3 = {
            "Accept":
            "application/json, text/plain, */*",
            "User-Agent":
            "Mozilla/5.0 (Linux; Android 7.1.1; MI 6 Build/NMF26X; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36"
        }
        r3 = requests.get(url3, params=par, headers=h3)
        print(r3.content.decode("utf-8"))
        a = r3.json()
        b = json.loads(a)
        c = b["Table"]
        for i in c:
            idt = dict(i)
            if idt["QuestionsID"] == self.QuestionsID3:
                d = idt["PreviewID"]
                return d

    def SubmitQuestion(self, d):
        #提交思考题
        url2 = "http://192.168.0.167/kesgo.Service/wcf/CaseService.svc/SaveQuesAnswer"
        body2 = {
            "previewInfo":
            "[{\"PreviewID\":\"" + d + "\","
            "\"ExperimentID\":\"" + self.ExperimentID1 + "\","
            "\"QuestionsID\":\"" + self.QuestionsID3 + "\","
            "\"StudentID\":\"" + self.StudentID4 + "\","
            "\"IsSubmit\":1},"
            "{\"PreviewID\":\"00000000-0000-0000-0000-000000000000\","
            "\"ExperimentID\":\"" + self.ExperimentID1 + "\","
            "\"QuestionsID\":\"" + self.QuestionsID3s + "\","
            "\"StudentID\":\"" + self.StudentID4 + "\","
            "\"IsSubmit\":1}]"
        }
        h = {"Content-Type": "application/json;charset=UTF-8"}
        r2 = self.s.post(url2, json=body2, headers=h)
        print(r2.status_code)
 def __init__(self, ExperimentID, base_url):
     self.base_url = base_url
     self.A = MssqlUtil()
     sqlselgroup = "select GroupID from dbo.AFCS_Group where ExperimentID ='" + ExperimentID + "'"
     Bselgroup = self.A.mssql_getrows(sqlselgroup)
     self.Groupidlist = Bselgroup