def processCourses(self): # Taking only courseTitle, startDate & endDate self.endDate = "" self.startDate = "" courseCourseQry = {} courseCourseQry["_id.category"]="course" #//courseCourseQry.put("_id.course",courseName); #//BasicDBObject aboutQuery = new BasicDBObject("_id.category","about"); #BasicDBObject courseQuery = new BasicDBObject(courseCourseQry); courseCursor = self.edxCollection.find(courseQuery); #//System.out.println(" course and course count " + courseCursor.count()); for courseDo in courseCursor: edxCourse = classes.Course() courseDo = _decode_dict(courseDo) dbId = courseDo.get("_id") dbId=_decode_dict(dbId) self.courseName = dbId.get("course") self.orgName = dbId.get("org") self.courseRun = dbId.get("name") defs = courseDo.get("definition") childStr = defs.get("children") childStrs = childStr.split(",") meta = courseDo.get("metadata") meta=_decode_dict(meta) self.courseTitle = meta.get("display_name") # date is in the format YYYY:MM:DDTHH:MM:SSZ try : endDatetmp = meta.get("end") if(endDatetmp != None) : tmp=endDatetmp.split("T"); self.endDate=tmp[0]+" "+tmp[:-1] startDatetmp=meta.get("start") if(startDate != None) : tmp=startDatetmp.split("T"); self.startDate=tmp[0]+" "+tmp[:-1] except Exception ,err : traceback.print_exc() processAboutShort(); edxCourse.coursename=self.courseName edxCourse.coursetitle=self.courseTitle edxCourse.currconcepts=self.currCourseConcept #//edxCourse.setCurrencyCode(childStr); edxCourse.enddate=self.endDate #//edxCourse.setLanguage(childStr); edxCourse.lmsname=self.lmsName edxCourse.minprice=0 edxCourse.orgname=self.orgName edxCourse.prevconcepts=self.prevCourseConcept edxCourse.startdate=self.startDate edxCourse.startdate=self.startDate edxCourse.enddate=self.endDate edxCourse.save(); processChapters(childStrs);
def processDiscuss(self,discussName): discussTitle = "" discussSysId = "" courseDiscussQry = {} courseDiscussQry["_id.category"]="discussion" courseDiscussQry["_id.course"]=self.courseName courseDiscussQry["_id.name"]=discussName DiscussCursor = self.edxCollection.find(courseDiscussQry) for discussDo in DiscussCursor : courseDiscuss = classes.CourseDiscussions() defDO = discussDo.get("definition") defDo=_decode_dict(defDo) metaDO = discussDo.get("metadata") metaDo=_decode_dict(metaDo) discussTitle="" if(metaDO.get("discussion_target") != None) : discussTitle = str(metaDO.get("discussion_target")) else : discussTitle = "" discussSysId = metaDO.get("discussion_id") courseDiscuss.lmsname=self.lmsName courseDiscuss.orgname=self.orgName courseDiscuss.coursename=self.courseName courseDiscuss.discussiontitle=discussTitle courseDiscuss.chaptersysname=self.chapterSysName courseDiscuss.discussionsysname=discussName courseDiscuss.discusssysid=discussSysId courseDiscuss.save()
def processDiscuss(self, discussName): discussTitle = "" discussSysId = "" courseDiscussQry = {} courseDiscussQry["_id.category"] = "discussion" courseDiscussQry["_id.course"] = self.courseName courseDiscussQry["_id.name"] = discussName DiscussCursor = self.edxCollection.find(courseDiscussQry) for discussDo in DiscussCursor: courseDiscuss = classes.CourseDiscussions() defDO = discussDo.get("definition") defDo = _decode_dict(defDo) metaDO = discussDo.get("metadata") metaDo = _decode_dict(metaDo) discussTitle = "" if (metaDO.get("discussion_target") != None): discussTitle = str(metaDO.get("discussion_target")) else: discussTitle = "" discussSysId = metaDO.get("discussion_id") courseDiscuss.lmsname = self.lmsName courseDiscuss.orgname = self.orgName courseDiscuss.coursename = self.courseName courseDiscuss.discussiontitle = discussTitle courseDiscuss.chaptersysname = self.chapterSysName courseDiscuss.discussionsysname = discussName courseDiscuss.discusssysid = discussSysId courseDiscuss.save()
def processCourses(self): # Taking only courseTitle, startDate & endDate self.endDate = "" self.startDate = "" courseCourseQry = {} courseCourseQry["_id.category"] = "course" #//courseCourseQry.put("_id.course",courseName); #//BasicDBObject aboutQuery = new BasicDBObject("_id.category","about"); #BasicDBObject courseQuery = new BasicDBObject(courseCourseQry); courseCursor = self.edxCollection.find(courseQuery) #//System.out.println(" course and course count " + courseCursor.count()); for courseDo in courseCursor: edxCourse = classes.Course() courseDo = _decode_dict(courseDo) dbId = courseDo.get("_id") dbId = _decode_dict(dbId) self.courseName = dbId.get("course") self.orgName = dbId.get("org") self.courseRun = dbId.get("name") defs = courseDo.get("definition") childStr = defs.get("children") childStrs = childStr.split(",") meta = courseDo.get("metadata") meta = _decode_dict(meta) self.courseTitle = meta.get("display_name") # date is in the format YYYY:MM:DDTHH:MM:SSZ try: endDatetmp = meta.get("end") if (endDatetmp != None): tmp = endDatetmp.split("T") self.endDate = tmp[0] + " " + tmp[:-1] startDatetmp = meta.get("start") if (startDate != None): tmp = startDatetmp.split("T") self.startDate = tmp[0] + " " + tmp[:-1] except Exception, err: traceback.print_exc() processAboutShort() edxCourse.coursename = self.courseName edxCourse.coursetitle = self.courseTitle edxCourse.currconcepts = self.currCourseConcept #//edxCourse.setCurrencyCode(childStr); edxCourse.enddate = self.endDate #//edxCourse.setLanguage(childStr); edxCourse.lmsname = self.lmsName edxCourse.minprice = 0 edxCourse.orgname = self.orgName edxCourse.prevconcepts = self.prevCourseConcept edxCourse.startdate = self.startDate edxCourse.startdate = self.startDate edxCourse.enddate = self.endDate edxCourse.save() processChapters(childStrs)
def processSequential(self, seqName, position): #// Will enter as many chapters as available courseSeqQry = {} courseSeqQry["_id.category"] = "sequential" courseSeqQry["_id.course"] = self.courseName courseSeqQry["_id.name"] = seqName seqCursor = self.edxCollection.find(courseSeqQry) for seqDo in seqCursor: meta = seqDo.get("metadata") meta = _decode_dict(meta) seqTitle = meta.get("display_name") courseChapterSession = classes.Coursechaptersession() courseChapterSession.chaptersysname = self.chapterSysName courseChapterSession.coursename = self.courseName courseChapterSession.lmsname = self.lmsName courseChapterSession.orgname = self.orgName courseChapterSession.position = position if (meta.get("start") != None): try: tmp = meta.get("start") if tmp != None: tmparr = tmp.split("T") courseChapterSession.sessionstartdate = tmparr[ 0] + " " + tmparr[:-1] except Exception, err: traceback.print_exc() else: courseChapterSession.sessionstartdate = "" courseChapterSession.sessionsysname = seqName courseChapterSession.sessiontitle = seqTitle courseChapterSession.save() defs = seqDo.get("definition") childStr = defs.get("children") tmpStr = childStr.split(",") vertArray = [] tmpStr_len = len(tmpStr) for iSeq in range(0, tmpStr_len): vertArray.append("") if (tmpStr[iSeq].rfind("/") != -1): if (iSeq != len(tmpStr[iSeq])): vertArray[iSeq] = tmpStr[ iSeq][tmpStr[iSeq].rfind("/") + 1:tmpStr[iSeq].rfind("\"")] else: vertArray[iSeq] = tmpStr[ iSeq][tmpStr[iSeq].rfind("/") + 1:tmpStr[iSeq].rfind("\"") - 1] vertArray_len = len(vertArray) for iSeq in range(0, vertArray_len): processVertical(vertArray[iSeq], seqName)
def processSequential(self, seqName,position) : #// Will enter as many chapters as available courseSeqQry = {} courseSeqQry["_id.category"]="sequential" courseSeqQry["_id.course"]=self.courseName courseSeqQry["_id.name"]=seqName seqCursor = self.edxCollection.find(courseSeqQry) for seqDo in seqCursor : meta = seqDo.get("metadata") meta=_decode_dict(meta) seqTitle = meta.get("display_name") courseChapterSession = classes.Coursechaptersession() courseChapterSession.chaptersysname=self.chapterSysName courseChapterSession.coursename=self.courseName courseChapterSession.lmsname=self.lmsName courseChapterSession.orgname=self.orgName courseChapterSession.position=position if(meta.get("start") != None) : try: tmp=meta.get("start") if tmp != None: tmparr=tmp.split("T") courseChapterSession.sessionstartdate=tmparr[0]+" "+tmparr[:-1] except Exception ,err: traceback.print_exc() else : courseChapterSession.sessionstartdate="" courseChapterSession.sessionsysname=seqName courseChapterSession.sessiontitle=seqTitle courseChapterSession.save() defs = seqDo.get("definition") childStr = defs.get("children") tmpStr = childStr.split(",") vertArray = [] tmpStr_len=len(tmpStr) for iSeq in range(0,tmpStr_len) : vertArray.append("") if(tmpStr[iSeq].rfind("/") != -1): if(iSeq != len(tmpStr[iSeq])) : vertArray[iSeq] = tmpStr[iSeq][tmpStr[iSeq].rfind("/")+ 1 : tmpStr[iSeq].rfind("\"")] else : vertArray[iSeq] = tmpStr[iSeq][tmpStr[iSeq].rfind("/") + 1 : tmpStr[iSeq].rfind("\"") - 1] vertArray_len=len(vertArray) for iSeq in range(0,vertArray_len): processVertical(vertArray[iSeq], seqName)
def processVertical( self ,vertName,seqName) : #// Will enter as many chapters as available courseVertQry = {} courseVertQry["_id.category"]="vertical" courseVertQry["_id.course"]=self.courseName courseVertQry["_id.name"]=self.vertName vertCursor = self.edxCollection.find(courseVertQry) for seqDo in vertCursor : seqDo=_decode_dict(seqDo) meta = seqDo.get("metadata"); vertTitle = meta.get("display_name") defs = seqDo.get("definition") childStr = defs.get("children") courseVertical = classes.CourseVertical() courseVertical.coursename=self.courseName courseVertical.lmsname=self.lmsName courseVertical.orgname=self.orgName courseVertical.sessionsysname=seqName courseVertical.verticalsysname=vertName courseVertical.save() tmpStr = childStr.split(",") vertArray = []; tmpStr_len=len(tmpStr) for iSeq in range(0,tmpStr_len): vertArray.append("") tmpStr1 = tmpStr[iSeq].split("/") noOfSplits = len(tmpStr1) if(noOfSplits >=2 ) : vertType = tmpStr1[noOfSplits - 2]; vertArray[iSeq] = tmpStr1[noOfSplits - 1][0:tmpStr1[noOfSplits - 1].find("\"") ] if(vertType=="problem") : self.correctChoice = 0 processProblem(vertArray[iSeq]) elif(vertType=="html" ) : processHtmls(vertArray[iSeq], vertName, seqName); elif(vertType == "discussion"): processDiscuss(vertArray[iSeq]); elif(vertType == "video" ) : processVideos(vertArray[iSeq])
def processVertical(self, vertName, seqName): #// Will enter as many chapters as available courseVertQry = {} courseVertQry["_id.category"] = "vertical" courseVertQry["_id.course"] = self.courseName courseVertQry["_id.name"] = self.vertName vertCursor = self.edxCollection.find(courseVertQry) for seqDo in vertCursor: seqDo = _decode_dict(seqDo) meta = seqDo.get("metadata") vertTitle = meta.get("display_name") defs = seqDo.get("definition") childStr = defs.get("children") courseVertical = classes.CourseVertical() courseVertical.coursename = self.courseName courseVertical.lmsname = self.lmsName courseVertical.orgname = self.orgName courseVertical.sessionsysname = seqName courseVertical.verticalsysname = vertName courseVertical.save() tmpStr = childStr.split(",") vertArray = [] tmpStr_len = len(tmpStr) for iSeq in range(0, tmpStr_len): vertArray.append("") tmpStr1 = tmpStr[iSeq].split("/") noOfSplits = len(tmpStr1) if (noOfSplits >= 2): vertType = tmpStr1[noOfSplits - 2] vertArray[iSeq] = tmpStr1[noOfSplits - 1][0:tmpStr1[noOfSplits - 1].find("\"")] if (vertType == "problem"): self.correctChoice = 0 processProblem(vertArray[iSeq]) elif (vertType == "html"): processHtmls(vertArray[iSeq], vertName, seqName) elif (vertType == "discussion"): processDiscuss(vertArray[iSeq]) elif (vertType == "video"): processVideos(vertArray[iSeq])
def processHtmls( self ,htmlName,vertName,seqName): courseHtmlQry = {} courseHtmlQry["_id.category"]="html" courseHtmlQry["_id.course"]=self.courseName courseHtmlQry["_id.name"]=htmlName htmlCursor = self.edxCollection.find(courseHtmlQry) for htmlDo in htmlCursor : defDO = htmlDo.get("definition") defDo=_decode_dict(defDo) metaDO = htmlDo.get("metadata") dataDO = defDO.get("data") source = "" if(dataDO.get("data") != None): source = str(dataDO.get("data")) type1 = "" if (".pdf\\" in source ) : type1 = "pdf" elif (".jpg\\" in source) : type1 = "jpg" else : type1 = "html" vertTitle="" if(metaDO.get("display_name") != None) : vertTitle = str(metaDO.get("display_name")) courseOthers = classes.CourseOthers() courseOthers.type=type1 courseOthers.title=vertTitle courseOthers.coursename=self.courseName courseOthers.lmsname=self.lmsName courseOthers.orgname=self.orgName courseOthers.chaptersysname=self.chapterSysName courseOthers.htmlsysname=self.htmlName courseOthers.sessionsysname=seqName courseOthers.verticalsysname=vertName courseOthers.save()
def processHtmls(self, htmlName, vertName, seqName): courseHtmlQry = {} courseHtmlQry["_id.category"] = "html" courseHtmlQry["_id.course"] = self.courseName courseHtmlQry["_id.name"] = htmlName htmlCursor = self.edxCollection.find(courseHtmlQry) for htmlDo in htmlCursor: defDO = htmlDo.get("definition") defDo = _decode_dict(defDo) metaDO = htmlDo.get("metadata") dataDO = defDO.get("data") source = "" if (dataDO.get("data") != None): source = str(dataDO.get("data")) type1 = "" if (".pdf\\" in source): type1 = "pdf" elif (".jpg\\" in source): type1 = "jpg" else: type1 = "html" vertTitle = "" if (metaDO.get("display_name") != None): vertTitle = str(metaDO.get("display_name")) courseOthers = classes.CourseOthers() courseOthers.type = type1 courseOthers.title = vertTitle courseOthers.coursename = self.courseName courseOthers.lmsname = self.lmsName courseOthers.orgname = self.orgName courseOthers.chaptersysname = self.chapterSysName courseOthers.htmlsysname = self.htmlName courseOthers.sessionsysname = seqName courseOthers.verticalsysname = vertName courseOthers.save()
def fun(self): '''#userSessionDao = new UserSessionOldDao(connIIT) System.out.println("BEFORE PREP STA") psVideoInteract = connIIT .prepareStatement("insert into EventVideoInteract( sessionSysName, lmsName, orgName, courseName, courseRun, lmsUserId," + "eventName,eventNo, videoSysName, videoTitle, chapterSysName,chapterTitle, oldSeekTime, currSeekTime, videoNavigType, " + " oldSpeed, currSpeed, source,createDateTime, lastModDateTime) " + " values (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?)") psCourseInteract = connIIT .prepareStatement("insert into EventCourseInteract ( lmsName, orgName, courseName, courseRun, lmsUserId," + "eventName,eventNo, moduleType, moduleSysName,moduleTitle,chapterSysName,chapterTitle," + "createDateTime, modDateTime, oldPosition, curPosition, source) " + " values (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?)") psProbInteract = connIIT .prepareStatement("insert into EventProbInteract( lmsName,orgName, courseName,lmsUserId," + "eventName,eventNo,quizzSysName,quizzTitle,chapterSysName,chapterTitle,hintAvailable,hintMode,inputType,responseType," + "variantId,oldScore,newScore,maxGrade,attempts,maxAttempts,choice, success, " + "source, probSubTime,done,createDateTime,lastModDateTime,courseRun) " + " values (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,? , ?,?,?)") psUserSession = connIIT .prepareStatement("insert into UserSession (sessionSysName, lmsName, orgName, courseName,courseRun, lmsUserId, userName," + "agent, hostName, ipAddress, url, createDateTime, eventType, eventSource, eventName," + "eventId, lastModDateTime,dataSource,eventNo) values (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?)") System.out.println(psCourseInteract) stmt = connEDX.createStatement() } catch (IOException e1) { // TODO Auto-generated catch block System.out.println("I/O Exception " + e1.toString()) } catch (SQLException e) { // TODO Auto-generated catch block // e.printStackTrace() System.out.println("SQL Exception " + e.toString())} // Query edx tables courseware_studentmodule, Create all Event Tables // table of LMS // /******** End Of Insert into User Table of LMS''' sqlStmt = "select module_type,module_id,student_id,state,grade,created,modified,max_grade,\ done, course_id,userName from courseware_studentmodule s join auth_user u \ on s.student_id = u.id" #// Get userName from auth_user''' #System.out.println("sqlSTmt " + sqlStmt) try : self.cursor.execute(sqlStmt) result=self.cursor.fetchall() #System.out.println("RECORD NO : rs executed" + recNo) for rs in result : self.currEventNo = 0 self.userSession.datasource="SQL" self.userSession.lmsname="EDX" self.recNo+=1 #System.out.println("RECORD NO : " + recNo) self.moduleType = rs[0] #System.out.println("MODULE TYPE : " + moduleType) self.moduleId = rs[1] self.userSession.lmsuserid=long(rs[2]) # doubt format of stateStr stateStr = rs[3] self.stateJson = json.loads(stateStr) #doubt self.stateJson=dataloader._decode_dict(self.stateJson) self.userSession.createdatetime=rs[5] self.userSession.lastmoddatetime=rs[6] self.userSession.username=rs[10] self.tmpStrArr = rs[9].split("/") self.userSession.orgname=self.tmpStrArr[0] self.userSession.coursename=self.tmpStrArr[1] self.userSession.courserun=self.tmpStrArr[2] print self.moduleType, self.stateJson.get("last_submission_time") if ((self.moduleType == "chapter") or (self.moduleType == "course" ) or (self.moduleType == "sequential" )) : #System.out.println("moduleType is course") self.userSession.eventtype="course" self.eventCourseInteract.lmsname=self.lmsName self.eventCourseInteract.orgname=self.userSession.orgname self.eventCourseInteract.coursename=self.userSession.coursename self.eventCourseInteract.lmsuserid=self.userSession.lmsuserid self.eventCourseInteract.eventname=self.moduleType self.userSession.eventname=self.moduleType self.eventCourseInteract.moduletype=self.moduleType self.eventCourseInteract.modulesysname=self.moduleId[self.moduleId.rfind("/") + 1:] print self.eventCourseInteract.modulesysname self.userSession.modulesysname=self.eventCourseInteract.modulesysname if self.properties.get("EVNT_GOTO_POSITION")!=None: self.currEventNo = int(self.properties.get("EVNT_GOTO_POSITION")) if (self.moduleType == "chapter") : self.eventCourseInteract.chaptersysname=self.eventCourseInteract.modulesysname rsTmp=sqlFetch.psChapter(self.userSession.coursename,self.eventCourseInteract.modulesysname) if(rsTmp!=None): self.eventCourseInteract.chaptertitle=rsTmp[0] self.userSession.chaptertitle=rsTmp[0] elif (self.moduleType=="session"): self.eventCourseInteract.chaptersysname=self.eventCourseInteract.modulesysname self.userSession.chaptersysname=self.eventCourseInteract.chaptersysname rsTmp = psChapterSess(self.userSession.coursename,self.eventCourseInteract.modulesysname) if (rsTmp!=None): chapTitle = rsTmp[0] moduleTitle = rsTmp[1] chapSysName = rsTmp[2] self.eventCourseInteract.chaptertitle=chapTitle self.eventCourseInteract.moduletitle=moduleTitle self.eventCourseInteract.chaptersysname=chapSysName self.userSession.chaptertitle=chapTitle self.userSession.moduletitle=moduleTitle self.userSession.chapterSysName=chapSysName elif self.moduleType == "course": chapTitle = self.userSession.coursename moduleTitle = self.userSession.coursename chapSysName = self.eventCourseInteract.modulesysname self.eventCourseInteract.chaptersysname=self.eventCourseInteract.modulesysname self.eventCourseInteract.chaptertitle=self.userSession.coursename self.eventCourseInteract.moduletitle=self.userSession.coursename self.userSession.chaptertitle=chapTitle self.userSession.moduletitle=moduleTitle self.userSession.chaptersysname=chapSysName self.eventCourseInteract.eventno=self.currEventNo self.userSession.eventno=self.currEventNo self.eventCourseInteract.curposition=int( str(self.stateJson.get("position") )) self.userSession.currposition=int( str(self.stateJson.get("position")) ) self.eventCourseInteract.source="SQL" self.userSession.eventsource="SQL" self.eventCourseInteract.courserun=self.userSession.courserun self.eventCourseInteract.createdatetime=self.userSession.createdatetime self.eventCourseInteract.moddatetime=self.userSession.lastmoddatetime #self.insertCourse() self.eventCourseInteract.save() elif self.moduleType=="openassessment": self.userSession.eventtype="openassess" elif self.moduleType=="problem": #System.out.println("moduleType is problem") self.userSession.eventtype="problem" self.userSession.eventname="Quizz" self.eventProbInteract.done=rs[8] self.userSession.done=rs[8] self.eventProbInteract.lmsname=self.lmsName self.eventProbInteract.orgname=self.userSession.orgname self.eventProbInteract.coursename=self.userSession.coursename self.eventProbInteract.lmsuserid=self.userSession.lmsuserid self.eventProbInteract.eventname="problem" self.eventProbInteract.quizzsysname=self.moduleId[ self.moduleId.rfind("/") + 1 ] self.userSession.modulesysname=self.eventProbInteract.quizzsysname rsTmp = sqlFetch.psProblem( self.userSession.coursename, self.eventProbInteract.quizzsysname ) if (rsTmp!=None): self.eventProbInteract.chaptersysname=rsTmp[0] self.eventProbInteract.chaptertitle=rsTmp[1] self.eventProbInteract.quizztitle=rsTmp[2] self.userSession.chaptersysname=rsTmp[0] self.userSession.chaptertitle=rsTmp[1] self.userSession.moduletitle=self.eventProbInteract.quizztitle self.eventProbInteract.maxgrade=rs[7] self.eventProbInteract.newscore=rs[4] self.eventProbInteract.source="SQL" self.eventProbInteract.courserun=self.userSession.courserun self.eventProbInteract.createdatetime=self.userSession.createdatetime self.eventProbInteract.lastmoddatetime=self.userSession.lastmoddatetime if rs[7]!=None: self.userSession.maxgrade=float(rs[7]) if rs[4]!=None: self.userSession.currgrade=float(rs[4]) self.userSession.eventsource="SQL" self.studentAnswerJson = json.dumps( self.stateJson.get("student_answers") ) self.correctMapJson = json.dumps( self.stateJson.get("correct_map") ) if (self.stateJson.get("last_submission_time") != None): #self.eventProbInteract.probsubtime=new java.sql.Timestamp( mongoDateFormat.parse( stateJson.get("last_submission_time").toString()).getTime())) #no idea about the format of the string #changed mongoDateFormat in EdxParams.Properties print 'i am here',self.stateJson.get("last_submission_time") #self.eventProbInteract.probsubtime= datetime.datetime.strftime( self.mongoDateFormat, self.stateJson.get("last_submission_time") ) #self.eventProbInteract.probsubtime=datetime.datetime.fromtimestamp( self.stateJson.get("last_submission_time") ).strftime('%Y-%m-%d %H:%M:%S') self.eventProbInteract.probsubtime=datetime.datetime.strptime(self.stateJson.get("last_submission_time"),'%Y-%m-%dT%H:%M:%SZ') self.userSession.probsubmissiontime=self.eventProbInteract.probsubtime if (self.stateJson.get("attempts") != None): self.eventProbInteract.attempts=int( str(self.stateJson.get("attempts")) ) self.userSession.attempts=self.eventProbInteract.attempts if (self.stateJson.get("done") == None): self.eventProbInteract.done=None self.userSession.done=None elif ( str(self.stateJson.get("done") )=="false"): self.eventProbInteract.done="N" self.userSession.done="N" elif str(self.stateJson.get("done") )=="true": self.eventProbInteract.done="Y" self.userSession.done="Y" if self.correctMapJson != 'null': mydecoder=json.JSONDecoder() #self.keySet = self.correctMapJson.keys() self.correctMapJson=mydecoder.decode(self.correctMapJson) self.keySet = self.correctMapJson.keys() if len(self.keySet)!=0: for itr in self.keySet: self.correctMapKeyValJson = json.dumps( self.correctMapJson.get(itr) ) self.correctMapKeyValJson=mydecoder.decode(self.correctMapKeyValJson) if (self.correctMapKeyValJson != None) : if (self.correctMapKeyValJson.get("correctness") != None): if str(self.correctMapKeyValJson.get("correctness"))=="correct": self.eventProbInteract.success="Y" self.userSession.success="Y" else: self.eventProbInteract.success="N" self.userSession.success="N" if (self.correctMapKeyValJson.get("hint") != None): self.eventProbInteract.hintavailable=str(self.correctMapKeyValJson.get("hint")) self.userSession.hintavailable=self.eventProbInteract.hintavailable if (self.correctMapKeyValJson.get("hintmode") != None): self.eventProbInteract.hintmode=str( self.correctMapKeyValJson.get("hintmode") ) self.userSession.hintmode=self.eventProbInteract.hintmode if (self.studentAnswerJson != 'null'): mydecoder=json.JSONDecoder() #self.keySet = self.studentAnswerJson.keys() self.studentAnswerJson=mydecoder.decode(self.studentAnswerJson) self.keySet = self.studentAnswerJson.keys() if len(self.keySet)!=0: self.firstFlag = True self.answers= self.answers[ len(self.answers): ] for itr in self.keySet: if (self.firstFlag): self.answers.append( str(self.studentAnswerJson.get(itr)) ) self.firstFlag = False else: self.answers.append(",") self.answers.append( str(self.studentAnswerJson.get(itr)) ) print("answers " + self.answers) self.eventProbInteract.choice=str(self.answers) self.userSession.answerchoice=self.eventProbInteract.choice else: print("studentAnswerJSon.get(key) is empty ") if self.stateJson.get("done")== None or self.stateJson.get("done")=="false": self.currEventNo = int(self.properties.get("EVNT_PROBLEM_SAVE")) self.eventProbInteract.eventno=self.currEventNo self.userSession.eventno=self.currEventNo elif str(self.stateJson.get("done"))=="true": self.currEventNo = int(self.properties.get("EVNT_SAVE_PROBLEM_SUCCESS")) self.eventProbInteract.eventno=self.currEventNo self.userSession.eventno=self.currEventNo else: if self.properties.get("EVNT_PROBLEM_GET")!=None: self.currEventNo = int(self.properties.get("EVNT_PROBLEM_GET")) self.eventProbInteract.eventno=self.currEventNo self.userSession.eventno=self.currEventNo print("Evemt No " + str(self.currEventNo) + " stateJson.get(done) " + str(self.stateJson.get("done")) ) #self.insertProbRec() self.eventProbInteract.save() elif self.moduleType=="video": self.userSession.eventtype="video" self.eventVideoInteract.eventname="video" if (self.stateJson.get("saved_video_position") != None): self.currEventNo = self.evnt_Save_Video_Position self.userSession.eventname="saved_video_position" self.userSession.eventno=self.currEventNo self.eventVideoInteract.eventno=self.currEventNo #doubt #tmpDate = dsf.parse(stateJson.get("saved_video_position").toString()) self.tmpDate= datetime.datetime.strptime(str(self.stateJson.get('saved_video_position')), "%Y-%m-%d %H:%M:%S") self.eventVideoInteract.currseektime=float( str(self.tmpDate.hour*3600 + self.tmpDate.minute*600+ self.tmpDate.second)) #doubt self.userSession.currentseektime=self.eventVideoInteract.currseektime if (self.stateJson.get("speed") != None): self.eventVideoInteract.currspeed=float( str(self.stateJson.get("speed")) ) self.userSession.currvideospeed=self.eventVideoInteract.currspeed self.eventVideoInteract.lmsname=self.lmsName self.eventVideoInteract.orgname=self.userSession.orgname self.eventVideoInteract.coursename=self.userSession.coursename self.eventVideoInteract.lmsuserid=self.userSession.lmsuserid self.eventVideoInteract.eventname=self.moduleType self.eventVideoInteract.videosysname=self.moduleId[ self.moduleId.rfind("/") + 1 ] self.userSession.eventname=self.moduleType self.userSession.modulesysname=self.eventVideoInteract.videosysname rsVideo = psVideo( self.userSession.coursename, self.eventVideoInteract.videosysname ) if rsVideo!=None: self.eventVideoInteract.videotitle=rsVideo[0] self.eventVideoInteract.chaptersysname=rsVideo[1] self.eventVideoInteract.chaptertitle=rsVideo[2] self.userSession.moduletitle=self.eventVideoInteract.videotitle self.userSession.chaptersysname=self.eventVideoInteract.chaptersysname self.userSession.chaptertitle=self.eventVideoInteract.chaptertitle self.eventVideoInteract.source="SQL" self.eventVideoInteract.courserun=self.userSession.courserun self.eventVideoInteract.createdatetime=self.userSession.createdatetime self.eventVideoInteract.lastmoddatetime=self.userSession.lastmoddatetime self.userSession.eventsource="SQL" #self.insertVideoRec() self.eventVideoInteract.save() self.userSession.sessionid=self.eventId self.userSession.eventno=self.currEventNo print("BEFORE USERSESSION RECORD NO " + str(self.recNo) + " eventId " + str(self.eventId) ) print("BEFORE USERSESSION currEventNo " + str(self.currEventNo) + " moduleType " + str(self.userSession.eventtype) ) self.userSession.save() print 'yahoo' #userSessionDao.insertRec(self.userSession) # catch (SQLException e) # { # // TODO Auto-generated catch block # System.out.println("SQL Exception " + e.toString()) # } # catch (ParseException e) # { # // TODO Auto-generated catch block # System.out.println("Parse Exception " + e.toString()) # } # catch (java.text.ParseException e) # { # // TODO Auto-generated catch block # System.out.println("Text Parse Exception " + e.toString())// e.printStackTrace() # } except Exception, e: print 'error1' print("Exception " + str(e))
def processContents(self) : endDate =None startDate = None tmpStr=[] tmpStrArr=[] isoDateFormatStr = "EEE, MMM dd HH:mm:ss IST yyyy" forumContentQry = {} forumContentQry["_id.category"]="course" # ask they have not used query forumCursor = edxCollection.find(forumContentQry) try : for forumDO in forumCursor : courseForums = classes.Courseforums() courseForums.lmsname=self.lmsName forumDO=_decode_dict(forumDO) tmpObj =forumDO.get("_id") courseForums.commentsysid=str(tmpObj) courseForums.commenttype= str(forumDO.get("_type")) if(bool(forumDO.get("anonymous")) == False): courseForums.anonymousmode="N" if (forumDO.get("author_id")!=None): courseForums.lmsauthorid=long(forumDO.get("author_id")) if (forumDO.get("author_username")!=None): courseForums.lmsauthorname=forumDO.get("author_username") if (forumDO.get("closed")!=None): courseForums.closed=bool(forumDO.get("closed")) if (forumDO.get("comment_count")!=None): courseForums.commentCount=int(forumDO.get("comment_count")) if (forumDO.get("commentable_id")!=None): courseForums.commentablesysid=forumDO.get("comment_id") tmpStrArr = forumDO.get("course_id").split("/") courseForums.orgname=tmpStrArr[0] courseForums.coursename=tmpStrArr[1] courseForums.courserun=tmpStrArr[2] if (forumDO.get("endorsed")!=None): courseForums.endorsed= bool( forumDO.get("endorsed")) if (forumDO.get("created_at")!=None): courseForums.createdatetime=forumDO.get("created_at") if (forumDO.get("last_activity_at")!=None) : courseForums.lastmoddatetime=forumDO.get("last_activity_at") if (forumDO.get("thread_type")!=None): courseForums.threadtype=forumDO.get("thread_type") if(forumDO.get("title")): courseForums.title=forumDO.get("title") if(forumDO.get("visible")!=None): courseForums.visible=bool(forumDO.get("visible")) if(forumDO.get("votes.count")!=None): courseForums.totvotecount =int(forumDO.get("votes.count")) if(forumDO.get("votes.up_count")!=None): courseForums.upvotecount =int(forumDO.get("votes.up_count")) courseForums.save() except Exception ,err : traceback.print_exc()
def processProblem(self ,problemName) : #// Will enter as many chapters as available courseProblemQry = {} courseProblemQry["_id.category"]="problem" courseProblemQry["_id.course"]=self.courseName courseProblemQry["_id.name"]=problemName problemCursor = self.edxCollection.find(problemQuery) for problemDo in problemCursor : courseProblems = classes.CourseProblems() defDO = problemDo.get("definition") metaDO = problemDo.get("metadata") metaDO=_decode_dict(metaDO) maxAttempt=-1 if(metaDO.get("max_attempts") != None) : maxAttempt = int(str(metaDO.get("max_attempts")).strip()) else : maxAttempt = -1 weight=0.0 if(metaDO.get("weight") != None) : weight = float(str(metaDO.get("weight")).strip()) else : weight = 0.0 if(metaDO.get("showanswer") != None): if((str(metaDO.get("showanswer")).strip()) == "never" ) : courseProblems.hintavailable=0 else : courseProblems.hintavailable=1 courseProblems.hintmode=str(metaDO.get("showanswer")).strip() dataDO = defDO.get("data") courseProblems.lmsname=self.lmsName courseProblems.orgname=self.orgName courseProblems.coursenames=self.courseName courseProblems.chaptersysname=self.chapterSysName self.quizType = None self.quizTitle = None self.correctChoice = None if(dataDO.get("data") != None) : parseXMLString(str(dataDO.get("data"))) if(metaDO.get("display_name") != None): if (self.quizTitle != None) : courseProblems.quiztitle=str(metaDO.get("display_name")) + " " + self.quizTitle else : courseProblems.quiztitle=str(metaDO.get("display_name")) else : if (self.quizTitle != None) : courseProblems.quiztitle=self.quizTitle else : courseProblems.quiztitle=None courseProblems.quiztype=self.quizType courseProblems.quizweight=weight courseProblems.noofattemptsallowed=maxAttempt courseProblems.quizmaxmarks=weight courseProblems.correctchoice=self.correctChoice courseProblems.quizsysname=problemName courseProblems.save()
def fun(self): '''#userSessionDao = new UserSessionOldDao(connIIT) System.out.println("BEFORE PREP STA") psVideoInteract = connIIT .prepareStatement("insert into EventVideoInteract( sessionSysName, lmsName, orgName, courseName, courseRun, lmsUserId," + "eventName,eventNo, videoSysName, videoTitle, chapterSysName,chapterTitle, oldSeekTime, currSeekTime, videoNavigType, " + " oldSpeed, currSpeed, source,createDateTime, lastModDateTime) " + " values (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?)") psCourseInteract = connIIT .prepareStatement("insert into EventCourseInteract ( lmsName, orgName, courseName, courseRun, lmsUserId," + "eventName,eventNo, moduleType, moduleSysName,moduleTitle,chapterSysName,chapterTitle," + "createDateTime, modDateTime, oldPosition, curPosition, source) " + " values (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?)") psProbInteract = connIIT .prepareStatement("insert into EventProbInteract( lmsName,orgName, courseName,lmsUserId," + "eventName,eventNo,quizzSysName,quizzTitle,chapterSysName,chapterTitle,hintAvailable,hintMode,inputType,responseType," + "variantId,oldScore,newScore,maxGrade,attempts,maxAttempts,choice, success, " + "source, probSubTime,done,createDateTime,lastModDateTime,courseRun) " + " values (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,? , ?,?,?)") psUserSession = connIIT .prepareStatement("insert into UserSession (sessionSysName, lmsName, orgName, courseName,courseRun, lmsUserId, userName," + "agent, hostName, ipAddress, url, createDateTime, eventType, eventSource, eventName," + "eventId, lastModDateTime,dataSource,eventNo) values (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?)") System.out.println(psCourseInteract) stmt = connEDX.createStatement() } catch (IOException e1) { // TODO Auto-generated catch block System.out.println("I/O Exception " + e1.toString()) } catch (SQLException e) { // TODO Auto-generated catch block // e.printStackTrace() System.out.println("SQL Exception " + e.toString())} // Query edx tables courseware_studentmodule, Create all Event Tables // table of LMS // /******** End Of Insert into User Table of LMS''' sqlStmt = "select module_type,module_id,student_id,state,grade,created,modified,max_grade,\ done, course_id,userName from courseware_studentmodule s join auth_user u \ on s.student_id = u.id" #// Get userName from auth_user''' #System.out.println("sqlSTmt " + sqlStmt) try: self.cursor.execute(sqlStmt) result = self.cursor.fetchall() #System.out.println("RECORD NO : rs executed" + recNo) for rs in result: self.currEventNo = 0 self.userSession.datasource = "SQL" self.userSession.lmsname = "EDX" self.recNo += 1 #System.out.println("RECORD NO : " + recNo) self.moduleType = rs[0] #System.out.println("MODULE TYPE : " + moduleType) self.moduleId = rs[1] self.userSession.lmsuserid = long(rs[2]) # doubt format of stateStr stateStr = rs[3] self.stateJson = json.loads(stateStr) #doubt self.stateJson = dataloader._decode_dict(self.stateJson) self.userSession.createdatetime = rs[5] self.userSession.lastmoddatetime = rs[6] self.userSession.username = rs[10] self.tmpStrArr = rs[9].split("/") self.userSession.orgname = self.tmpStrArr[0] self.userSession.coursename = self.tmpStrArr[1] self.userSession.courserun = self.tmpStrArr[2] print self.moduleType, self.stateJson.get( "last_submission_time") if ((self.moduleType == "chapter") or (self.moduleType == "course") or (self.moduleType == "sequential")): #System.out.println("moduleType is course") self.userSession.eventtype = "course" self.eventCourseInteract.lmsname = self.lmsName self.eventCourseInteract.orgname = self.userSession.orgname self.eventCourseInteract.coursename = self.userSession.coursename self.eventCourseInteract.lmsuserid = self.userSession.lmsuserid self.eventCourseInteract.eventname = self.moduleType self.userSession.eventname = self.moduleType self.eventCourseInteract.moduletype = self.moduleType self.eventCourseInteract.modulesysname = self.moduleId[ self.moduleId.rfind("/") + 1:] print self.eventCourseInteract.modulesysname self.userSession.modulesysname = self.eventCourseInteract.modulesysname if self.properties.get("EVNT_GOTO_POSITION") != None: self.currEventNo = int( self.properties.get("EVNT_GOTO_POSITION")) if (self.moduleType == "chapter"): self.eventCourseInteract.chaptersysname = self.eventCourseInteract.modulesysname rsTmp = sqlFetch.psChapter( self.userSession.coursename, self.eventCourseInteract.modulesysname) if (rsTmp != None): self.eventCourseInteract.chaptertitle = rsTmp[0] self.userSession.chaptertitle = rsTmp[0] elif (self.moduleType == "session"): self.eventCourseInteract.chaptersysname = self.eventCourseInteract.modulesysname self.userSession.chaptersysname = self.eventCourseInteract.chaptersysname rsTmp = psChapterSess( self.userSession.coursename, self.eventCourseInteract.modulesysname) if (rsTmp != None): chapTitle = rsTmp[0] moduleTitle = rsTmp[1] chapSysName = rsTmp[2] self.eventCourseInteract.chaptertitle = chapTitle self.eventCourseInteract.moduletitle = moduleTitle self.eventCourseInteract.chaptersysname = chapSysName self.userSession.chaptertitle = chapTitle self.userSession.moduletitle = moduleTitle self.userSession.chapterSysName = chapSysName elif self.moduleType == "course": chapTitle = self.userSession.coursename moduleTitle = self.userSession.coursename chapSysName = self.eventCourseInteract.modulesysname self.eventCourseInteract.chaptersysname = self.eventCourseInteract.modulesysname self.eventCourseInteract.chaptertitle = self.userSession.coursename self.eventCourseInteract.moduletitle = self.userSession.coursename self.userSession.chaptertitle = chapTitle self.userSession.moduletitle = moduleTitle self.userSession.chaptersysname = chapSysName self.eventCourseInteract.eventno = self.currEventNo self.userSession.eventno = self.currEventNo self.eventCourseInteract.curposition = int( str(self.stateJson.get("position"))) self.userSession.currposition = int( str(self.stateJson.get("position"))) self.eventCourseInteract.source = "SQL" self.userSession.eventsource = "SQL" self.eventCourseInteract.courserun = self.userSession.courserun self.eventCourseInteract.createdatetime = self.userSession.createdatetime self.eventCourseInteract.moddatetime = self.userSession.lastmoddatetime #self.insertCourse() self.eventCourseInteract.save() elif self.moduleType == "openassessment": self.userSession.eventtype = "openassess" elif self.moduleType == "problem": #System.out.println("moduleType is problem") self.userSession.eventtype = "problem" self.userSession.eventname = "Quizz" self.eventProbInteract.done = rs[8] self.userSession.done = rs[8] self.eventProbInteract.lmsname = self.lmsName self.eventProbInteract.orgname = self.userSession.orgname self.eventProbInteract.coursename = self.userSession.coursename self.eventProbInteract.lmsuserid = self.userSession.lmsuserid self.eventProbInteract.eventname = "problem" self.eventProbInteract.quizzsysname = self.moduleId[ self.moduleId.rfind("/") + 1] self.userSession.modulesysname = self.eventProbInteract.quizzsysname rsTmp = sqlFetch.psProblem( self.userSession.coursename, self.eventProbInteract.quizzsysname) if (rsTmp != None): self.eventProbInteract.chaptersysname = rsTmp[0] self.eventProbInteract.chaptertitle = rsTmp[1] self.eventProbInteract.quizztitle = rsTmp[2] self.userSession.chaptersysname = rsTmp[0] self.userSession.chaptertitle = rsTmp[1] self.userSession.moduletitle = self.eventProbInteract.quizztitle self.eventProbInteract.maxgrade = rs[7] self.eventProbInteract.newscore = rs[4] self.eventProbInteract.source = "SQL" self.eventProbInteract.courserun = self.userSession.courserun self.eventProbInteract.createdatetime = self.userSession.createdatetime self.eventProbInteract.lastmoddatetime = self.userSession.lastmoddatetime if rs[7] != None: self.userSession.maxgrade = float(rs[7]) if rs[4] != None: self.userSession.currgrade = float(rs[4]) self.userSession.eventsource = "SQL" self.studentAnswerJson = json.dumps( self.stateJson.get("student_answers")) self.correctMapJson = json.dumps( self.stateJson.get("correct_map")) if (self.stateJson.get("last_submission_time") != None): #self.eventProbInteract.probsubtime=new java.sql.Timestamp( mongoDateFormat.parse( stateJson.get("last_submission_time").toString()).getTime())) #no idea about the format of the string #changed mongoDateFormat in EdxParams.Properties print 'i am here', self.stateJson.get( "last_submission_time") #self.eventProbInteract.probsubtime= datetime.datetime.strftime( self.mongoDateFormat, self.stateJson.get("last_submission_time") ) #self.eventProbInteract.probsubtime=datetime.datetime.fromtimestamp( self.stateJson.get("last_submission_time") ).strftime('%Y-%m-%d %H:%M:%S') self.eventProbInteract.probsubtime = datetime.datetime.strptime( self.stateJson.get("last_submission_time"), '%Y-%m-%dT%H:%M:%SZ') self.userSession.probsubmissiontime = self.eventProbInteract.probsubtime if (self.stateJson.get("attempts") != None): self.eventProbInteract.attempts = int( str(self.stateJson.get("attempts"))) self.userSession.attempts = self.eventProbInteract.attempts if (self.stateJson.get("done") == None): self.eventProbInteract.done = None self.userSession.done = None elif (str(self.stateJson.get("done")) == "false"): self.eventProbInteract.done = "N" self.userSession.done = "N" elif str(self.stateJson.get("done")) == "true": self.eventProbInteract.done = "Y" self.userSession.done = "Y" if self.correctMapJson != 'null': mydecoder = json.JSONDecoder() #self.keySet = self.correctMapJson.keys() self.correctMapJson = mydecoder.decode( self.correctMapJson) self.keySet = self.correctMapJson.keys() if len(self.keySet) != 0: for itr in self.keySet: self.correctMapKeyValJson = json.dumps( self.correctMapJson.get(itr)) self.correctMapKeyValJson = mydecoder.decode( self.correctMapKeyValJson) if (self.correctMapKeyValJson != None): if (self.correctMapKeyValJson.get( "correctness") != None): if str( self.correctMapKeyValJson.get( "correctness") ) == "correct": self.eventProbInteract.success = "Y" self.userSession.success = "Y" else: self.eventProbInteract.success = "N" self.userSession.success = "N" if (self.correctMapKeyValJson.get( "hint") != None): self.eventProbInteract.hintavailable = str( self.correctMapKeyValJson.get( "hint")) self.userSession.hintavailable = self.eventProbInteract.hintavailable if (self.correctMapKeyValJson.get( "hintmode") != None): self.eventProbInteract.hintmode = str( self.correctMapKeyValJson.get( "hintmode")) self.userSession.hintmode = self.eventProbInteract.hintmode if (self.studentAnswerJson != 'null'): mydecoder = json.JSONDecoder() #self.keySet = self.studentAnswerJson.keys() self.studentAnswerJson = mydecoder.decode( self.studentAnswerJson) self.keySet = self.studentAnswerJson.keys() if len(self.keySet) != 0: self.firstFlag = True self.answers = self.answers[len(self.answers):] for itr in self.keySet: if (self.firstFlag): self.answers.append( str(self.studentAnswerJson.get(itr))) self.firstFlag = False else: self.answers.append(",") self.answers.append( str(self.studentAnswerJson.get(itr))) print("answers " + self.answers) self.eventProbInteract.choice = str(self.answers) self.userSession.answerchoice = self.eventProbInteract.choice else: print("studentAnswerJSon.get(key) is empty ") if self.stateJson.get( "done") == None or self.stateJson.get( "done") == "false": self.currEventNo = int( self.properties.get("EVNT_PROBLEM_SAVE")) self.eventProbInteract.eventno = self.currEventNo self.userSession.eventno = self.currEventNo elif str(self.stateJson.get("done")) == "true": self.currEventNo = int( self.properties.get( "EVNT_SAVE_PROBLEM_SUCCESS")) self.eventProbInteract.eventno = self.currEventNo self.userSession.eventno = self.currEventNo else: if self.properties.get("EVNT_PROBLEM_GET") != None: self.currEventNo = int( self.properties.get("EVNT_PROBLEM_GET")) self.eventProbInteract.eventno = self.currEventNo self.userSession.eventno = self.currEventNo print("Evemt No " + str(self.currEventNo) + " stateJson.get(done) " + str(self.stateJson.get("done"))) #self.insertProbRec() self.eventProbInteract.save() elif self.moduleType == "video": self.userSession.eventtype = "video" self.eventVideoInteract.eventname = "video" if (self.stateJson.get("saved_video_position") != None): self.currEventNo = self.evnt_Save_Video_Position self.userSession.eventname = "saved_video_position" self.userSession.eventno = self.currEventNo self.eventVideoInteract.eventno = self.currEventNo #doubt #tmpDate = dsf.parse(stateJson.get("saved_video_position").toString()) self.tmpDate = datetime.datetime.strptime( str(self.stateJson.get('saved_video_position')), "%Y-%m-%d %H:%M:%S") self.eventVideoInteract.currseektime = float( str(self.tmpDate.hour * 3600 + self.tmpDate.minute * 600 + self.tmpDate.second)) #doubt self.userSession.currentseektime = self.eventVideoInteract.currseektime if (self.stateJson.get("speed") != None): self.eventVideoInteract.currspeed = float( str(self.stateJson.get("speed"))) self.userSession.currvideospeed = self.eventVideoInteract.currspeed self.eventVideoInteract.lmsname = self.lmsName self.eventVideoInteract.orgname = self.userSession.orgname self.eventVideoInteract.coursename = self.userSession.coursename self.eventVideoInteract.lmsuserid = self.userSession.lmsuserid self.eventVideoInteract.eventname = self.moduleType self.eventVideoInteract.videosysname = self.moduleId[ self.moduleId.rfind("/") + 1] self.userSession.eventname = self.moduleType self.userSession.modulesysname = self.eventVideoInteract.videosysname rsVideo = psVideo(self.userSession.coursename, self.eventVideoInteract.videosysname) if rsVideo != None: self.eventVideoInteract.videotitle = rsVideo[0] self.eventVideoInteract.chaptersysname = rsVideo[1] self.eventVideoInteract.chaptertitle = rsVideo[2] self.userSession.moduletitle = self.eventVideoInteract.videotitle self.userSession.chaptersysname = self.eventVideoInteract.chaptersysname self.userSession.chaptertitle = self.eventVideoInteract.chaptertitle self.eventVideoInteract.source = "SQL" self.eventVideoInteract.courserun = self.userSession.courserun self.eventVideoInteract.createdatetime = self.userSession.createdatetime self.eventVideoInteract.lastmoddatetime = self.userSession.lastmoddatetime self.userSession.eventsource = "SQL" #self.insertVideoRec() self.eventVideoInteract.save() self.userSession.sessionid = self.eventId self.userSession.eventno = self.currEventNo print("BEFORE USERSESSION RECORD NO " + str(self.recNo) + " eventId " + str(self.eventId)) print("BEFORE USERSESSION currEventNo " + str(self.currEventNo) + " moduleType " + str(self.userSession.eventtype)) self.userSession.save() print 'yahoo' #userSessionDao.insertRec(self.userSession) # catch (SQLException e) # { # // TODO Auto-generated catch block # System.out.println("SQL Exception " + e.toString()) # } # catch (ParseException e) # { # // TODO Auto-generated catch block # System.out.println("Parse Exception " + e.toString()) # } # catch (java.text.ParseException e) # { # // TODO Auto-generated catch block # System.out.println("Text Parse Exception " + e.toString())// e.printStackTrace() # } except Exception, e: print 'error1' print("Exception " + str(e))
def processProblem(self, problemName): #// Will enter as many chapters as available courseProblemQry = {} courseProblemQry["_id.category"] = "problem" courseProblemQry["_id.course"] = self.courseName courseProblemQry["_id.name"] = problemName problemCursor = self.edxCollection.find(problemQuery) for problemDo in problemCursor: courseProblems = classes.CourseProblems() defDO = problemDo.get("definition") metaDO = problemDo.get("metadata") metaDO = _decode_dict(metaDO) maxAttempt = -1 if (metaDO.get("max_attempts") != None): maxAttempt = int(str(metaDO.get("max_attempts")).strip()) else: maxAttempt = -1 weight = 0.0 if (metaDO.get("weight") != None): weight = float(str(metaDO.get("weight")).strip()) else: weight = 0.0 if (metaDO.get("showanswer") != None): if ((str(metaDO.get("showanswer")).strip()) == "never"): courseProblems.hintavailable = 0 else: courseProblems.hintavailable = 1 courseProblems.hintmode = str( metaDO.get("showanswer")).strip() dataDO = defDO.get("data") courseProblems.lmsname = self.lmsName courseProblems.orgname = self.orgName courseProblems.coursenames = self.courseName courseProblems.chaptersysname = self.chapterSysName self.quizType = None self.quizTitle = None self.correctChoice = None if (dataDO.get("data") != None): parseXMLString(str(dataDO.get("data"))) if (metaDO.get("display_name") != None): if (self.quizTitle != None): courseProblems.quiztitle = str( metaDO.get("display_name")) + " " + self.quizTitle else: courseProblems.quiztitle = str(metaDO.get("display_name")) else: if (self.quizTitle != None): courseProblems.quiztitle = self.quizTitle else: courseProblems.quiztitle = None courseProblems.quiztype = self.quizType courseProblems.quizweight = weight courseProblems.noofattemptsallowed = maxAttempt courseProblems.quizmaxmarks = weight courseProblems.correctchoice = self.correctChoice courseProblems.quizsysname = problemName courseProblems.save()
def processContents(self): endDate = None startDate = None tmpStr = [] tmpStrArr = [] isoDateFormatStr = "EEE, MMM dd HH:mm:ss IST yyyy" forumContentQry = {} forumContentQry["_id.category"] = "course" # ask they have not used query forumCursor = edxCollection.find(forumContentQry) try: for forumDO in forumCursor: courseForums = classes.Courseforums() courseForums.lmsname = self.lmsName forumDO = _decode_dict(forumDO) tmpObj = forumDO.get("_id") courseForums.commentsysid = str(tmpObj) courseForums.commenttype = str(forumDO.get("_type")) if (bool(forumDO.get("anonymous")) == False): courseForums.anonymousmode = "N" if (forumDO.get("author_id") != None): courseForums.lmsauthorid = long(forumDO.get("author_id")) if (forumDO.get("author_username") != None): courseForums.lmsauthorname = forumDO.get("author_username") if (forumDO.get("closed") != None): courseForums.closed = bool(forumDO.get("closed")) if (forumDO.get("comment_count") != None): courseForums.commentCount = int( forumDO.get("comment_count")) if (forumDO.get("commentable_id") != None): courseForums.commentablesysid = forumDO.get("comment_id") tmpStrArr = forumDO.get("course_id").split("/") courseForums.orgname = tmpStrArr[0] courseForums.coursename = tmpStrArr[1] courseForums.courserun = tmpStrArr[2] if (forumDO.get("endorsed") != None): courseForums.endorsed = bool(forumDO.get("endorsed")) if (forumDO.get("created_at") != None): courseForums.createdatetime = forumDO.get("created_at") if (forumDO.get("last_activity_at") != None): courseForums.lastmoddatetime = forumDO.get( "last_activity_at") if (forumDO.get("thread_type") != None): courseForums.threadtype = forumDO.get("thread_type") if (forumDO.get("title")): courseForums.title = forumDO.get("title") if (forumDO.get("visible") != None): courseForums.visible = bool(forumDO.get("visible")) if (forumDO.get("votes.count") != None): courseForums.totvotecount = int(forumDO.get("votes.count")) if (forumDO.get("votes.up_count") != None): courseForums.upvotecount = int( forumDO.get("votes.up_count")) courseForums.save() except Exception, err: traceback.print_exc()